Haskell Matrix Library...
Keean Schupke
k.schupke at imperial.ac.uk
Thu Jun 9 10:11:00 EDT 2005
Henning Thielemann wrote:
>On Thu, 9 Jun 2005, David Roundy wrote:
>
>
>
>>On Thu, Jun 09, 2005 at 01:35:26PM +0200, Henning Thielemann wrote:
>>
>>
>>>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.
>>>
>>>
>>The thing is that all these things are what make matlab so easy to use.
>>
>>
>
>Isn't it easier to actually use MatLab if you like it? I don't see the
>benefit of a MatLab library embedded in Haskell.
>
>
Because Haskell is a compiled language - and because I program in Haskell -
however every time I try and do something a little complicated I am
frustrated by
lack of matrix support. (and Haskell is free/open-source)
>
>
>>Would you really like to have separate multiplication operators for every
>>combination of scalars, vectors and matrices?
>>
>>
>
> There are more functions but I think they are worth the distinction. In
>the case of (+) and (-) I agree to overloaded operators. In the case of
>multiplication we have these classes of functions:
>
> - multiply a scalar with a vector or a matrix or a general tensor
> (the (*>) method in class Module in NumericPrelude)
> - multiply matrix with vector
> (the matrix is considered as a canonical representation of a linear
> operator, which is hereby applied to the vector)
> - multiply matrix with matrix
> (representing the composition of linear operators)
> - scalar product
> (could be part of a Hilbert Space type class)
> - a general product between tensors were arbitrary ranks are fused
>
>
>
>>It may be possible to come up
>>with a better scheme, but personally I'd be very happy with a library that
>>just does what matlab does, i.e. define (*), (/), (+), (-), (.*), (./), and
>>treat every object as a matrix.
>>
>>
>
>Treating everything as a matrix is a big bug of MatLab: Matrices are a
>special case of the tensors MatLab also support. So tensors of at most
>rank 2 are treated as matrices and above they are treated differently.
>This break is quite arbitrary because you often switch from vectors to
>arrays of vectors (= matrices) and from matrices to arrays of matrices (=
>higher rank tensors). In MatLab you must distinguish between row and
>column vectors, which is again quite arbitrary (although it is adapted
>from common usage in linear algebra). Further you never know if a 1x1
>matrix is actually meant as a scalar, a one-element row vector, a
>one-element column vector or a one by one matrix. In my applications I can
>always decide statically which of these four (essentially three)
>alternatives is appropriate and I want to express this by types and I want
>that the compiler checks the proper usage.
>
>
Yes, I haven't thought about general tensor support - it would be better
- however
the current project I am working on does not need tensors (yet!)
>
>
>>I'd tend to say that matlab has a working system that has a number of
>>satisfied users.
>>
>>
>
>I know also a lot of unsatisfied people - no longer being "users". :-)
>
>
I work in the electrical and electronic engineering dept of Imperial
College London,
MatLab is probably the most used engineering application (both for
teaching and
research)... Nearly everone used MatLab actively whether its the signal
processing
toolbox, the neural-network toolbox, or the control toolbox. People want
to write
equations like they look in maths text-books ... which as it happens use
the same
symbol for matrix and scalar multiplication...
>
>
>>Inventing a new interface for linear algebra is an interesting problem,
>>but I'd be satisfied with a "matlab with a nice programming language"...
>>
>>
>
>Haskell with weak matrix typing will be at least as broken as MatLab.
>
>
You could also say:
Haskell with weak matrix typing will be at least as good as MatLab.
Infact as 'broken' and 'good' merely represent opinions what you are
really saying is:
Haskell with weak matrix typing will be like MatLab...
which is a tortology.
Haskell cannot do strong matrix typing easily... you need to get into
type level
natural representations (to encode the dimensions of the matrix into the
type)...
At this point it is turning into a computer-science project rather than
a useful
matrix library.
Keean.
More information about the Libraries
mailing list