summaryrefslogtreecommitdiff
path: root/lib/cmath.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cmath.rb')
-rw-r--r--lib/cmath.rb34
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/cmath.rb b/lib/cmath.rb
index 158da4175d..55995879e6 100644
--- a/lib/cmath.rb
+++ b/lib/cmath.rb
@@ -25,7 +25,7 @@ module CMath
alias atanh! atanh
def exp(z)
- if Complex.generic?(z)
+ if z.scalar?
exp!(z)
else
Complex(exp!(z.real) * cos!(z.image),
@@ -35,7 +35,7 @@ module CMath
def log(*args)
z, b = args
- if Complex.generic?(z) and z >= 0 and (b.nil? or b >= 0)
+ if z.scalar? and z >= 0 and (b.nil? or b >= 0)
log!(*args)
else
r, theta = z.polar
@@ -48,7 +48,7 @@ module CMath
end
def log10(z)
- if Complex.generic?(z)
+ if z.scalar?
log10!(z)
else
log(z) / log!(10)
@@ -56,7 +56,7 @@ module CMath
end
def sqrt(z)
- if Complex.generic?(z)
+ if z.scalar?
if z >= 0
sqrt!(z)
else
@@ -74,7 +74,7 @@ module CMath
end
def sin(z)
- if Complex.generic?(z)
+ if z.scalar?
sin!(z)
else
Complex(sin!(z.real) * cosh!(z.image),
@@ -83,7 +83,7 @@ module CMath
end
def cos(z)
- if Complex.generic?(z)
+ if z.scalar?
cos!(z)
else
Complex(cos!(z.real) * cosh!(z.image),
@@ -92,7 +92,7 @@ module CMath
end
def tan(z)
- if Complex.generic?(z)
+ if z.scalar?
tan!(z)
else
sin(z)/cos(z)
@@ -100,7 +100,7 @@ module CMath
end
def sinh(z)
- if Complex.generic?(z)
+ if z.scalar?
sinh!(z)
else
Complex(sinh!(z.real) * cos!(z.image),
@@ -109,7 +109,7 @@ module CMath
end
def cosh(z)
- if Complex.generic?(z)
+ if z.scalar?
cosh!(z)
else
Complex(cosh!(z.real) * cos!(z.image),
@@ -118,7 +118,7 @@ module CMath
end
def tanh(z)
- if Complex.generic?(z)
+ if z.scalar?
tanh!(z)
else
sinh(z) / cosh(z)
@@ -126,7 +126,7 @@ module CMath
end
def asin(z)
- if Complex.generic?(z) and z >= -1 and z <= 1
+ if z.scalar? and z >= -1 and z <= 1
asin!(z)
else
-1.0.im * log(1.0.im * z + sqrt(1.0 - z * z))
@@ -134,7 +134,7 @@ module CMath
end
def acos(z)
- if Complex.generic?(z) and z >= -1 and z <= 1
+ if z.scalar? and z >= -1 and z <= 1
acos!(z)
else
-1.0.im * log(z + 1.0.im * sqrt(1.0 - z * z))
@@ -142,7 +142,7 @@ module CMath
end
def atan(z)
- if Complex.generic?(z)
+ if z.scalar?
atan!(z)
else
1.0.im * log((1.0.im + z) / (1.0.im - z)) / 2.0
@@ -150,7 +150,7 @@ module CMath
end
def atan2(y,x)
- if Complex.generic?(y) and Complex.generic?(x)
+ if y.scalar? and x.scalar?
atan2!(y,x)
else
-1.0.im * log((x + 1.0.im * y) / sqrt(x * x + y * y))
@@ -158,7 +158,7 @@ module CMath
end
def acosh(z)
- if Complex.generic?(z) and z >= 1
+ if z.scalar? and z >= 1
acosh!(z)
else
log(z + sqrt(z * z - 1.0))
@@ -166,7 +166,7 @@ module CMath
end
def asinh(z)
- if Complex.generic?(z)
+ if z.scalar?
asinh!(z)
else
log(z + sqrt(1.0 + z * z))
@@ -174,7 +174,7 @@ module CMath
end
def atanh(z)
- if Complex.generic?(z) and z >= -1 and z <= 1
+ if z.scalar? and z >= -1 and z <= 1
atanh!(z)
else
log((1.0 + z) / (1.0 - z)) / 2.0