summaryrefslogtreecommitdiff
path: root/ext/bigdecimal
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-21 19:49:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-21 19:49:32 +0000
commit178dafefa9057ea0eb16e89d5f703e6077b2ddab (patch)
tree4b4b57421de5b71a5cc54701d625da0bc734bd40 /ext/bigdecimal
parentd9bfa822ea7e23dcc0dd1572773495419d89e145 (diff)
* ext/bigdecimal/lib/*.rb: fixed indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/lib/bigdecimal/jacobian.rb22
-rw-r--r--ext/bigdecimal/lib/bigdecimal/ludcmp.rb38
-rw-r--r--ext/bigdecimal/lib/bigdecimal/util.rb24
3 files changed, 42 insertions, 42 deletions
diff --git a/ext/bigdecimal/lib/bigdecimal/jacobian.rb b/ext/bigdecimal/lib/bigdecimal/jacobian.rb
index 8c36ad1..8d8d583 100644
--- a/ext/bigdecimal/lib/bigdecimal/jacobian.rb
+++ b/ext/bigdecimal/lib/bigdecimal/jacobian.rb
@@ -26,13 +26,13 @@ module Jacobian
aa = a.abs
bb = b.abs
if aa == zero && bb == zero then
- true
+ true
else
- if ((a-b)/(aa+bb)).abs < e then
- true
- else
- false
- end
+ if ((a-b)/(aa+bb)).abs < e then
+ true
+ else
+ false
+ end
end
end
#++
@@ -52,17 +52,17 @@ module Jacobian
s = f.zero
deriv = []
if(nRetry>100) then
- raise "Singular Jacobian matrix. No change at x[" + i.to_s + "]"
+ raise "Singular Jacobian matrix. No change at x[" + i.to_s + "]"
end
dx = dx*f.two
x[i] += dx
fxNew = f.values(x)
for j in 0...n do
if !isEqual(fxNew[j],fx[j],f.zero,f.eps) then
- ok += 1
- deriv <<= (fxNew[j]-fx[j])/dx
+ ok += 1
+ deriv <<= (fxNew[j]-fx[j])/dx
else
- deriv <<= f.zero
+ deriv <<= f.zero
end
end
x[i] = xSave
@@ -77,7 +77,7 @@ module Jacobian
for i in 0...n do
df = dfdxi(f,fx,x,i)
for j in 0...n do
- dfdx[j*n+i] = df[j]
+ dfdx[j*n+i] = df[j]
end
end
dfdx
diff --git a/ext/bigdecimal/lib/bigdecimal/ludcmp.rb b/ext/bigdecimal/lib/bigdecimal/ludcmp.rb
index 176ed84..e18446d 100644
--- a/ext/bigdecimal/lib/bigdecimal/ludcmp.rb
+++ b/ext/bigdecimal/lib/bigdecimal/ludcmp.rb
@@ -12,24 +12,24 @@ module LUSolve
nrmrow = zero
ixn = i*n
for j in 0...n do
- biggst = a[ixn+j].abs
- nrmrow = biggst if biggst>nrmrow
+ biggst = a[ixn+j].abs
+ nrmrow = biggst if biggst>nrmrow
end
if nrmrow>zero then
- scales <<= one.div(nrmrow,prec)
+ scales <<= one.div(nrmrow,prec)
else
- raise "Singular matrix"
+ raise "Singular matrix"
end
end
n1 = n - 1
for k in 0...n1 do # Gaussian elimination with partial pivoting.
biggst = zero;
for i in k...n do
- size = a[ps[i]*n+k].abs*scales[ps[i]]
- if size>biggst then
- biggst = size
- pividx = i
- end
+ size = a[ps[i]*n+k].abs*scales[ps[i]]
+ if size>biggst then
+ biggst = size
+ pividx = i
+ end
end
raise "Singular matrix" if biggst<=zero
if pividx!=k then
@@ -42,10 +42,10 @@ module LUSolve
psin = ps[i]*n
a[psin+k] = mult = a[psin+k].div(pivot,prec)
if mult!=zero then
- pskn = ps[k]*n
- for j in (k+1)...n do
- a[psin+j] -= mult.mult(a[pskn+j],prec)
- end
+ pskn = ps[k]*n
+ for j in (k+1)...n do
+ a[psin+j] -= mult.mult(a[pskn+j],prec)
+ end
end
end
end
@@ -72,12 +72,12 @@ module LUSolve
x <<= b[ps[i]] - dot
end
(n-1).downto(0) do |i|
- dot = zero
- psin = ps[i]*n
- for j in (i+1)...n do
- dot = a[psin+j].mult(x[j],prec) + dot
- end
- x[i] = (x[i]-dot).div(a[psin+i],prec)
+ dot = zero
+ psin = ps[i]*n
+ for j in (i+1)...n do
+ dot = a[psin+j].mult(x[j],prec) + dot
+ end
+ x[i] = (x[i]-dot).div(a[psin+i],prec)
end
x
end
diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb
index 257781f..4742664 100644
--- a/ext/bigdecimal/lib/bigdecimal/util.rb
+++ b/ext/bigdecimal/lib/bigdecimal/util.rb
@@ -31,23 +31,23 @@ class BigDecimal < Numeric
# Converts a BigDecimal to a String of the form "nnnnnn.mmm".
# This method is deprecated; use BigDecimal#to_s("F") instead.
def to_digits
- if self.nan? || self.infinite? || self.zero?
- self.to_s
- else
- i = self.to_i.to_s
- s,f,y,z = self.frac.split
- i + "." + ("0"*(-z)) + f
- end
+ if self.nan? || self.infinite? || self.zero?
+ self.to_s
+ else
+ i = self.to_i.to_s
+ s,f,y,z = self.frac.split
+ i + "." + ("0"*(-z)) + f
+ end
end
end
class Rational < Numeric
# Converts a Rational to a BigDecimal
def to_d(nFig=0)
- num = self.numerator.to_s
- if nFig<=0
- nFig = BigDecimal.double_fig*2+1
- end
- BigDecimal.new(num).div(self.denominator,nFig)
+ num = self.numerator.to_s
+ if nFig<=0
+ nFig = BigDecimal.double_fig*2+1
+ end
+ BigDecimal.new(num).div(self.denominator,nFig)
end
end