Keean Schupke k.schupke at imperial.ac.uk
Sun Jun 12 15:00:02 EDT 2005

```Well, here for your delight is my first attempt at what some will
undoutably think is a broken matrix library. However I would argue that
my principal aim is to allow functions to be polymorphic over matrices
as well as scalars. Features are:

- Scalars and Vectors supported as [1x1] and [Nx1] matrices.
- Standard arithmetic operators do standard matrix operations (except
"/" is unimplemented - until I write a Gaussian-elimination routine)
- 'dot' operators '.*' './' do elementwise operations on matrices, and
are composed into a matrix level analogue of the
standard Numeric class hierachy.
- Any operation involving a scalar applies that operation to each
element in the matrix.
- operations in Floating that have no obvious matrix equivalents are
applied elementwise (sin/cos/tan)
- operations in Floating that have matrix equivalents (exp) are applied
elementwise for consistancy with the
other functions in the Floating class.

So functions which generalise over scalars, vectors and matrices can be
written... for example element-wise generalisation:

f :: FloatingMatrix a i e => Matrix a i e -> Matrix a i e
f x = 1./ (1 + exp (-x))

can be used with:

f (scalar 2)
f (vector [1,2,3])
f (matrix [[1,2,3],[3,4,5],[6,7,8]])

On reflection, am not that fussy over the naming of functions. 'exp'
could be matrix exponentiation rather than the
element-wise one. It could be that just defining a map for matrices is
enough, in which case 'f' could be written:

f :: FloatingMatrix a i e => Matrix a i e -> Matrix a i e
f z = mmap (\x -> 1 / (1 + exp (-x))) z

I will add features as I require them, but if anyone actually wants to
use it, I will consider patches and requests for
features...

Idea's and improvements greatly appreciated... The archive includes the
module, and a modified copy of lambdaTeX
which uses smaller fonts, more appropriate to modern high resolution
printers and displays.

Keean.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Matrix.zip
Type: application/zip
Size: 12029 bytes
Desc: not available