[Haskell-cafe] matrix computations based on the GSL

Conal Elliott conal at conal.net
Thu Jul 7 14:10:59 EDT 2005

Maybe we could solve this problem in a simple and general way by working
with a more abstract notion of linear maps, rather than the matrices
commonly used to represent linear maps.  Instead of "Matrix n m", where
n and m are either integers (requiring something like dependent types)
or type encodings of integers, use "LMap u v", where u and v are vector
spaces, e.g., R^n and R^m.  This change would eliminate the need for
dependent types or integer encodings.  From another perspective, the
integers are encodings of the vector space types, but a very restricted
subset of vector space types.  If we take the encoding out of the
interface, we might get a much mor general library, allowing for linear
maps between *any* vector spaces, not just ones of the form R^n.  For
instance, linear maps are vector spaces also, so we can handle "LMap u
(LMap u v)" (the range type of the second derivative of a u->v

Also, it's clear that "LMap R R^n" and "LMap R^n R" are different types
(for n/=1), so we can distinguish between "row" and "column" vectors
without creating more types.  Are there other reasons for orienting

I can't call these comments a concrete proposal, as it's not clear to me
how to define LMap and what operations it supports.  It may be worth
exploring, though.

Cheers,  - Conal

-----Original Message-----
From: Lennart Augustsson
Sent: Thursday, July 07, 2005 5:44 AM
To: David Roundy
Cc: haskell-cafe at haskell.org
Subject: Re: [Haskell-cafe] matrix computations based on the GSL

David Roundy wrote:
> The issue is that Haskell (as far as I understand, and noone has
> anything to the contrary) doesn't have a sufficiently powerful type
> to represent matrices or vectors in a statically typed way.  It would
> wonderful if we could represent matrix multiplication as 
> matrix_mul :: Matrix n m -> Matrix m o -> Matrix n o

Actually, Haskell does allow you to do that.  But the syntax of the
types gets pretty horrendous.
I'm sure Oleg will show you how any moment now. :)

	-- Lennart

More information about the Haskell-Cafe mailing list