From: Johann Hibschman
Subject: Is a Lisp equiv. of C++ templated numerics possible?
Date: 
Message-ID: <5stmir$ero@agate.berkeley.edu>
Hi all,

I was just reading the web site for the Blitz++ numeric library in C++
<http://monet.uwaterloo.ca/blitz/> when I realized that it sounded
an awful lot like the standard Lisp macro system.

If you're not familiar with the project, it's an attempt to create a
set of routines in C++ which will provide numeric speed approaching
(and maybe exceeding) that of Fortran for array manipulations.  They
use the template mechanism to unroll certain loops at compile time,
so that if A, B, C, and D are MxN matrices,

  A = B + C + D;

translates to the equivalent of 

for(i=0; i<M; i++)
  for(j=0; j<N; j++)
    A[i][j] = B[i][j]+C[i][j]+D[i][j];

rather than doing A = B + (C + D) and creating a temporary to hold
C+D.

1) Has anyone done work like this in Lisp?
2) Is there any reason this would work better in C++ than in Lisp?
3) Is there any reason this would work better in Lisp than in C++?

I'm not interested in C++ vs. Lisp flames; I just want to know if
there's some reason this technique is unique to C++.

Thanks,

- Johann


-- 
Johann A. Hibschman         | Grad student in Physics, working in Astronomy.
······@physics.berkeley.edu | Probing pulsar pair production processes.
From: Henry Baker
Subject: Re: Is a Lisp equiv. of C++ templated numerics possible?
Date: 
Message-ID: <hbaker-1408970953060001@10.0.2.1>
In article <··········@agate.berkeley.edu>, ······@physics2.berkeley.edu
(Johann Hibschman) wrote:

> If you're not familiar with the project, it's an attempt to create a
> set of routines in C++ which will provide numeric speed approaching
> (and maybe exceeding) that of Fortran for array manipulations.  They
> use the template mechanism to unroll certain loops at compile time,
> so that if A, B, C, and D are MxN matrices,
>   A = B + C + D;
> translates to the equivalent of 
> for(i=0; i<M; i++)
>   for(j=0; j<N; j++)
>     A[i][j] = B[i][j]+C[i][j]+D[i][j];
> rather than doing A = B + (C + D) and creating a temporary to hold
> C+D.
> 1) Has anyone done work like this in Lisp?
> 2) Is there any reason this would work better in C++ than in Lisp?
> 3) Is there any reason this would work better in Lisp than in C++?

This sort of thing has been done in APL compilers for 20 years.  Yes, it
could be done in Lisp, but you'd probably have to compile it at run-time
for the greatest ease in compiling & the best performance.