matrixMultiply

Jan Schenkel janschenkel at yahoo.com
Sat Sep 21 16:27:00 CDT 2002


Hi Brad,

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.

Hope this helped,

Jan Schenkel.

"As we grow older, we grow both wiser and more foolish
at the same time."  (De Rochefoucald)

--- Brad Allen <BradAllen at mac.com> 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
> 
> Here is the function I'm using (it's purpose is just
> to explore how 
> to put data into a matrix, do matrix multiplication,
> and display the 
> output):
> 
> 
> function testMatrix inputText
>    put the number of lines in inputText into
> rowLength
>    put the number of words in line 1 of inputText
> into columnLength
>    repeat with c = 1 to columnLength
>      repeat with r = 1 to rowLength
>        put the value of (word c of line r of
> inputText) into outputArray[r,c]
>      end repeat
>    end repeat
>    put matrixMultiply(outputArray,outputArray) into
> productArray -- 
> here is where I get the error
> 
>    --display the contents of productArray in field
> "array2"
>    put empty into field "array2"
>    repeat with c = 1 to columnLength
>      repeat with r = 1 to rowLength
>        put productArray[r,c] & space into word c of
> line r of field "array2"
>      end repeat
>    end repeat
>    return productArray
> end testMatrix
> 
> 
> Thanks!
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
>
http://lists.runrev.com/mailman/listinfo/use-revolution


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com



More information about the use-livecode mailing list