Confusion with 1 x 1 matrices



On Sun, 2007-06-10 at 19:56 -0400, Nikos Apostolakis wrote:
> "Andrej Vodopivec" <andrej.vodopivec at gmail.com> writes:
> >
> > scalarmatrixp=false changes the behaviour of "." as a product of
> vectors:
> >
> > (%i2) v : columnvector([1,2,3])$
> > (%i3) v.v;
> > (%o3) 14
> > (%i4) v.v, scalarmatrixp=false;
> > (%o4) matrix([14])
> >
> 
> I think this is a bug, at least at the mathematical level.  It seems
> that "." in maxima stands for two distinct operations, the inner
> product (aka scalar product, aka dot product) of vectors and matrix
> multiplication. 

I agree with Nikos. In the past we have already discussed the problems
of the "." operator when used for the scalar product. There should be a
separate operator for the scalar product and "." should be used only for
matrix product. Look at this example (with the current default
scalarmatrixp: true):

(%i3) a: matrix([1,3,5],[2,4,6]);
                           [ 1  3  5 ]
(%o3)                      [         ]
                           [ 2  4  6 ]
(%i4) a.a;
incompatible dimensions - cannot multiply
 -- an error.  To debug this try debugmode(true);
(%i5) b: matrix([1,3,5]);
(%o5)                      [ 1  3  5 ]
(%i6) b.b;
(%o6)                          35

I think that (%i6) should give the same error message as (%i4).

As for the default for scalarmatrixp, I agree that it should be false.
It is not enough to change it inside invert; cases like the following
are unexpected for most users:
(%i7) c: matrix([3]);
(%o7)                         [ 3 ]
(%i8) c.c;
(%o8)                           9

Regards,
Jaime Villate