matrixMultiply

Sat Sep 21 18:30:01 EDT 2002

>If I remember correctly from my Linear Algebra
>classes, in order to multiply two arrays, their
>dimensions have to be such that the first dimension of
>the second array equals the second dimension of the
>first array, so they should be of the sort:
>   Array1 [m x n]  and  Array2 [n x p]
>which means that, in this case, as it's not a square
>array, it can't multiply it with itself.
>Try again wih a square array.

Thanks! Now it all makes sense and works the way it should.

Another question about matrixMultiply in Rev: According to the entry
in the Transcript dictionary for the operator "*", we should be able
to multiply matrices by using the * operator instead of the
matrixMultiply() function.  I'm trying it with a 4 x 4 array, so it
should work, but using the * operator yields different results from
matrix multiply.

Here's the example I'm using. The following text is read into a 4 x 4
array variable with numeric keys, named outputArray

1 0 1 1
1 1 0 0
1 0 1 0
0 1 1 0

Next, I want to multiply this array by itself:

put outputArray * outputArray into productArray

or

put matrixMultiply(outputArray,outputArray) into productArray

The first example, using * yields an incorrect answer:

1 0 1 1
1 1 0 0
1 0 1 0
0 1 1 0

The second, using matrixMultiply yields the correct answer:

2 1 3 1
2 1 1 1
2 0 2 1
2 1 1 0

So, why didn't the * operator produce the correct answer? It did
work, for the simpler case of multiplying a number times a matrix,
but not for a matrix times a matrix.