Haskell Matrix Library...

David Roundy droundy at abridgegame.org
Thu Jun 9 07:29:40 EDT 2005


[Turning questions around...]

On Thu, Jun 09, 2005 at 12:07:54PM +0100, Keean Schupke wrote:
> What do people think?

I think this would be cool.  One of the things that saddens me about
haskell is that I can't really use it for work (or at least, I don't think
I could).  One thing you haven't mentioned is the ability to create data
structures containing matrices and use them nicely (i.e. with operator
overloading, etc).  This is something that I'd like, so I could create a
data type WaveFunction that is an array, but also contains its quantum
numbers and other relevant information.  In matlab you're stuck with things
being a pure matrix, which is highly inconvenient, and that's also the case
for most

> - is anyone interested in a matrix library?

Yes.

> - would people want a library like MatLab where matrices are instances
> of Num/Fractional/Floating and can be
>   used in normal math equations...

Absolutely.  The only annoyance would be that due to haskell's strongly
typed approach and lack of automatic type conversions, *everything* would
have to be a matrix.  That's no worse than matlab, but it's not one of the
features of matlib I like.  But at least haskell's way of handling rational
numbers lends itself to this, since when you make a matrix an instance of
Rational (which means defining fromRational), floating point constants can
be automatically treated as 1x1 matrices.

> - operations like cos/sin/log can be applied to a matrix (and apply to
> each element like in MatLab)...

Yeah, this does seem necesary.  Especially since I envision that
*everything* is likely to be a matrix (including scalars).

If you could implement even a moderate fraction of octave's functionality
(octave being a free matlab clone, for any listeners unfamiliar with it),
it would be great.  Matlab's got a horrible language, but it's just so
darn convenient for dealing with linear algebra.  I'd love to be able to
recommend that new students learn haskell rather than octave (which I
despise).

I'm guessing that your simple matrix class doesn't call lapack or do
blocked matrix multiplies? A blocked matrix multiply of the fftw/atlas
variety would be an interesting project to code in template haskell...
-- 
David Roundy
http://www.darcs.net


More information about the Libraries mailing list