Package smile.math
Record Class Complex
java.lang.Object
java.lang.Record
smile.math.Complex
- Record Components:
re
- the real part.im
- the imaginary part.
- 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
Nested ClassesModifier and TypeClassDescriptionstatic class
Packed array of complex numbers for better memory efficiency. -
Constructor Summary
ConstructorsConstructorDescriptionComplex
(double re, double im) Creates an instance of aComplex
record class. -
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.final boolean
Indicates whether some other object is "equal to" this one.exp()
Returns the complex exponential.final int
hashCode()
Returns a hash code value for this object.double
im()
Returns the value of theim
record component.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.double
re()
Returns the value of there
record component.Returns the reciprocal.scale
(double b) Scalar multiplication.sin()
Returns the complex sine.Returns this - b.tan()
Returns the complex tangent.toString()
Returns a string representation of this record class.
-
Constructor Details
-
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
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
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.
-
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
re
public double re()Returns the value of there
record component.- Returns:
- the value of the
re
record component
-
im
public double im()Returns the value of theim
record component.- Returns:
- the value of the
im
record component
-