Matrix multiplication: Difference between revisions
Added Easylang
Walterpachl (talk | contribs) (add ooRexx) |
(Added Easylang) |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 2,016:
[75,00, 75,00, 75,00]
[117,00, 117,00, 117,00]]</pre>
=={{header|EasyLang}}==
proc matmul . m1[][] m2[][] r[][] .
r[][] = [ ]▼
for i to len m1[][]
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 2,083 ⟶ 2,111:
=={{header|Emacs Lisp}}==
<syntaxhighlight lang="lisp">
(defvar M1 '((2 1 4)
( 1 1 0 4)
▲ (0 1 1)))
(apply #'seq-mapn #'list M2)))
▲ (m2 '((6 3 -1 0)
▲ (-2 5 0 2)))
▲ (seq-map (lambda (item) (format "%5s " item)) line) ) ) ) ) )
</syntaxhighlight>
{{out}}
<pre>
▲ -1 6 0 6
</pre>
Line 5,607 ⟶ 5,612:
{{works with|Rakudo|2022.07-3}}
Here is
<syntaxhighlight lang="raku" line>sub infix:<
sub
</syntaxhighlight>
▲}</syntaxhighlight>
=={{header|Rascal}}==
Line 5,639 ⟶ 5,643:
=={{header|REXX}}==
<syntaxhighlight lang="rexx">/*REXX program calculates the Kronecker product of two arbitrary size matrices. */
Signal On syntax
x.=0
amat=4X2 1 2 3 4 5 6 7 8 /* define A matrix size and elements */
Line 5,711 ⟶ 5,716:
exit:
Say arg(1)
Exit
Syntax:
Say 'Syntax raised in line' sigl
Say sourceline(sigl)
Say 'rc='rc '('errortext(rc)')'
Say '***** There was a problem!'
Exit</syntaxhighlight>
{{out|output|text= when using the internal default input:}}
Line 6,653 ⟶ 6,665:
{{libheader|Wren-matrix}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="
import "./fmt" for Fmt
var a = Matrix.new([
|