Complex
classin packageklyn.math
public class Complex<FLOAT_TYPE extends AbstractFloat = Double> extends AbstractNumber:
Represents a complex number with real and imaginary parts.
@param <FLOAT_TYPE> Numeric type used for the components.
z = Complex<Double>(3.0, 4.0)
print(z.magnitude()) # 5.0
Properties
| Modifier and Type |
Member |
Description |
| public property |
imag imag as FLOAT_TYPE
|
The imaginary part of the complex number. |
| public property |
real real as FLOAT_TYPE
|
The real part of the complex number. |
Constructors
| Modifier and Type |
Member |
Description |
| public |
ComplexComplex(real as FLOAT_TYPE = 0, imaginary as FLOAT_TYPE = 0): |
Constructor for Complex class. |
Methods
| Modifier and Type |
Member |
Description |
| public |
conjugateconjugate() as Complex<FLOAT_TYPE>: |
Returns the conjugate of the complex number. |
| public |
magnitude |
Returns the magnitude (or absolute value) of the complex number. |
| public |
phase |
Returns the phase (or angle) of the complex number in radians. |
| public readonly |
toString |
Returns a string representation of the complex number. |
Operators