Thanks, that's simpler than the code i was working on. Maybe something
like this could be added to Array ?
//this assumes array elements are rows of a matrix
+ Array {
mult { |matrix|
if( this.flop.size == matrix.size)
{ ^ this.collect{|row| (row * matrix).sum } }
{ "Error: matrix dimensions mismatch".postln;
^nil
}
}
}
Miguel
Dan Stowell escreveu:
> Yes, I haven't used that class either but you may find it useful.
>
> In fact matrix multiplication can be written fairly compactly in plain SC:
>
> a = [[1, 0, 2], [-1, 3, 1]];
> b = [[3,1], [2,1], [1,0]];
>
> a.collect{|row| (row * b).sum }
>
> Dan
>
> 2008/5/12 Luke Selden <
lselden@...>:
>> In the MathLib Quark there's a Matrix class that I haven't used but
>> might be worth looking into.
>>
>> ~luke
>>
>>
>>
>> On Mon, May 12, 2008 at 7:26 AM, Miguel Negrao
>> <
miguel.negrao@...> wrote:
>> > Hi
>> >
>> > Is there a way to do linear algebra in sc, specifically matrix
>> > multiplication (matrix with matrix, matrix with vector,etc) ?
>> >
>> > thanks
>> > Miguel Negrão
>> > _______________________________________________
>> > sc-users mailing list
>> >
sc-users@...
>> >
http://lists.create.ucsb.edu/mailman/listinfo/sc-users>> >
>> _______________________________________________
>> sc-users mailing list
>>
sc-users@...
>>
http://lists.create.ucsb.edu/mailman/listinfo/sc-users>>
>
>
>
_______________________________________________
sc-users mailing list
sc-users@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-users