Confusion with 1 x 1 matrices



"Robert Dodier" <robert.dodier at gmail.com> writes:

> On 6/9/07, Nikos Apostolakis <nikos.ap at gmail.com> wrote:
>
>> So its not clear (at least to me) when the result will be a number
>> and when it will be a matrix. This is not just idle curiosity, I
>> spent quite some time trying to figure out what was wrong with my
>> calculations, I had defined a procedure to get some matrices which
>> in some cases were 1 x 1 :(
>>
>> Is this a bug or a feature?
>
> Well, it is a feature. ? scalarmatrixp tells about it.
>

Ok now it makes sense.  I didn't know about scalarmatrixp, thanks
for pointing it out.  So I guess the computation of "invert(x)"
involves matrix multiplication while "^^-1" doesn't.  Is there a
good reason for two different methods for computing the inverse? is
one method more efficient in certain situations?

> We might consider making the default value of scalarmatrixp equal
> to false (at present it is true).  I think simplifying 1-element
> matrices to scalars is too often a bad surprise.
>

FWIW, I think that "scalarmatrixp : false" is the most sensible
default.  For sure is the least surprising for the unaware user.


Thanks,
Nikos

> HTH
> Robert