Multiplying matrices



2008/5/7 Mike Hansen <mhansen at gmail.com>:
> Hello,
>
>  Is the following desired behavior?
>
>  (%i1) m: matrix([1,2,3]);
>  (%o1)                             [ 1  2  3 ]
>  (%i2) m . transpose(m);
>  (%o2)                                 14
>
>  One would expect multiplying a 1xn matrix by a nx1 matrix to return a
>  1x1 matrix rather than just the value.

This is intended behavior. Maxima is using the operator . for matrix
multiplication and for the dot product of vectors. In your case,
maxima is computing the dot product. This can be changed with the
option variable scalarmatrixp:

(%i1) m:matrix([1,2,3]);
(%o1) matrix([1,2,3])
(%i2) m . transpose(m);
(%o2) 14
(%i3) m . transpose(m), scalarmatrixp=false;
(%o3) matrix([14])

HTH,

-- 
Andrej