D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Complex
/
Filename :
cdesc-Complex.ri
back
Copy
U:RDoc::NormalClass[iI"Complex:ET@I"Numeric;To:RDoc::Markup::Document:@parts[o;;[?o:RDoc::Markup::Paragraph;[I"0A \Complex object houses a pair of values, ;TI"Ogiven when the object is created as either <i>rectangular coordinates</i> ;TI"!or <i>polar coordinates</i>.;To:RDoc::Markup::BlankLine S:RDoc::Markup::Heading: leveli: textI"Rectangular Coordinates;T@o; ;[I"5The rectangular coordinates of a complex number ;TI"2are called the _real_ and _imaginary_ parts; ;TI"ssee {Complex number definition}[https://en.wikipedia.org/wiki/Complex_number#Definition_and_basic_operations].;T@o; ;[I"HYou can create a \Complex object from rectangular coordinates with:;T@o:RDoc::Markup::List: @type:BULLET:@items[ o:RDoc::Markup::ListItem:@label0;[o; ;[I"IA {complex literal}[rdoc-ref:syntax/literals.rdoc@Complex+Literals].;To;;0;[o; ;[I"\Method Complex.rect.;To;;0;[o; ;[I"\\Method Kernel#Complex, either with numeric arguments or with certain string arguments.;To;;0;[o; ;[I".\Method String#to_c, for certain strings.;T@o; ;[I"PNote that each of the stored parts may be a an instance one of the classes ;TI"+Complex, Float, Integer, or Rational; ;TI"they may be retrieved:;T@o;;;;[o;;0;[o; ;[I"ASeparately, with methods Complex#real and Complex#imaginary.;To;;0;[o; ;[I"(Together, with method Complex#rect.;T@o; ;[I"@The corresponding (computed) polar values may be retrieved:;T@o;;;;[o;;0;[o; ;[I":Separately, with methods Complex#abs and Complex#arg.;To;;0;[o; ;[I")Together, with method Complex#polar.;T@S;;i; I"Polar Coordinates;T@o; ;[I"/The polar coordinates of a complex number ;TI"5are called the _absolute_ and _argument_ parts; ;TI"Xsee {Complex polar plane}[https://en.wikipedia.org/wiki/Complex_number#Polar_form].;T@o; ;[I"&In this class, the argument part ;TI"Bin expressed {radians}[https://en.wikipedia.org/wiki/Radian] ;TI"C(not {degrees}[https://en.wikipedia.org/wiki/Degree_(angle)]).;T@o; ;[I"BYou can create a \Complex object from polar coordinates with:;T@o;;;;[o;;0;[o; ;[I"\Method Complex.polar.;To;;0;[o; ;[I";\Method Kernel#Complex, with certain string arguments.;To;;0;[o; ;[I".\Method String#to_c, for certain strings.;T@o; ;[I"PNote that each of the stored parts may be a an instance one of the classes ;TI"+Complex, Float, Integer, or Rational; ;TI"they may be retrieved:;T@o;;;;[o;;0;[o; ;[I":Separately, with methods Complex#abs and Complex#arg.;To;;0;[o; ;[I")Together, with method Complex#polar.;T@o; ;[I"FThe corresponding (computed) rectangular values may be retrieved:;T@o;;;;[o;;0;[o; ;[I"<Separately, with methods Complex#real and Complex#imag.;To;;0;[o; ;[I"(Together, with method Complex#rect.;T@S;;i; I"What's Here;T@o; ;[I"First, what's elsewhere:;T@o;;;;[o;;0;[o; ;[I"7\Class \Complex inherits (directly or indirectly) ;TI"<from classes {Numeric}[rdoc-ref:Numeric@What-27s+Here] ;TI"1and {Object}[rdoc-ref:Object@What-27s+Here].;To;;0;[o; ;[I"RIncludes (indirectly) module {Comparable}[rdoc-ref:Comparable@What-27s+Here].;T@o; ;[I"*Here, class \Complex has methods for:;T@S;;i; I"Creating \Complex Objects;T@o;;;;[o;;0;[o; ;[I"M::polar: Returns a new \Complex object based on given polar coordinates.;To;;0;[o; ;[I"+::rect (and its alias ::rectangular): ;TI"JReturns a new \Complex object based on given rectangular coordinates.;T@S;;i; I" Querying;T@o;;;;[o;;0;[o; ;[I"L#abs (and its alias #magnitude): Returns the absolute value for +self+.;To;;0;[o; ;[I"/#arg (and its aliases #angle and #phase): ;TI"8Returns the argument (angle) for +self+ in radians.;To;;0;[o; ;[I"5#denominator: Returns the denominator of +self+.;To;;0;[o; ;[I"L#finite?: Returns whether both +self.real+ and +self.image+ are finite.;To;;0;[o; ;[I"6#hash: Returns the integer hash value for +self+.;To;;0;[o; ;[I"N#imag (and its alias #imaginary): Returns the imaginary value for +self+.;To;;0;[o; ;[I"I#infinite?: Returns whether +self.real+ or +self.image+ is infinite.;To;;0;[o; ;[I"1#numerator: Returns the numerator of +self+.;To;;0;[o; ;[I"=#polar: Returns the array <tt>[self.abs, self.arg]</tt>.;To;;0;[o; ;[I"9#inspect: Returns a string representation of +self+.;To;;0;[o; ;[I".#real: Returns the real value for +self+.;To;;0;[o; ;[I"C#real?: Returns +false+; for compatibility with Numeric#real?.;To;;0;[o; ;[I")#rect (and its alias #rectangular): ;TI"7Returns the array <tt>[self.real, self.imag]</tt>.;T@S;;i; I"Comparing;T@o;;;;[o;;0;[o; ;[I"]#<=>: Returns whether +self+ is less than, equal to, or greater than the given argument.;To;;0;[o; ;[I"@#==: Returns whether +self+ is equal to the given argument.;T@S;;i; I"Converting;T@o;;;;[o;;0;[o; ;[I"D#rationalize: Returns a Rational object whose value is exactly ;TI"?or approximately equivalent to that of <tt>self.real</tt>.;To;;0;[o; ;[I"#to_c: Returns +self+.;To;;0;[o; ;[I"5#to_d: Returns the value as a BigDecimal object.;To;;0;[o; ;[I"L#to_f: Returns the value of <tt>self.real</tt> as a Float, if possible.;To;;0;[o; ;[I"O#to_i: Returns the value of <tt>self.real</tt> as an Integer, if possible.;To;;0;[o; ;[I"O#to_r: Returns the value of <tt>self.real</tt> as a Rational, if possible.;To;;0;[o; ;[I"6#to_s: Returns a string representation of +self+.;T@S;;i; I""Performing Complex Arithmetic;T@o;;;;[o;;0;[o; ;[I"=#*: Returns the product of +self+ and the given numeric.;To;;0;[o; ;[I">#**: Returns +self+ raised to power of the given numeric.;To;;0;[o; ;[I"9#+: Returns the sum of +self+ and the given numeric.;To;;0;[o; ;[I"@#-: Returns the difference of +self+ and the given numeric.;To;;0;[o; ;[I")#-@: Returns the negation of +self+.;To;;0;[o; ;[I">#/: Returns the quotient of +self+ and the given numeric.;To;;0;[o; ;[I"H#abs2: Returns square of the absolute value (magnitude) for +self+.;To;;0;[o; ;[I"G#conj (and its alias #conjugate): Returns the conjugate of +self+.;To;;0;[o; ;[I"P#fdiv: Returns <tt>Complex.rect(self.real/numeric, self.imag/numeric)</tt>.;T@S;;i; I"Working with JSON;T@o;;;;[o;;0;[o; ;[I"3::json_create: Returns a new \Complex object, ;TI"1deserialized from the given serialized hash.;To;;0;[o; ;[I"A#as_json: Returns a serialized hash constructed from +self+.;To;;0;[o; ;[I"9#to_json: Returns a JSON string representing +self+.;T@o; ;[I"qThese methods are provided by the {JSON gem}[https://github.com/ruby/json]. To make these methods available:;T@o:RDoc::Markup::Verbatim;[I"require 'json/add/complex';T:@format0: @fileI"complex.c;T:0@omit_headings_from_table_of_contents_below0o;;[ ;I"%ext/json/lib/json/add/complex.rb;T;0;0;0[ [U:RDoc::Constant[i I"I;TI"Complex::I;T:public0o;;[o; ;[I"Equivalent ;TI"$to <tt>Complex.rect(0, 1)</tt>:;T@o;;[I"Complex::I # => (0+1i);T;0;@{;0@{@cRDoc::NormalClass0[ [[I" class;T[[;[ [I"json_create;TI"%ext/json/lib/json/add/complex.rb;T[I" polar;TI"complex.c;T[I" rect;T@�[I"rectangular;T@�[:protected[ [:private[ [I" instance;T[[;[,[I"*;T@�[I"**;T@�[I"+;T@�[I"-;T@�[I"-@;T@�[I"/;T@�[I"<=>;T@�[I"==;T@�[I"abs;T@�[I" abs2;T@�[I" angle;T@�[I"arg;T@�[I"as_json;T@�[I" conj;T@�[I"conjugate;T@�[I"denominator;T@�[I" fdiv;T@�[I"finite?;T@�[I" hash;T@�[I" imag;T@�[I"imaginary;T@�[I"infinite?;T@�[I"inspect;T@�[I"magnitude;T@�[I"numerator;T@�[I" phase;T@�[I" polar;T@�[I"quo;T@�[I"rationalize;T@�[I" real;T@�[I" real?;T@�[@�@�[I"rectangular;T@�[I" to_c;T@�[I" to_f;T@�[I" to_i;T@�[I"to_json;T@�[I" to_r;T@�[I" to_s;T@�[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[@{@~@~cRDoc::TopLevel