Haskell Matrix Library...
droundy at abridgegame.org
Thu Jun 9 08:23:10 EDT 2005
On Thu, Jun 09, 2005 at 01:08:48PM +0100, Keean Schupke wrote:
> What about implementation?
> At the moment I am coding the vector operations in Haskell (a foreign
> interface to lapack or Intel MKL can come later)... and am using a UArray
> - is this portable enough - or should I parameterise by array type (using
> IArray) even though this might result in type ambiguities?
Personally, I'd lean towards a ForeignPtr for the back end from the
beginning--but that's partly just because I'm very comfortable with
ForeignPtrs. This is partly because I'm not sure how to pass IArray
through the FFI, and if you can't figure out how to do that you'll have to
change your storage mechanism (or do a copy... yuck) when you want to
interface with lapack. Also, the FFI is pretty portable, and there's
obviously going to be no boxing going on. It means using unsafePerformIO
all over the place, but you can pretty easily encapsulate that in a
completely safe manner.
Another interesting question is what to do with complex numbers. Matlab
just make everything complex, which is pretty easy, but sometimes leads to
uglinesses (real matrices with tiny imaginary parts due to roundoff). But
this question is one that can probably be deferred.
On another interesting note, I wonder how hard it would be to write a
compile-time optimized block matrix multiply in the spirit of ATLAS using
template haskell? One could write a little program to generate blocking
algorithms and test them all, and then generate the best one... :) I'm
sure it'd be a lot easier to write in haskell than in C, and wonder how
close we could come in performance.
More information about the Libraries