Top Level Namespace

Defined Under Namespace

Modules: Math Classes: Complex, Integer, Numeric

Instance Method Summary collapse

Instance Method Details

#Complex(a, b = 0) ⇒ Object

Creates a Complex number. a and b should be Numeric. The result will be a+bi.



86
87
88
89
90
91
92
# File 'lib/complex.rb', line 86

def Complex(a, b = 0)
  if b == 0 and (a.kind_of?(Complex) or defined? Complex::Unify)
    a
  else
    Complex.new( a.real-b.imag, a.imag+b.real )
  end
end