Matrix multiplication: Difference between revisions

Added Easylang
No edit summary
(Added Easylang)
(3 intermediate revisions by 2 users 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}}==
Line 6,638 ⟶ 6,665:
{{libheader|Wren-matrix}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./matrix" for Matrix
import "./fmt" for Fmt
 
var a = Matrix.new([
2,008

edits