matrixMultiply

Jeanne A. E. DeVoto jeanne at runrev.com
Sat Sep 21 18:36:12 EDT 2002


At 12:31 PM -0700 9/21/2002, Brad Allen wrote:
>I'm also having some difficulty with this function. Here is the error
>message I receive when I try to use it on a two-dimensional
>numerically keyed array containing only integer elements:
>
>Message execution error:
>Error description: matrixMultiply: can't multiply these arrays
>
>
>
>Here is the text I'm putting into my function"
>
>1 0 1 1
>1 1 0 0
>1 0 3 0

The problem is that this array can't be multiplied by itself - its
dimensions aren't equal - and that's what you're trying to do. Quoting
myself:

"The number of rows in the firstArray must be the same as the number of
columns in the secondArray, and the number of rows in the secondArray must
match the number of columns in the firstArray. However, the number of rows
in the firstArray and secondArray need not be the same."

For example, you can multiply these two arrays:

  1  0  3       4  5
  2  4  9       9  3
                  6  9

because one is 3x2 and the other is 2x3. But above, you're trying to
multiply a 4x3 array by another 4x3 array, which means both dimensions are
mismatched. Hence the error. You could create another array, 3x4, to
multiply by this one; or you could multiply a square array (3x3 or 4x4) by
itself.


--
Jeanne A. E. DeVoto ~ jeanne at runrev.com
Runtime Revolution Limited - The Solution for Software Development
http://www.runrev.com/





More information about the use-livecode mailing list