-
Notifications
You must be signed in to change notification settings - Fork 0
math.MutableComplex.Class.MutableComplex
dsp-collection / math/MutableComplex / MutableComplex
A mutable complex number.
This class implementation for storing complex numbers is optimized for high performance computation. Immutability is sacrificed in favor of fast in-place operations.
When mutability is no longer needed, a MutableComplex can be type cast into an immutable Complex.
new MutableComplex(re?, im?): MutableComplex;Constructs a MutableComplex.
number = 0
The real part. Optional. Default is 0.
number = 0
The imaginary part. Optional. Default is 0.
MutableComplex
| Property | Modifier | Type | Description | Overrides | Inherited from |
|---|---|---|---|---|---|
im
|
public |
number |
Mutable imaginary part of the complex number. |
Complex.im
|
- |
re
|
public |
number |
Mutable real part of the complex number. |
Complex.re
|
- |
I
|
readonly |
Complex |
The imaginary unit i. | - |
Complex.I
|
INFINITY
|
readonly |
Complex |
A Complex representing "+Infinity + Infinity i" |
- |
Complex.INFINITY
|
NaN
|
readonly |
Complex |
A Complex representing "NaN + NaN i" |
- |
Complex.NaN
|
ONE
|
readonly |
Complex |
A Complex representing 1. |
- |
Complex.ONE
|
TWO
|
readonly |
Complex |
A Complex representing 2. |
- |
Complex.TWO
|
ZERO
|
readonly |
Complex |
A Complex representing 0. |
- |
Complex.ZERO
|
abs(): number;Returns the absolute value (magnitude, vector length, radius).
number
add(x): Complex;Returns this + x;
addReal(x): Complex;Returns this + x;
number
addRealTo(x): void;Mutates this MutableComplex by adding a real number.
number
void
addTo(x): void;Mutates this MutableComplex by adding a Complex.
void
arg(): number;Returns the argument (angle).
number
conj(): Complex;Returns the conjugate.
div(x): Complex;Returns this / x;
divBy(x): void;Mutates this MutableComplex by dividing by a Complex.
void
divByReal(x): void;Mutates this MutableComplex by dividing by a real number.
number
void
divReal(x): Complex;Returns this / x;
number
equals(x): boolean;Returns true if this complex number is exactly equal to another.
boolean
exp(): Complex;Returns the exponential function. (The Euler's number e raised to the power of this complex number).
fuzzyEquals(x, eps): boolean;Returns true if the real and imaginary parts of the two numbers
do not differ more than eps.
number
boolean
isFinite(): boolean;Returns true if the real and imaginary parts are both finite.
boolean
isInfinite(): boolean;Returns true if the real or the imaginary part is infinite (positive or negative).
boolean
isNaN(): boolean;Returns true if the real part or the imaginary part is NaN.
boolean
log(): Complex;Returns the natural logarithm (base e).
mul(x): Complex;Returns this * x;
mulBy(x): void;Mutates this MutableComplex by multiplying a Complex.
void
mulByReal(x): void;Mutates this MutableComplex by multiplying a real number.
number
void
mulReal(x): Complex;Returns this * x;
number
neg(): Complex;Returns the negation (-this).
pow(x): Complex;Returns this raised to the power of x.
powInt(x): Complex;Returns this raised to the power of x.
number
powReal(x): Complex;Returns this raised to the power of x.
number
reciprocal(): Complex;Returns the reciprocal (1 / this, multiplicative inverse).
set(x): void;Sets this MutableComplex to the value of another Complex.
void
setDiv(
re1,
im1,
re2,
im2): void;Sets this MutableComplex to (re1, im1) / (re2, im2).
number
number
number
number
void
setExpj(arg): void;Sets this MutableComplex to e^(j * arg) (length 1 and argument arg).
number
void
setMul(
re1,
im1,
re2,
im2): void;Sets this MutableComplex to (re1, im1) * (re2, im2).
number
number
number
number
void
setPolar(abs, arg): void;Sets this MutableComplex using polar coordinates.
number
number
void
setReIm(re, im?): void;Sets this MutableComplex to (re, im).
number
number = 0
void
sqr(): Complex;Returns the square.
sqrt(): Complex;Returns one of the two square roots.
sub(x): Complex;Returns this - x;
subFrom(x): void;Mutates this MutableComplex by subtracting a Complex.
void
subReal(x): Complex;Returns this - x;
number
subRealFrom(x): void;Mutates this MutableComplex by substracting a real number.
number
void
toNumber(eps): number;Returns the real part.
Verifies that abs(im) <= eps or abs(im) <= abs(re) * eps.
number
number
toString(): string;Returns a string representing the complex number.
string
static divFromReal(x, y): Complex;Returns x / y;
number
static expj(arg): MutableComplex;Creates a MutableComplex of length 1 and argument arg.
number
MutableComplex
static fromComplex(x): MutableComplex;Creates a MutableComplex from a Complex.
MutableComplex
static fromPolar(abs, arg): MutableComplex;Creates a MutableComplex from polar coordinates.
number
number
MutableComplex
static subFromReal(x, y): Complex;Returns x - y;
number