Complex
class in package klyn.math

    public class Complex<FLOAT_TYPE extends AbstractFloat = Double> extends AbstractNumber:

Complex

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 | Complex `Complex(real as FLOAT_TYPE = 0, imaginary as FLOAT_TYPE = 0):` | Constructor for Complex class.

Methods

Modifier and Type | Member | Description
--- | --- | ---
public | conjugate `conjugate() as Complex<FLOAT_TYPE>:` | Returns the conjugate of the complex number.
public | magnitude `magnitude() as Double:` | Returns the magnitude (or absolute value) of the complex number.
public | phase `phase() as Double:` | Returns the phase (or angle) of the complex number in radians.
public readonly | toString `toString() as String:` | Returns a string representation of the complex number.

Operators

Modifier and Type | Member | Description
--- | --- | ---
public static | operator*( c1 as Complex<FLOAT_TYPE>, c2 as Complex<FLOAT_TYPE> ) as Complex<FLOAT_TYPE>: | Multiplication operator for Complex numbers.
public static | operator+( c1 as Complex<FLOAT_TYPE>, c2 as Complex<FLOAT_TYPE> ) as Complex<FLOAT_TYPE>: | Addition operator for Complex numbers.
public static | operator+( c1 as Complex<FLOAT_TYPE>, value as FLOAT_TYPE ) as Complex<FLOAT_TYPE>: | Addition operator between a complex number and a scalar value.
public static | operator+( value as FLOAT_TYPE, c1 as Complex<FLOAT_TYPE> ) as Complex<FLOAT_TYPE>: | Addition operator between a scalar value and a complex number.
public static | operator-( c1 as Complex<FLOAT_TYPE>, c2 as Complex<FLOAT_TYPE> ) as Complex<FLOAT_TYPE>: | Subtraction operator for Complex numbers.
public static | operator-( c1 as Complex<FLOAT_TYPE>, value as FLOAT_TYPE ) as Complex<FLOAT_TYPE>: | Subtraction operator between a complex number and a scalar value.
public static | operator-( value as FLOAT_TYPE, c1 as Complex<FLOAT_TYPE> ) as Complex<FLOAT_TYPE>: | Subtraction operator between a scalar value and a complex number.
public static | operator/( c1 as Complex<FLOAT_TYPE>, c2 as Complex<FLOAT_TYPE> ) as Complex<FLOAT_TYPE>: | Division operator for Complex numbers.