From e3dc13e6f3caadaed889a4727338a0e8cb54e01d Mon Sep 17 00:00:00 2001 From: Jason Dew Date: Mon, 16 May 2011 20:47:43 -0400 Subject: [PATCH 2/2] whitespace fixes for the CMath module --- lib/cmath.rb | 32 +++++++++++++------------------- 1 files changed, 13 insertions(+), 19 deletions(-) diff --git a/lib/cmath.rb b/lib/cmath.rb index e4de057..305652c 100644 --- a/lib/cmath.rb +++ b/lib/cmath.rb @@ -36,8 +36,7 @@ module CMath exp!(z) else ere = exp!(z.real) - Complex(ere * cos!(z.imag), - ere * sin!(z.imag)) + Complex(ere * cos!(z.imag), ere * sin!(z.imag)) end end @@ -51,7 +50,7 @@ module CMath else a = Complex(log!(z.abs), z.arg) if b - a /= log(b) + a /= log(b) end a end @@ -82,18 +81,17 @@ module CMath def sqrt(z) if z.real? if z < 0 - Complex(0, sqrt!(-z)) + Complex(0, sqrt!(-z)) else - sqrt!(z) + sqrt!(z) end else - if z.imag < 0 || - (z.imag == 0 && z.imag.to_s[0] == '-') - sqrt(z.conjugate).conjugate + 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)) + r = z.abs + x = z.real + Complex(sqrt!((r + x) / 2.0), sqrt!((r - x) / 2.0)) end end end @@ -114,8 +112,7 @@ module CMath if z.real? sin!(z) else - Complex(sin!(z.real) * cosh!(z.imag), - cos!(z.real) * sinh!(z.imag)) + Complex(sin!(z.real) * cosh!(z.imag), cos!(z.real) * sinh!(z.imag)) end end @@ -125,8 +122,7 @@ module CMath if z.real? cos!(z) else - Complex(cos!(z.real) * cosh!(z.imag), - -sin!(z.real) * sinh!(z.imag)) + Complex(cos!(z.real) * cosh!(z.imag), -sin!(z.real) * sinh!(z.imag)) end end @@ -146,8 +142,7 @@ module CMath if z.real? sinh!(z) else - Complex(sinh!(z.real) * cos!(z.imag), - cosh!(z.real) * sin!(z.imag)) + Complex(sinh!(z.real) * cos!(z.imag), cosh!(z.real) * sin!(z.imag)) end end @@ -157,8 +152,7 @@ module CMath if z.real? cosh!(z) else - Complex(cosh!(z.real) * cos!(z.imag), - sinh!(z.real) * sin!(z.imag)) + Complex(cosh!(z.real) * cos!(z.imag), sinh!(z.real) * sin!(z.imag)) end end -- 1.7.3.2