summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/sample
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-05 11:30:24 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-05 11:30:24 +0000
commit2810c12a99fed7297d558d8b1aaaf755eb8b8a2d (patch)
tree03ded624e1b6eab7bcf9059c5193c25f10ee26ae /ext/bigdecimal/sample
parentae88d2fc93e887f22d025b4738ebbb00f6ae53e9 (diff)
Import bigdecimal 1.4.0.pre.20181205a
* https://github.com/ruby/bigdecimal/compare/74d25ef..v1.4.0.pre.20181205a git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal/sample')
-rw-r--r--ext/bigdecimal/sample/linear.rb21
-rw-r--r--ext/bigdecimal/sample/nlsolve.rb10
2 files changed, 16 insertions, 15 deletions
diff --git a/ext/bigdecimal/sample/linear.rb b/ext/bigdecimal/sample/linear.rb
index 3b23269f8a..516c2473be 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.new("0.0")
-one = BigDecimal.new("1.0")
+zero = BigDecimal("0.0")
+one = BigDecimal("1.0")
while (n=rd_order(na))>0
a = []
@@ -37,27 +37,28 @@ 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.new(s);
- as << BigDecimal.new(s);
+ a << BigDecimal(s)
+ as << BigDecimal(s)
end
- printf("Contatant vector element b[%d] ? ",i); b << BigDecimal.new(ARGF.gets);
+ printf("Contatant vector element b[%d] ? ",i)
+ b << BigDecimal(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.new(s[j]);
- as << BigDecimal.new(s[j]);
+ a << BigDecimal(s[j])
+ as << BigDecimal(s[j])
end
- b << BigDecimal.new(s[n]);
+ b << BigDecimal(s[n])
end
end
x = lusolve(a,b,ludecomp(a,n,zero,one),zero)
diff --git a/ext/bigdecimal/sample/nlsolve.rb b/ext/bigdecimal/sample/nlsolve.rb
index b1dd08e0a3..c2227dac73 100644
--- a/ext/bigdecimal/sample/nlsolve.rb
+++ b/ext/bigdecimal/sample/nlsolve.rb
@@ -12,11 +12,11 @@ include Newton
class Function # :nodoc: all
def initialize()
- @zero = BigDecimal.new("0.0")
- @one = BigDecimal.new("1.0")
- @two = BigDecimal.new("2.0")
- @ten = BigDecimal.new("10.0")
- @eps = BigDecimal.new("1.0e-16")
+ @zero = BigDecimal("0.0")
+ @one = BigDecimal("1.0")
+ @two = BigDecimal("2.0")
+ @ten = BigDecimal("10.0")
+ @eps = BigDecimal("1.0e-16")
end
def zero;@zero;end
def one ;@one ;end