[Maxima] How to construct a new matrix using existent ones

Stavros Macrakis macrakis at alum.mit.edu
Tue Oct 6 07:09:32 CDT 2009

```Let's define some example matrices:

a:matrix([a,b],[c,d]);

[ a  b ]
[      ]
[ c  d ]

b:matrix([e,f],[g,h]);

[ e  f ]
[      ]
[ g  h ]

A matrix in Maxima is a list of rows (each of which is a list), so appending
two matrices appends their row-lists, giving:

append(a,b);

[ a  b ]
[      ]
[ c  d ]
[      ]
[ e  f ]
[      ]
[ g  h ]

But you wanted to append the column-lists, so you need to map through the
rows:

map(append,a,b);

[ a  b  e  f ]
[            ]
[ c  d  g  h ]

Equivalently:

transpose(append(transpose(a),transpose(b)));

[ a  b  e  f ]
[            ]
[ c  d  g  h ]

I don't know if there is any built-in for these operations. If this isn't
what you had in mind, let us know.

-s

On Tue, Oct 6, 2009 at 4:18 AM, jie liu <liuauto at gmail.com> wrote:

> I have two matrix a:n*m and b:n*k, and I want to construct a new
> matrix using a and b : [a b]: n*(m+k). How can I do in Maxima.
>
>
> --
> Yours sincerely,
> Jie Liu
>
> State Key Laboratory of Industry Control Technology
> Department of Control Science and Engineering,
> Zhejiang University, China
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.math.utexas.edu/pipermail/maxima/attachments/20091006/e7efc65b/attachment.htm
```