Cholesky decomposition: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: added/changed whitespace and comments, made other cosmetic improvements. |
|||
Line 1,996:
If trailing zeroes are wanted after the decimal point for values of zero (0), the <big>'''/1'''</big> (division by one performs
<br>REXX number normalization) can be removed from the line (number 73) which contains the source statement:
<br> <code>
<lang rexx>/*REXX program
hexer = 18 22 54 42,
exit
/*──────────────────────────────────Cholesky subroutine───────────────────────*/
▲exit /*stick a fork in it, we're done.*/
▲Cholesky: procedure; arg !; call tell 'input array',!
end
end
▲ end /*i*/
▲call tell 'Cholesky factor',,$.,'─'
return
/*─────────────────────────────────ERR subroutine─────────────────────────────*/
/*─────────────────────────────────TELL subroutine────────────────────────────*/
decPlaces = 5 /*number of decimal places past the decimal point. */▼
width =10 /*width of field used to display elements*/
if y=='' then
▲ else do row=1 for order
else do row=1 for ord; do col=1 for ord; x=x
x=x $.row.col▼
end /*row*/▼
w=words(x)
say
▲ do order=1 until order**2>=w /*fast way to find the MAT order.*/
say
▲if order**2\==w then call err "matrix elements don't match its order"
▲say; say center(hdr, ((width+1)*w)%order, sep); say
z=z right( format(@.row.col,, dPlaces) / 1,
end
▲ say aLine
end /*row*/
return
/*─────────────────────────────────SQRT subroutine────────────────────────────*/
sqrt: procedure;
numeric form; numeric digits
g=g*.5'E'_%2; do j=0 while p>9; m.j=p; p=p%2+1; end
▲err: say; say; say '***error***!'; say; say arg(1); say; say; exit 13</lang>
{{out}}
<pre>
Line 2,076 ⟶ 2,060:
3 3 0
-1 1 3
════════════════input array═════════════════
|