Feature #4718 ยป 0002-whitespace-fixes-for-the-CMath-module.patch
| lib/cmath.rb | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
else
|
||
|
a = Complex(log!(z.abs), z.arg)
|
||
|
if b
|
||
|
a /= log(b)
|
||
|
a /= log(b)
|
||
|
end
|
||
|
a
|
||
|
end
|
||
| ... | ... | |
|
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
|
||
| ... | ... | |
|
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
|
||
| ... | ... | |
|
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
|
||
| ... | ... | |
|
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
|
||
| ... | ... | |
|
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
|
||