summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/sample
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bigdecimal/sample')
-rw-r--r--ext/bigdecimal/sample/linear.rb20
-rw-r--r--ext/bigdecimal/sample/nlsolve.rb21
2 files changed, 21 insertions, 20 deletions
diff --git a/ext/bigdecimal/sample/linear.rb b/ext/bigdecimal/sample/linear.rb
index 93d558b539..a33255f591 100644
--- a/ext/bigdecimal/sample/linear.rb
+++ b/ext/bigdecimal/sample/linear.rb
@@ -16,8 +16,8 @@ require "bigdecimal/ludcmp"
#
# NOTE:
-# Change following BigDecimal::limit() if needed.
-BigDecimal::limit(100)
+# Change following BigDecimal.limit() if needed.
+BigDecimal.limit(100)
#
include LUSolve
@@ -27,8 +27,8 @@ def rd_order(na)
end
na = ARGV.size
-zero = BigDecimal::new("0.0")
-one = BigDecimal::new("1.0")
+zero = BigDecimal.new("0.0")
+one = BigDecimal.new("1.0")
while (n=rd_order(na))>0
a = []
@@ -40,10 +40,10 @@ while (n=rd_order(na))>0
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.new(s);
+ as << BigDecimal.new(s);
end
- printf("Contatant vector element b[%d] ? ",i); b << BigDecimal::new(ARGF.gets);
+ printf("Contatant vector element b[%d] ? ",i); b << BigDecimal.new(ARGF.gets);
end
else
# Read data from specified file.
@@ -53,10 +53,10 @@ while (n=rd_order(na))>0
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.new(s[j]);
+ as << BigDecimal.new(s[j]);
end
- b << BigDecimal::new(s[n]);
+ b << BigDecimal.new(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 692a5023cc..7fa921c2c3 100644
--- a/ext/bigdecimal/sample/nlsolve.rb
+++ b/ext/bigdecimal/sample/nlsolve.rb
@@ -11,11 +11,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.new("0.0")
+ @one = BigDecimal.new("1.0")
+ @two = BigDecimal.new("2.0")
+ @ten = BigDecimal.new("10.0")
+ @eps = BigDecimal.new("1.0e-16")
end
def zero;@zero;end
def one ;@one ;end
@@ -31,8 +31,9 @@ class Function # :nodoc: all
f
end
end
- f = BigDecimal::limit(100)
- f = Function.new
- x = [f.zero,f.zero] # Initial values
- n = nlsolve(f,x)
- p x
+
+f = BigDecimal.limit(100)
+f = Function.new
+x = [f.zero,f.zero] # Initial values
+n = nlsolve(f,x)
+p x