[racket] math/matrix

From: Konrad Hinsen (konrad.hinsen at fastmail.net)
Date: Wed May 14 11:32:23 EDT 2014

Jens Axel Søgaard writes:

 > See my post in this thread 3 days ago. It is attached.

It isn't, but I found it in the thread, thanks! I am mostly interested
in using it as an example for the Racket FFI, given that I know LAPACK
rather well.

 > > Transposition can be avoided in many practically relevant situations
 > > (e.g. symmetric matrices), so such decisions should be taken on a
 > > case-by-case basis.
 > 
 > The problem is that (Matrix Flonum) and LAPACK has different
 > representation for matrices. In order to take a (Matrix Flonum)
 > and turn it into a LAPACK one, the entries in the underlying vector
 > must be transposed.

That depends. If as I assume (Matrix Flonum) used C-style row-major
order, then transposition *may* be necessary. In some cases it's
sufficient to tweak the parameters fed to LAPACK a bit. For example,
if you work with symmetric matrices, you just claim your
lower-triangular matrix to be upper-triangular and everything works
fine.

 > If we(I) had realized it sooner, the representation in (Matrix Flonum)
 > would have been the same.

I am not sure it's a good idea to design a matrix library around
LAPACK.  There are also nice C and C++ libraries, which in general use
row-major order.

Konrad.


Posted on the users mailing list.