Reduced row echelon form: Difference between revisions

m
Use "strformat".
m (Used "<M" and "<N" in "toMatrix" instead of "a.high" and "a[0].high".)
m (Use "strformat".)
Line 2,708:
===Using floats===
When using floats, we have to be careful when doing comparisons. The previous program adapted to use floats instead of rationals may give wrong results. This would be the case with the second matrix. To get the right result, we have to do a comparison to an epsilon rather than zero. Here is the program modified to work with floats:
<lang Nim>import strutils, strformat
 
const Eps = 1e-10
Line 2,761:
for val in row:
line.addSep(" ", 0)
line.add &"{val:7.formatFloat(ffDecimal, 2).align(7)2f}"
echo line
 
Anonymous user