biz.source_code.dsp.math

## Class Complex

• ```public final class Complex
extends Object```
Complex number.
• ### Field Summary

Fields
Modifier and Type Field and Description
`static Complex` `I`
The imaginary unit i.
`static Complex` `INF`
A Complex representing "+INF + INF i"
`static Complex` `NaN`
A Complex representing "NaN + NaN i".
`static Complex` `ONE`
A Complex representing 1.
`static Complex` `TWO`
A Complex representing 2.
`static Complex` `ZERO`
A Complex representing 0.
• ### Constructor Summary

Constructors
Constructor and Description
`Complex(double re)`
Constructs a Complex with a real part and 0 as the imaginary part.
```Complex(double re, double im)```
Constructs a Complex.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`double` `abs()`
Returns the absolute value (magnitude, vector length, radius).
`Complex` `add(Complex x)`
Returns `this + x`;
`Complex` `add(double x)`
Returns `this + x`;
`double` `arg()`
Returns the argument (angle).
`Complex` `conj()`
Returns the conjugate.
`Complex` `div(Complex x)`
Returns `this / x`;
`Complex` `div(double x)`
Returns `this / x`;
`static Complex` ```div(double x, Complex y)```
Returns `x / y`;
`boolean` ```equals(Complex x, double eps)```
Returns `true` if the real and imaginary parts of the two numbers do not differ more than `eps`.
`boolean` `equals(Object obj)`
`Complex` `exp()`
Returns the exponential function.
`static Complex` `expj(double arg)`
Creates a Complex of length 1 and argument `arg`.
`static Complex` ```fromPolar(double abs, double arg)```
Creates a Complex from polar coordinates.
`int` `hashCode()`
`double` `im()`
Returns the imaginary part.
`boolean` `isInfinite()`
Returns `true` if the real or imaginary part is infinite.
`boolean` `isNaN()`
Returns `true` if the real or imaginary part in not a number.
`Complex` `log()`
Returns the natural logarithm (base e).
`Complex` `mul(Complex x)`
Returns `this * x`;
`Complex` `mul(double x)`
Returns `this * x`;
`Complex` `neg()`
Returns the negation (`-this`).
`Complex` `pow(Complex x)`
Returns this raised to the power of `x`.
`Complex` `pow(double x)`
Returns this raised to the power of `x`.
`Complex` `pow(int x)`
Returns this raised to the power of `x`.
`double` `re()`
Returns the real part.
`Complex` `reciprocal()`
Returns the reciprocal (`1 / this`, multiplicative inverse).
`Complex` `sqr()`
Returns the square.
`Complex` `sqrt()`
Returns one of the two square roots.
`Complex` `sub(Complex x)`
Returns `this - x`;
`Complex` `sub(double x)`
Returns `this - x`;
`static Complex` ```sub(double x, Complex y)```
Returns `x - y`;
`double` `toDouble(double eps)`
Returns the real part.
`String` `toString()`
• ### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### I

`public static final Complex I`
The imaginary unit i.
• #### ZERO

`public static final Complex ZERO`
A Complex representing 0.
• #### ONE

`public static final Complex ONE`
A Complex representing 1.
• #### TWO

`public static final Complex TWO`
A Complex representing 2.
• #### NaN

`public static final Complex NaN`
A Complex representing "NaN + NaN i".
• #### INF

`public static final Complex INF`
A Complex representing "+INF + INF i"
• ### Constructor Detail

• #### Complex

```public Complex(double re,
double im)```
Constructs a Complex.
Parameters:
`re` - The real part.
`im` - The imaginary part.
• #### Complex

`public Complex(double re)`
Constructs a Complex with a real part and 0 as the imaginary part.
Parameters:
`re` - The real part.
• ### Method Detail

• #### re

`public double re()`
Returns the real part.
• #### im

`public double im()`
Returns the imaginary part.
• #### toDouble

`public double toDouble(double eps)`
Returns the real part. Verifies that `abs(im) <= eps` or `abs(im) <= eps * abs(re)`.
• #### isNaN

`public boolean isNaN()`
Returns `true` if the real or imaginary part in not a number.
• #### isInfinite

`public boolean isInfinite()`
Returns `true` if the real or imaginary part is infinite.
• #### expj

`public static Complex expj(double arg)`
Creates a Complex of length 1 and argument `arg`.
• #### fromPolar

```public static Complex fromPolar(double abs,
double arg)```
Creates a Complex from polar coordinates.
• #### abs

`public double abs()`
Returns the absolute value (magnitude, vector length, radius).
• #### arg

`public double arg()`
Returns the argument (angle).
• #### conj

`public Complex conj()`
Returns the conjugate.
• #### neg

`public Complex neg()`
Returns the negation (`-this`).
• #### reciprocal

`public Complex reciprocal()`
Returns the reciprocal (`1 / this`, multiplicative inverse).
• #### exp

`public Complex exp()`
Returns the exponential function. (The Euler's number e raised to the power of this complex number).
• #### log

`public Complex log()`
Returns the natural logarithm (base e).
• #### sqr

`public Complex sqr()`
Returns the square.
• #### sqrt

`public Complex sqrt()`
Returns one of the two square roots.

`public Complex add(double x)`
Returns `this + x`;

`public Complex add(Complex x)`
Returns `this + x`;
• #### sub

`public Complex sub(double x)`
Returns `this - x`;
• #### sub

`public Complex sub(Complex x)`
Returns `this - x`;
• #### sub

```public static Complex sub(double x,
Complex y)```
Returns `x - y`;
• #### mul

`public Complex mul(double x)`
Returns `this * x`;
• #### mul

`public Complex mul(Complex x)`
Returns `this * x`;
• #### div

`public Complex div(double x)`
Returns `this / x`;
• #### div

`public Complex div(Complex x)`
Returns `this / x`;
• #### div

```public static Complex div(double x,
Complex y)```
Returns `x / y`;
• #### pow

`public Complex pow(int x)`
Returns this raised to the power of `x`.
• #### pow

`public Complex pow(double x)`
Returns this raised to the power of `x`.
• #### pow

`public Complex pow(Complex x)`
Returns this raised to the power of `x`.
• #### equals

```public boolean equals(Complex x,
double eps)```
Returns `true` if the real and imaginary parts of the two numbers do not differ more than `eps`.
• #### equals

`public boolean equals(Object obj)`
Overrides:
`equals` in class `Object`
• #### hashCode

`public int hashCode()`
Overrides:
`hashCode` in class `Object`
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`