Haskell Matrix Library...
Henning Thielemann
lemming at henning-thielemann.de
Thu Jun 9 07:35:26 EDT 2005
On Thu, 9 Jun 2005, Keean Schupke wrote:
> Hi, I have a simple matrix library (styled after MatLab's use of
> matrices), and was wondering if any of the standard libraries include
> matrix functionality.
Not more than arrays, as far as I know.
> The library as stands is not suitable for general use - but it could be
> adapted. I guess the questions are:
>
> - is there already a matrix library in the standard libraries?
There is a small linear algebra library of Jan Skibinski and a linear
algebra part of the HaskellDSP library. I remember that this question
already arose and resulted in some more interesting links.
> - 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...
I'm pretty unhappy with all these automatisms in MatLab which prevent fast
detection of mistakes, e.g. treating vectors as column or row matrices,
random collapses of singleton dimensions, automatic extension of
singletons to vectors with equal components.
What is the natural definition of matrix multiplication? The element-wise
multiplication (which is commutative like the multiplication of other Num
instances) or the matrix multiplication? I vote for separate functions or
infix operators for matrix multiplications, linear equation system
solvers, matrix-vector-multiplication, matrix and vector scaling. I wished
to have an interface to LAPACK for the floating point types because you
can hardly compete with algorithms you write in one afternoon.
Btw. when considering the class hierarchy of the numeric prelude project
http://cvs.haskell.org/darcs/numericprelude/
you would naturally put matrices and vectors in Additive, Module and
VectorSpace class but not in Fractional.
> - operations like cos/sin/log can be applied to a matrix (and apply to
> each element like in MatLab) ...
MatLab must provide these automatisms because it doesn't have proper
higher functions. I think the Haskell way is to provide a 'map' for
matrices. Otherwise the question is: What is the most natural 'exp' on
matrices? The elementwise application of 'exp' to each element or the
matrix exponentation?
More information about the Libraries
mailing list