matrixMultiply

miscdas at boxfrog.com miscdas at boxfrog.com
Sun Sep 22 03:19:01 CDT 2002


You are correct, Jan. Also, the Help stack entry for Arrays states this 
requirement very clearly. 

miscdas 

Jan Schenkel writes: 

> 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
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
 



More information about the use-livecode mailing list