Haskell Matrix Library...
David Roundy
droundy at abridgegame.org
Sat Jun 11 10:15:40 EDT 2005
On Thu, Jun 09, 2005 at 02:53:27PM +0200, 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.
I don't like it. But I also know that the rest of my research group can do
many things more easily in octave than I can without it. And as a
programming tool it's just abominable.
> > 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:
How can we overload (+) and (-) without also overloading (*)? They're all
in the same class.
> > 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.
I must admit that my familiarity with matlab is mostly through octave,
which doesn't even have as nice tensor support as matlab does (from one I
hear). But the point of a simple matrix module would simpley a have matrix
support, not to have tensor support. You can put full tensor support into
your tensor module.
Matrices are indeed a special case of tensors, but they are a special case
that has simpler operators than those that exist for tensors, and on which
there are more functions defined. The only reasonable notations that I'm
aware of for tensor multiplication are either based on repeated index
summation (or explicit summation) or treating a tensor as a matrix
(e.g. treating a fourth-rank tensor as a 9x9 matrix).
If you know of a nice representation for tensor multiplication, I'd be very
interested to hear about it. If you don't, then I'm not sure how the
creation of O(N^2) multiplication operators (where N is the highest rank
tensor supported) can be viewed as an improvement over treating everything
as a matrix.
> > 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.
Fortunately, the brokenness of matlab that bothers me isn't its matrix
operators, but rather it's features as a programming language.
--
David Roundy
http://www.darcs.net
More information about the Libraries
mailing list