Haskell Matrix Library...

David Roundy droundy at abridgegame.org
Sat Jun 11 10:30:52 EDT 2005


On Fri, Jun 10, 2005 at 10:50:01AM -0400, Jan-Willem Maessen wrote:
> On Jun 10, 2005, at 6:33 AM, Keean Schupke wrote:
> >anyone know how to marshall data for Fortran?
> 
> Find something with a C interface and use that.  Most LAPACK and BLAS
> libraries should have a C binding.  My understanding is that Fortran dope
> vector formats are not standard, though the latest versions of the
> Fortran standard aim to fix that non-portability problem.

I've never heard of a problem with the Fortran matrix format.  We call the
fortran LAPACK/BLAS routines straight from C, using an autoconf macro to
figure out how the fortran symbols are mangled.  It's not so hard.
Basically, a fortran matrix is just a C matrix (2D array) transposed.  It's
either M_ij = M[i+N*j] or M[j+N*i].  I can never remember which.

Fortran also always passes by reference, so when calling from C you need to
make every argument a pointer, but other than that you can pretty much read
the LAPACK docs and code in C straight from that.

Oddly enough, I think calling the fortran routines from C is more portable
than trying to find a C binding.

P.S. for examples of calling lapack from C/C++ (although it also does a lot
more) you can run see the dft++ source code.

darcs get http://dft.physics.cornell.edu/dft

You can grep for F77_FUNC to find fortran-calling code.  The
fortran-calling and lapack-finding autoconf macros are cribbed from mpb,
which is written by the Steven Johnson, who is one of the authors of fftw.
So I suppose you could also look at the mpb source...
-- 
David Roundy
http://www.darcs.net


More information about the Libraries mailing list