# [Maxima] Why I think lapack matrices should not be converted to list-of-lists.

Richard Fateman fateman at cs.berkeley.edu
Wed Jan 3 10:43:50 CST 2007

```
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu [mailto:maxima-
> bounces at math.utexas.edu] On Behalf Of Raymond Toy
....>
>     Robert> I think the Lisp arrays should be copied back into Maxima
> matrices.
>

Just to point out what may help inform this discussion:

It is not at all that hard -- and in fact is done in Mathematica, I believe
-- to support another type of matrix (or more...). Namely large numerical
matrices are stored in Mathematica NOT at lists of lists. This makes it
possible to mimic  programs like matlab at full speed (in fact, as fast as
matlab or faster).

A full commitment to numerical matrix computation would provide the full
complement of representation possibilities, including triangular,
tridiagonal, symmetric, sparse, ...  double, complex

I suggest the following:

(a) a new maxima "head" or "operator"  which would be (say) ddmatrix for
dense matrix of real double floats, e.g.  ((ddmatrix 10 20 simp) <a lisp
matrix compatible with C>)
(b) display programs for this. Naturally it would be unusual to see ALL of a
large matrix in a 2-D display, since the typical entry would itself take 16+
character spaces.
(c) setting and accessing functions ... i.e.  a[p,q] as a value and a[p,q]:
...

(d) conversion to and from ddmatrix to list-of-lists.

Note that (d) at least must be written anyway.

Also some policy that might automatically convert to a ddmatrix --when
possible-- for the first use of a matrix in lapack functions etc,  and
automatic conversion to a list-of-lists when necessary by setting a location
to a symbol.

What is the payoff, since conversion is in any case linear time and the
lapack stuff is quadratic or worse?  Well, the overhead of converting each
matrix repeatedly inside a loop or even inside a single matrix expression
like A.B.transpose(A) ... would be painful.

And if you want Maxima to compete head-on with Matlab, you can do it this
way.

```