Matrix multiplication: Difference between revisions

added Ursala
m (→‎Parallel processing: A Multi core adaptation of Strassen's O(n^log2(7)) matrix multiplication algorithm)
(added Ursala)
Line 899:
-7 -6 11
-17 -20 25 </pre>
 
=={{header|Ursala}}==
There is a library function for matrix multiplication of IEEE double precision floating point
numbers. This example shows how to define and use a matrix multiplication function over
any chosen field given only the relevant product and sum functions, in this case for
the built in rational number type.
 
<lang Ursala>#import rat
 
a =
 
<
<1/1, 1/1, 1/1, 1/1>,
<2/1, 4/1, 8/1, 16/1>,
<3/1, 9/1, 27/1, 81/1>,
<4/1, 16/1, 64/1, 256/1>>
 
b =
 
<
< 4/1, -3/1, 4/3, -1/4>,
<-13/3, 19/4, -7/3, 11/24>,
< 3/2, -2/1, 7/6, -1/4>,
< -1/6, 1/4, -1/6, 1/24>>
 
mmult = *rK7lD *rlD sum:-0.+ product*p
 
#cast %qLL
 
test = mmult(a,b)</lang>
output:
<pre><
<1/1,0/1,0/1,0/1>,
<0/1,1/1,0/1,0/1>,
<0/1,0/1,1/1,0/1>,
<0/1,0/1,0/1,1/1>></pre>
Anonymous user