diff options
Diffstat (limited to 'ext/bigdecimal/sample/linear.rb')
-rw-r--r-- | ext/bigdecimal/sample/linear.rb | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/ext/bigdecimal/sample/linear.rb b/ext/bigdecimal/sample/linear.rb index 516c2473be..3b23269f8a 100644 --- a/ext/bigdecimal/sample/linear.rb +++ b/ext/bigdecimal/sample/linear.rb @@ -28,8 +28,8 @@ def rd_order(na) end na = ARGV.size -zero = BigDecimal("0.0") -one = BigDecimal("1.0") +zero = BigDecimal.new("0.0") +one = BigDecimal.new("1.0") while (n=rd_order(na))>0 a = [] @@ -37,28 +37,27 @@ while (n=rd_order(na))>0 b = [] if na <= 0 # Read data from console. - printf("\nEnter coefficient matrix element A[i,j]\n") + printf("\nEnter coefficient matrix element A[i,j]\n"); for i in 0...n do for j in 0...n do printf("A[%d,%d]? ",i,j); s = ARGF.gets - a << BigDecimal(s) - as << BigDecimal(s) + a << BigDecimal.new(s); + as << BigDecimal.new(s); end - printf("Contatant vector element b[%d] ? ",i) - b << BigDecimal(ARGF.gets) + printf("Contatant vector element b[%d] ? ",i); b << BigDecimal.new(ARGF.gets); end else # Read data from specified file. - printf("Coefficient matrix and constant vector.\n") + printf("Coefficient matrix and constant vector.\n"); for i in 0...n do s = ARGF.gets printf("%d) %s",i,s) s = s.split for j in 0...n do - a << BigDecimal(s[j]) - as << BigDecimal(s[j]) + a << BigDecimal.new(s[j]); + as << BigDecimal.new(s[j]); end - b << BigDecimal(s[n]) + b << BigDecimal.new(s[n]); end end x = lusolve(a,b,ludecomp(a,n,zero,one),zero) |