diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-09 01:36:49 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-09 01:36:49 +0000 |
commit | 8e5af8b628b2a52d203e43ad5a8b18375f801cde () | |
tree | 457d72a0f7ac4ea97949ec5b317b359a7d776089 /lib/cmath.rb | |
parent | 45592f4b4c7e835881538e52172932c3e20d0c4d (diff) |
* lib/cmath.rb: fixed indent.
* lib/drb/ssl.rb: ditto. * lib/irb/**/*.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/cmath.rb | 112 |
1 files changed, 56 insertions, 56 deletions
@@ -50,11 +50,11 @@ module CMath def exp(z) begin if z.real? - exp!(z) else - ere = exp!(z.real) - Complex(ere * cos!(z.imag), - ere * sin!(z.imag)) end rescue NoMethodError handle_no_method_error @@ -70,14 +70,14 @@ module CMath begin z, b = args unless b.nil? || b.kind_of?(Numeric) - raise TypeError, "Numeric Number required" end if z.real? and z >= 0 and (b.nil? or b >= 0) - log!(*args) else - a = Complex(log!(z.abs), z.arg) - if b - a /= log(b) end a end @@ -91,9 +91,9 @@ module CMath def log2(z) begin if z.real? and z >= 0 - log2!(z) else - log(z) / log!(2) end rescue NoMethodError handle_no_method_error @@ -105,9 +105,9 @@ module CMath def log10(z) begin if z.real? and z >= 0 - log10!(z) else - log(z) / log!(10) end rescue NoMethodError handle_no_method_error @@ -122,20 +122,20 @@ module CMath def sqrt(z) begin if z.real? - if z < 0 - Complex(0, sqrt!(-z)) - else - sqrt!(z) - end else - if z.imag < 0 || - (z.imag == 0 && z.imag.to_s[0] == '-') - sqrt(z.conjugate).conjugate - else - r = z.abs - x = z.real - Complex(sqrt!((r + x) / 2.0), sqrt!((r - x) / 2.0)) - end end rescue NoMethodError handle_no_method_error @@ -153,10 +153,10 @@ module CMath def sin(z) begin if z.real? - sin!(z) else - Complex(sin!(z.real) * cosh!(z.imag), - cos!(z.real) * sinh!(z.imag)) end rescue NoMethodError handle_no_method_error @@ -168,10 +168,10 @@ module CMath def cos(z) begin if z.real? - cos!(z) else - Complex(cos!(z.real) * cosh!(z.imag), - -sin!(z.real) * sinh!(z.imag)) end rescue NoMethodError handle_no_method_error @@ -183,9 +183,9 @@ module CMath def tan(z) begin if z.real? - tan!(z) else - sin(z) / cos(z) end rescue NoMethodError handle_no_method_error @@ -197,10 +197,10 @@ module CMath def sinh(z) begin if z.real? - sinh!(z) else - Complex(sinh!(z.real) * cos!(z.imag), - cosh!(z.real) * sin!(z.imag)) end rescue NoMethodError handle_no_method_error @@ -212,10 +212,10 @@ module CMath def cosh(z) begin if z.real? - cosh!(z) else - Complex(cosh!(z.real) * cos!(z.imag), - sinh!(z.real) * sin!(z.imag)) end rescue NoMethodError handle_no_method_error @@ -227,9 +227,9 @@ module CMath def tanh(z) begin if z.real? - tanh!(z) else - sinh(z) / cosh(z) end rescue NoMethodError handle_no_method_error @@ -241,9 +241,9 @@ module CMath def asin(z) begin if z.real? and z >= -1 and z <= 1 - asin!(z) else - (-1.0).i * log(1.0.i * z + sqrt(1.0 - z * z)) end rescue NoMethodError handle_no_method_error @@ -255,9 +255,9 @@ module CMath def acos(z) begin if z.real? and z >= -1 and z <= 1 - acos!(z) else - (-1.0).i * log(z + 1.0.i * sqrt(1.0 - z * z)) end rescue NoMethodError handle_no_method_error @@ -269,9 +269,9 @@ module CMath def atan(z) begin if z.real? - atan!(z) else - 1.0.i * log((1.0.i + z) / (1.0.i - z)) / 2.0 end rescue NoMethodError handle_no_method_error @@ -284,9 +284,9 @@ module CMath def atan2(y,x) begin if y.real? and x.real? - atan2!(y,x) else - (-1.0).i * log((x + 1.0.i * y) / sqrt(x * x + y * y)) end rescue NoMethodError handle_no_method_error @@ -298,9 +298,9 @@ module CMath def asinh(z) begin if z.real? - asinh!(z) else - log(z + sqrt(1.0 + z * z)) end rescue NoMethodError handle_no_method_error @@ -312,9 +312,9 @@ module CMath def acosh(z) begin if z.real? and z >= 1 - acosh!(z) else - log(z + sqrt(z * z - 1.0)) end rescue NoMethodError handle_no_method_error @@ -326,9 +326,9 @@ module CMath def atanh(z) begin if z.real? and z >= -1 and z <= 1 - atanh!(z) else - log((1.0 + z) / (1.0 - z)) / 2.0 end rescue NoMethodError handle_no_method_error |