Anonymous user
Matrix multiplication: Difference between revisions
m
→{{header|REXX}}: added comments, added whitespace, split some lines, used better subroutine name.
m (Added Sidef language.) |
m (→{{header|REXX}}: added comments, added whitespace, split some lines, used better subroutine name.) |
||
Line 2,719:
=={{header|REXX}}==
<lang rexx>/*REXX program multiplies
x.1 = 1 2 /*╔═════════════════════════════╗*/
x.1 = '1 2'▼
x.2 = 3 4 /*║As none of the values haven't║*/
x.2 = '3 4'▼
x.3 =
x.4 = 7 8 /*╚═════════════════════════════╝*/
do r=1 while x.r\==''
do c=1 while x.r\==''; parse var x.r a.r.c x.r; end
end /*r*/
Arows=r-1 /*adjust number of rows (DO loop)*/
Acols=c-1 /* " " " cols " " */
y.
▲y.2 = 4 5 6 /*can eliminate the quotes. */
do
do c=1 while y.r\==''; parse var y.r b.r.c y.r; end
end
Bcols=c-1
c.=0; L=0
do i
do j =1 for Bcols
do k=1 for Acols
c.i.j = c.i.j + a.i.k * b.k.j; L=max(L,length(c.i.j))
end /*k*/
end /*j*/
call
call
call
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────SHOWMATRIX subroutine───────────────*/
say center(mat 'matrix',cols*(L+1)+4,"─")
do r =1 for rows; _=
do c=1 for cols; _=_ right(value(mat'.'r'.'c),L); end; say _
end /*r*/
return</lang>
{{out}}
|