Kronecker product based fractals: Difference between revisions
Content deleted Content added
m added missing </lang> |
m →{{header|REXX}}: added whitespace, changed indentations. |
||
Line 2,222:
<lang rexx>/*REXX program calculates the Kronecker product of two arbitrary size matrices. */
parse arg pGlyph . /*obtain optional argument from the CL.*/
if pGlyph=='' | pGlyph=="," then pGlyph= '█'
if length(pGlyph)==2 then pGlyph= x2c(pGlyph)
if length(pGlyph)==3 then pGlyph= d2c(pGlyph)
aMat= 3x3 0 1 0 1 1 1 0 1 0
bMat= 3x3 1 1 1 1 0 1 1 1 1
call makeMat 'A', aMat /*construct A matrix from elements.*/
call makeMat 'B', bMat /* " B " " " */
Line 2,233:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
KronMat: parse arg what; #= 0; parse var @.a.shape aRows aCols
parse var @.b.shape bRows bCols
/*──────────────────────────────────────────────────────────────────────────────────────*/
makeMat: parse arg what, size elements; arg , row 'X' col .; @.what.shape= row col
#=0; do r=1 for row /* [↓] bump item#; get item; max width*/
do c=1 for col; #= # + 1; @.what.r.c= word(elements, #)
end /*c*/ /* [↑] define an element of WHAT matrix*/
end /*r*/; return
/*──────────────────────────────────────────────────────────────────────────────────────*/
showMat: parse arg what, size .; parse var size row 'X' col /*obtain mat name, sz*/
do r=1 for row;
do c=1 for col; $= $ || @.what.r.c
end /*c*/
$= translate($, pGlyph, 10)
say strip($, 'T') /*display line──►term*/
end /*r*/; return</lang>
{{out|output|text= when using the default input:}}
<pre>
███
|