Jump to content

Matrix multiplication: Difference between revisions

Added Easylang
m (→‎{{header|Wren}}: Minor tidy)
(Added Easylang)
(2 intermediate revisions by one other user not shown)
Line 2,016:
[75,00, 75,00, 75,00]
[117,00, 117,00, 117,00]]</pre>
=={{header|EasyLang}}==
}</syntaxhighlight>
proc matmul . m1[][] m2[][] r[][] .
r[][] = [ ]
for i to len m1[][]
r[][] &= [ ]
for j = 1 to len m2[1][]
r[i][] &= 0
for k to len m2[][]
r[i][j] += m1[i][k] * m2[k][j]
.
.
.
.
mat1[][] = [ [ 1 2 3 ] [ 4 5 6 ] ]
mat2[][] = [ [ 1 2 ] [ 3 4 ] [ 5 6 ] ]
matmul mat1[][] mat2[][] erg[][]
print erg[][]
</syntaxhighlight>
 
{{out}}
<pre>
[
[ 22 28 ]
[ 49 64 ]
]
</pre>
 
=={{header|EGL}}==
<syntaxhighlight lang="egl">
Line 5,584 ⟶ 5,612:
{{works with|Rakudo|2022.07-3}}
 
Here is an evena more concisefunctional version, expressing the product of two matrices as the cross dot product of the first matrix with the transpose of the second :
 
<syntaxhighlight lang="raku" line>sub infix:<×·>( { [+] @A,^a Z* @B)^b {}
sub crossinfix:<×>(@A, ([Z] @B), with{ =>(@A { [+Z] @^a Z* B).rotor(@^bB) })
</syntaxhighlight>
.rotor(@B);
}</syntaxhighlight>
 
=={{header|Rascal}}==
1,982

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.