lib/ruby/truffle/stdlib/cmath.rb
##
# Returns the natural logarithm of Complex. If a second argument is given,
# it will be the base of logarithm.
#
#   CMath.log(1 + 4i)     #=> (1.416606672028108+1.3258176636680326i)
#   CMath.log(1 + 4i, 10) #=> (0.6152244606891369+0.5757952953408879i)
Returns the natural logarithm of Complex. If a second argument is given,
it will be the base of logarithm.


Returns the natural logarithm of Complex . If a second argument is given it will be the base of logarithm .
def log(*args)
    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
    rescue NoMethodError
      handle_no_method_error
    end
  end
def log ( * args ) 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 rescue NoMethodError handle_no_method_error end end
Returns the natural logarithm of Complex.
Returns the natural logarithm of Complex .
args
<not_specific>