Anonymous user
Matrix multiplication: Difference between revisions
m
→{{header|REXX}}: added/changed whitespace and comments, changed indentations.
m (→{{header|Sidef}}: code simplifications) |
m (→{{header|REXX}}: added/changed whitespace and comments, changed indentations.) |
||
Line 3,056:
=={{header|REXX}}==
<lang rexx>/*REXX program multiplies two matrices together, displays the matrices and
x.=; x.1=1 2 /*╔═══════════════════════════════════╗*/
x.2=3 4 /*║ As none of the matrix values have ║*/
x.3=5 6 /*║ a sign, quotes aren't needed. ║*/
x.4=7 8 /*╚═══════════════════════════════════╝*/
do r=1 while x.r\=='' /*build the "A" matrix from X. numbers.*/
do c=1 while x.r\=='';
end /*r*/
Arows=r-1 /*adjust the number of rows (DO loop).*/
Acols=c-1 /* " " " " cols " " .*/
y.=; y.1=1 2 3
y.2=4 5 6
do r=1 while y.r\=='' /*build the "B" matrix from Y. numbers.*/
do c=1 while y.r\=='';
end /*r*/
Brows=r-1 /*adjust the number of rows (DO loop).*/
Bcols=c-1 /* " " " " cols " " */
c.=0; w=0 /*W is max width of an matrix element.*/
call showMatrix 'A', Arows, Acols /*display matrix A ───► the terminal.*/
call showMatrix 'B', Brows, Bcols /* " " B ───► " " */
call showMatrix 'C', Arows, Bcols /* " " C ───► " " */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
showMatrix:
do r=1 for rows; _=
'''output'''
<pre>
─A matrix─
|