1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

use num#i.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2009-08-16 23:12:41 +00:00
parent 02a7cbec82
commit 01971cad75
2 changed files with 8 additions and 4 deletions

View file

@ -1,3 +1,7 @@
Mon Aug 17 08:11:53 2009 Tadayoshi Funaba <tadf@dotrb.org>
* lib/cmath.rb: use num#i.
Mon Aug 17 07:59:00 2009 Tadayoshi Funaba <tadf@dotrb.org> Mon Aug 17 07:59:00 2009 Tadayoshi Funaba <tadf@dotrb.org>
* numeric.c (flo_pow,fix_pow): may return complex number. * numeric.c (flo_pow,fix_pow): may return complex number.

View file

@ -148,7 +148,7 @@ module CMath
if z.real? and z >= -1 and z <= 1 if z.real? and z >= -1 and z <= 1
asin!(z) asin!(z)
else else
Complex(0, -1.0) * log(Complex(0, 1.0) * z + sqrt(1.0 - z * z)) (-1.0).i * log(1.0.i * z + sqrt(1.0 - z * z))
end end
end end
@ -156,7 +156,7 @@ module CMath
if z.real? and z >= -1 and z <= 1 if z.real? and z >= -1 and z <= 1
acos!(z) acos!(z)
else else
Complex(0, -1.0) * log(z + Complex(0, 1.0) * sqrt(1.0 - z * z)) (-1.0).i * log(z + 1.0.i * sqrt(1.0 - z * z))
end end
end end
@ -164,7 +164,7 @@ module CMath
if z.real? if z.real?
atan!(z) atan!(z)
else else
Complex(0, 1.0) * log((Complex(0, 1.0) + z) / (Complex(0, 1.0) - z)) / 2.0 1.0.i * log((1.0.i + z) / (1.0.i - z)) / 2.0
end end
end end
@ -172,7 +172,7 @@ module CMath
if y.real? and x.real? if y.real? and x.real?
atan2!(y,x) atan2!(y,x)
else else
Complex(0, -1.0) * log((x + Complex(0, 1.0) * y) / sqrt(x * x + y * y)) (-1.0).i * log((x + 1.0.i * y) / sqrt(x * x + y * y))
end end
end end