Package org.jscience.mathematics.number
Class Complex
- All Implemented Interfaces:
Serializable
,Comparable<Complex>
,javolution.lang.Immutable
,javolution.lang.Realtime
,javolution.lang.ValueType
,javolution.xml.XMLSerializable
,Field<Complex>
,GroupAdditive<Complex>
,GroupMultiplicative<Complex>
,Ring<Complex>
,Structure<Complex>
This class represents an immutable complex number.
- See Also:
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
argument()
Returns the argument of this complex number.int
Compares two complex numbers, the real components are compared first, then if equal, the imaginary components.Returns the conjugate of this complex number.copy()
Returns a copy of this numberallocated
by the calling thread (possibly on the stack).divide
(double k) Returns this complex divided by the specified factor.Returns this complex divided by the specified complex.double
boolean
Compares this complex against the specified Object.boolean
Indicates if two complexes are "sufficiently" alike to be considered equal.exp()
Returns the exponential number e raised to the power of this complex.double
Returns the imaginary component of this complex number.double
getReal()
Returns the real component of this complex number.int
hashCode()
Returns the hash code for this complex number.inverse()
Returns the inverse of this complex.boolean
Indicates if either the real or imaginary component of this complex is infinite.boolean
isLargerThan
(Complex that) Compares themagnitude
of this complex number with the magnitude of the complex number specified.boolean
isNaN()
Indicates if either the real or imaginary component of this complex is not a number.log()
Returns the principal natural logarithm (base e) of this complex.long
double
Returns the magnitude of this complex number, also referred to as the "modulus" or "length".Returns the difference between this complex and the one specified.opposite()
Returns the negation of this complex.Returns the sum of this complex with the one specified.pow
(double e) Returns this complex raised to the specified power.Returns this complex raised to the power of the specified complex exponent.sqrt()
Returns one of the two square root of this complex number.times
(double k) Returns this complex multiplied by the specified factor.Returns the product of this complex with the one specified.javolution.text.Text
toText()
Returns the text representation of this complex number.static Complex
valueOf
(double real, double imaginary) Returns the complex number having the specified real and imaginary components.static Complex
valueOf
(CharSequence csq) Returns the complex number for the specified character sequence.Methods inherited from class org.jscience.mathematics.number.Number
byteValue, floatValue, intValue, isGreaterThan, isLessThan, pow, shortValue, toString
-
Field Details
-
ZERO
The complex number zero. -
ONE
The complex number one. -
I
The imaginary unit i.
-
-
Method Details
-
valueOf
Returns the complex number having the specified real and imaginary components.- Parameters:
real
- the real component of this complex number.imaginary
- the imaginary component of this complex number.- Returns:
- the corresponding complex number.
- See Also:
-
valueOf
Returns the complex number for the specified character sequence.- Parameters:
csq
- the character sequence.- Returns:
TextFormat.getInstance(Complex.class).parse(csq)
- Throws:
IllegalArgumentException
- if the character sequence does not contain a parsable complex number.- See Also:
-
TextFormat.getInstance(Class)
-
isInfinite
public boolean isInfinite()Indicates if either the real or imaginary component of this complex is infinite.- Returns:
true
if this complex is infinite;false
otherwise.
-
isNaN
public boolean isNaN()Indicates if either the real or imaginary component of this complex is not a number.- Returns:
true
if this complex is NaN;false
otherwise.
-
getReal
public double getReal()Returns the real component of this complex number.- Returns:
- the real component.
-
getImaginary
public double getImaginary()Returns the imaginary component of this complex number.- Returns:
- the imaginary component.
-
opposite
Returns the negation of this complex.- Specified by:
opposite
in interfaceGroupAdditive<Complex>
- Returns:
-this
.
-
plus
Returns the sum of this complex with the one specified.- Specified by:
plus
in interfaceGroupAdditive<Complex>
- Parameters:
that
- the complex to be added.- Returns:
this + that
.
-
minus
Returns the difference between this complex and the one specified. -
times
Returns this complex multiplied by the specified factor.- Parameters:
k
- the factor multiplier.- Returns:
this * k
.
-
times
Returns the product of this complex with the one specified. -
inverse
Returns the inverse of this complex.- Specified by:
inverse
in interfaceGroupMultiplicative<Complex>
- Returns:
1 / this
.
-
divide
Returns this complex divided by the specified factor.- Parameters:
k
- the factor divisor.- Returns:
this / k
.
-
divide
Returns this complex divided by the specified complex.- Parameters:
that
- the complex divisor.- Returns:
this / that
.
-
conjugate
Returns the conjugate of this complex number.- Returns:
(this.real(), - this.imaginary())
.
-
magnitude
public double magnitude()Returns the magnitude of this complex number, also referred to as the "modulus" or "length".- Returns:
- the magnitude of this complex number.
-
argument
public double argument()Returns the argument of this complex number. It is the angle in radians, measured counter-clockwise from the real axis.- Returns:
- argument of this complex number.
-
sqrt
Returns one of the two square root of this complex number.- Returns:
sqrt(this)
.
-
exp
Returns the exponential number e raised to the power of this complex. Note:ePI*i = -1
- Returns:
exp(this)
.
-
log
Returns the principal natural logarithm (base e) of this complex. Note: There are an infinity of solutions.- Returns:
log(this)
.
-
pow
Returns this complex raised to the specified power.- Parameters:
e
- the exponent.- Returns:
this**e
.
-
pow
Returns this complex raised to the power of the specified complex exponent.- Parameters:
that
- the exponent.- Returns:
this**that
.
-
equals
Indicates if two complexes are "sufficiently" alike to be considered equal.- Parameters:
that
- the complex to compare with.tolerance
- the maximum magnitude of the difference between them before they are considered not equal.- Returns:
true
if they are considered equal;false
otherwise.
-
equals
Compares this complex against the specified Object. -
hashCode
public int hashCode()Returns the hash code for this complex number. -
toText
public javolution.text.Text toText()Returns the text representation of this complex number. -
longValue
public long longValue() -
doubleValue
public double doubleValue()- Specified by:
doubleValue
in classNumber<Complex>
- Returns:
(double) this.getReal()
-
compareTo
Compares two complex numbers, the real components are compared first, then if equal, the imaginary components. -
isLargerThan
Compares themagnitude
of this complex number with the magnitude of the complex number specified.- Specified by:
isLargerThan
in classNumber<Complex>
- Parameters:
that
- the complex number to be compared with.- Returns:
|this| > |that|
-
copy
Description copied from class:Number
Returns a copy of this numberallocated
by the calling thread (possibly on the stack).
-