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 classPacked array of complex numbers for better memory efficiency. -
Constructor Summary
ConstructorsConstructorDescriptionComplex(double re, double im) Creates an instance of aComplexrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleabs()Returns the abs/modulus/magnitude.Returns this + b.Returns the conjugate.cos()Returns the complex cosine.Returns a / b.final booleanIndicates whether some other object is "equal to" this one.exp()Returns the complex exponential.final inthashCode()Returns a hash code value for this object.doubleim()Returns the value of theimrecord component.Returns this * b.static Complexof(double real) Returns a Complex instance representing the specified value.static Complexof(double real, double imag) Returns a Complex instance representing the specified value.doublephase()Returns the angle/phase/argument between -pi and pi.doublere()Returns the value of thererecord 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
-
Complex
-
-
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
-
add
-
sub
-
mul
-
scale
Scalar multiplication.- Parameters:
b- the operand.- Returns:
- the result.
-
div
-
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
-
reciprocal
-
exp
-
sin
-
cos
-
tan
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
re
-
im
-