Project

General

Profile

Bug #10487 ยป modify_cmath.rb.patch

gogotanaka (Kazuki Tanaka), 11/08/2014 07:50 PM

View differences:

lib/cmath.rb
66 66
  # it will be the base of logarithm.
67 67
  #
68 68
  #   log(Complex(0,0)) #=> -Infinity+0.0i
69
  def log(*args)
69
  def log(z, b=E)
70 70
    begin
71
      z, b = args
72
      unless b.nil? || b.kind_of?(Numeric)
73
        raise TypeError,  "Numeric Number required"
74
      end
75
      if z.real? and z >= 0 and (b.nil? or b >= 0)
76
        log!(*args)
71
      if z.real? && z >= 0 && b >= 0
72
        log!(z, b)
77 73
      else
78
        a = Complex(log!(z.abs), z.arg)
79
        if b
80
          a /= log(b)
81
        end
82
        a
74
        Complex(log!(z.abs), z.arg) / log(b)
83 75
      end
84 76
    rescue NoMethodError
85 77
      handle_no_method_error
......
397 389
  module_function :handle_no_method_error
398 390
end
399

  
400
-