Project

General

Profile

Feature #4717 ยป 0001-adding-documentation-to-the-CMath-module.patch

jasondew (Jason Dew), 05/17/2011 09:49 AM

View differences:

lib/cmath.rb
##
# Math functions for the complex numbers
module CMath
include Math
......
alias acosh! acosh
alias atanh! atanh
##
# returns the value of e raised to the +z+ power
def exp(z)
if z.real?
exp!(z)
......
end
end
##
# returns the log of the first argument with the base
# optionally specified as the second argument
def log(*args)
z, b = args
if z.real? and z >= 0 and (b.nil? or b >= 0)
......
end
end
##
# returns the log base 2 of +z+
def log2(z)
if z.real? and z >= 0
log2!(z)
......
end
end
##
# returns the log base 10 of +z+
def log10(z)
if z.real? and z >= 0
log10!(z)
......
end
end
##
# returns the square root of +z+
def sqrt(z)
if z.real?
if z < 0
......
end
end
##
# returns the cube root of +z+
def cbrt(z)
if z.real?
cbrt!(z)
......
end
end
##
# returns the sine of +z+, where +z+ is given in radians
def sin(z)
if z.real?
sin!(z)
......
end
end
##
# returns the cosine of +z+, where +z+ is given in radians
def cos(z)
if z.real?
cos!(z)
......
end
end
##
# returns the tangent of +z+, where +z+ is given in radians
def tan(z)
if z.real?
tan!(z)
......
end
end
##
# returns the hyperbolic sine of +z+
def sinh(z)
if z.real?
sinh!(z)
......
end
end
##
# returns the hyperbolic cosine of +z+
def cosh(z)
if z.real?
cosh!(z)
......
end
end
##
# returns the hyperbolic tangent of +z+
def tanh(z)
if z.real?
tanh!(z)
......
end
end
##
# returns the arc sine of +z+
def asin(z)
if z.real? and z >= -1 and z <= 1
asin!(z)
......
end
end
##
# returns the arc cosine of +z+
def acos(z)
if z.real? and z >= -1 and z <= 1
acos!(z)
......
end
end
##
# returns the arc tangent of +z+
def atan(z)
if z.real?
atan!(z)
......
end
end
##
# returns the arc tangent of +y+ / +x+ using the signs
# of +y+ and +x+ to determine the quadrant
def atan2(y,x)
if y.real? and x.real?
atan2!(y,x)
......
end
end
##
# returns the inverse hyperbolic sine of +z+
def asinh(z)
if z.real?
asinh!(z)
......
end
end
##
# returns the inverse hyperbolic cosine of +z+
def acosh(z)
if z.real? and z >= 1
acosh!(z)
......
end
end
##
# returns the inverse hyperbolic tangent of +z+
def atanh(z)
if z.real? and z >= -1 and z <= 1
atanh!(z)
    (1-1/1)