changing the dimensions of a matrix



On Apr 6, 2005 10:57 PM, Kamaraju Kusumanchi  wrote:
>
> A1 : matrix([1,2], [3,4], [5,6])
>
> Now I want to reshape the 3x2 matrix into a vector of 6x1 so that the
> end result would be same as declaring
>
> A2 = matrix([1, 3, 5, 2, 4, 6])
>

flatten_matrix(m):= apply(append, args(transpose(m))$

Then flatten_matrix(A1) gives you the 6-element list [1,3,5,2,4,6]. Lists
function as vectors in most contexts in Maxima. If you want a 1x6 matrix,
you can instead defien:

flatten_matrix(m):= matrix(apply(append, args(transpose(m)))$

-s