[Maxima] Numerical Matrix operations

Richard Fateman fateman at cs.berkeley.edu
Wed Jun 11 10:50:20 CDT 2008

```

> -----Original Message-----
> From: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Kun Lin
> Sent: Wednesday, June 11, 2008 5:12 AM
> To: maxima at math.utexas.edu
> Subject: [Maxima] Numerical Matrix operations
>
> Hi,
>
> So i have been doing alot of Maxima programming lately :-)
>
> There are couple questions i have.
>
> 1) Is there a easy command to figure out the dimension of a matrix?
>   For now i have to do length(M) to get the row number and
> length(transpose(M)) to get the column number of matrix M.
>    Of course i can always write a function do combine the operations
> above:-)

length(m) and
length(first(m))

>
>
> 2) When I declear a matrix of either 1xn or nx1. Let's call
> that matrix
> M.  so in matlab, i can just think of M as a vector.
> Meaning it doesn't matter if the matrix is 1xn or nx1 when i
> do M[2] it
> will return the same element.  However, in maxima i have to
> explicitly do
> either M[2,1] or M[1,2] depending on the dimension of the
> matrix.  Is
> there a way for maxima to do what matlab is doing?

part(m,1,1)  maybe

>
>
> 3) When i call row(M,1), maxima returns a matrix back. can i
> make it so
> that it returns an array?

A matrix is a list.  If you want an array, you have to copy it into an
array.
Unless you really don't need an array.

>
>
> 4) Is there a struct type in maxima?

Yes, there is a way of doing this. defstruct, which is probably not
documented.

somthing like
> Input:
> a.one=1,
> a.two=2,
> outout:
> a
>    one=1
>    two=2
>
>
> 5) Can i do object oriented programming in maxima? (creating classes)

maybe you should be using Common Lisp, where there is an elaborate
object system.  Probably you can fake this in Maxima, somehow.

>
> - Kun
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
```