Package smile.math
Class Complex
java.lang.Object
smile.math.Complex
- All Implemented Interfaces:
Serializable
Complex number. The object is immutable so once you create and initialize
a Complex object, you cannot modify it.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Packed array of complex numbers for better memory efficiency. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
abs()
Returns the abs/modulus/magnitude.Returns this + b.Returns the conjugate.cos()
Returns the complex cosine.Returns a / b.boolean
exp()
Returns the complex exponential.int
hashCode()
Returns this * b.static Complex
of
(double real) Returns a Complex instance representing the specified value.static Complex
of
(double real, double imag) Returns a Complex instance representing the specified value.double
phase()
Returns the angle/phase/argument between -pi and pi.Returns the reciprocal.scale
(double b) Scalar multiplication.sin()
Returns the complex sine.Returns this - b.tan()
Returns the complex tangent.toString()
-
Field Details
-
re
public final double reThe real part. -
im
public final double imThe imaginary part.
-
-
Constructor Details
-
Complex
public Complex(double real, double imag) Constructor.- Parameters:
real
- the real part.imag
- the imaginary part.
-
-
Method Details
-
of
Returns a Complex instance representing the specified value.- Parameters:
real
- the real part.- Returns:
- the complex object.
-
of
Returns a Complex instance representing the specified value.- Parameters:
real
- the real part.imag
- the imaginary part.- Returns:
- the complex object.
-
toString
-
equals
-
hashCode
public int hashCode() -
add
Returns this + b.- Parameters:
b
- the operand.- Returns:
- the result.
-
sub
Returns this - b.- Parameters:
b
- the operand.- Returns:
- the result.
-
mul
Returns this * b.- Parameters:
b
- the operand.- Returns:
- the result.
-
scale
Scalar multiplication.- Parameters:
b
- the operand.- Returns:
- the result.
-
div
Returns a / b.- Parameters:
b
- the operand.- Returns:
- the result.
-
abs
public double abs()Returns the abs/modulus/magnitude.- Returns:
- the modulus.
-
phase
public double phase()Returns the angle/phase/argument between -pi and pi.- Returns:
- the phase between -pi and pi.
-
conjugate
Returns the conjugate.- Returns:
- the conjugate.
-
reciprocal
Returns the reciprocal.- Returns:
- the reciprocal.
-
exp
Returns the complex exponential.- Returns:
- the complex exponential.
-
sin
Returns the complex sine.- Returns:
- the complex sine.
-
cos
Returns the complex cosine.- Returns:
- the complex cosine.
-
tan
Returns the complex tangent.- Returns:
- the complex tangent.
-