public final class Complex extends Object
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 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.
|
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() |
public static final Complex I
public static final Complex ZERO
public static final Complex ONE
public static final Complex TWO
public static final Complex NaN
public static final Complex INF
public Complex(double re, double im)
re
- The real part.im
- The imaginary part.public Complex(double re)
re
- The real part.public double re()
public double im()
public double toDouble(double eps)
abs(im) <= eps
or abs(im) <= eps * abs(re)
.public boolean isNaN()
true
if the real or imaginary part in not a number.public boolean isInfinite()
true
if the real or imaginary part is infinite.public static Complex expj(double arg)
arg
.public static Complex fromPolar(double abs, double arg)
public double abs()
public double arg()
public Complex conj()
public Complex neg()
-this
).public Complex reciprocal()
1 / this
, multiplicative inverse).public Complex exp()
public Complex log()
public Complex sqr()
public Complex sqrt()
public Complex add(double x)
this + x
;public Complex sub(double x)
this - x
;public Complex mul(double x)
this * x
;public Complex div(double x)
this / x
;public Complex pow(int x)
x
.public Complex pow(double x)
x
.public boolean equals(Complex x, double eps)
true
if the real and imaginary parts of the two numbers
do not differ more than eps
.