Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • complex.rb

Class/Module Index [+]

Quicksearch

Numeric

Numeric is a built-in class on which Fixnum, Bignum, etc., are based. Here some methods are added so that all number types can be treated to some extent as Complex numbers.

Public Instance Methods

angle() click to toggle source
Alias for: arg
arg() click to toggle source

See Complex#arg.

 
               # File complex.rb, line 60
def arg
  Math.atan2!(0, self)
end
            
Also aliased as: angle
conj() click to toggle source
Alias for: conjugate
conjugate() click to toggle source

See Complex#conjugate (short answer: returns self).

 
               # File complex.rb, line 75
def conjugate
  self
end
            
Also aliased as: conj
im() click to toggle source

Returns a Complex number (0,self).

 
               # File complex.rb, line 38
def im
  Complex(0, self)
end
            
imag() click to toggle source
Alias for: image
image() click to toggle source

The imaginary part of a complex number, i.e. 0.

 
               # File complex.rb, line 52
def image
  0
end
            
Also aliased as: imag
polar() click to toggle source

See Complex#polar.

 
               # File complex.rb, line 68
def polar
  return abs, arg
end
            
real() click to toggle source

The real part of a complex number, i.e. self.

 
               # File complex.rb, line 45
def real
  self
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus