public class Complex extends Object implements Cloneable, Serializable
Constructor and Description |
---|
Complex(double real,
double imag)
Creates a new Complex number
|
Modifier and Type | Method and Description |
---|---|
Complex |
add(Complex c)
Creates a new complex number containing the resulting addition of this and another
|
static void |
cDiv(double a,
double b,
double c,
double d,
double[] results)
Performs a complex division operation.
|
protected Complex |
clone() |
static void |
cMul(double a,
double b,
double c,
double d,
double[] results)
Performs a complex multiplication
|
Complex |
divide(Complex c)
Creates a new complex number containing the resulting division of this by
another
|
boolean |
equals(Object obj) |
boolean |
equals(Object obj,
double eps)
Checks if this is approximately equal to another Complex object
|
double |
getArg()
Computes the Argument, also called phase, of this complex number.
|
Complex |
getConjugate()
Returns a new complex number representing the complex conjugate of this
one
|
double |
getImag()
Returns the imaginary part of this complex number
|
double |
getMagnitude()
|
double |
getReal()
Returns the real part of this complex number
|
int |
hashCode() |
static Complex |
I()
Returns the complex number representing sqrt(-1)
|
Complex |
multiply(Complex c)
Creates a new complex number containing the resulting multiplication between this and another
|
void |
mutableAdd(Complex c)
Alters this complex number to contain the result of the addition of another
|
void |
mutableAdd(double r,
double i)
Alters this complex number as if an addition of another complex number was performed.
|
void |
mutableDivide(Complex c)
Alters this complex number to contain the result of the division by another
|
void |
mutableDivide(double c,
double d)
Alters this complex number as if a division by another complex number was performed.
|
void |
mutableMultiply(Complex c)
Alters this complex number to contain the result of the multiplication of another
|
void |
mutableMultiply(double c,
double d)
Alters this complex number as if a multiplication of another complex number was performed.
|
void |
mutableSubtract(Complex c)
Alters this complex number to contain the result of the subtraction of another
|
void |
mutableSubtract(double r,
double i)
Alters this complex number as if a subtraction of another complex number was performed.
|
void |
mutateConjugate()
Alters this complex number so that it represents its complex conjugate
instead.
|
void |
setImag(double imag)
Sets the imaginary value part of this complex number
|
void |
setReal(double r)
Sets the real value part of this complex number
|
Complex |
subtract(Complex c)
Creates a new complex number containing the resulting subtracting another from this one
|
String |
toString() |
public Complex(double real, double imag)
real
- the real part of the numberimag
- the imaginary part of the numberpublic static Complex I()
public double getReal()
public void setReal(double r)
r
- the new real valuepublic void setImag(double imag)
imag
- the new imaginary valuepublic double getImag()
public void mutableAdd(double r, double i)
r
- the real part of the other numberi
- the imaginary part of the other numberpublic void mutableAdd(Complex c)
c
- the complex value to add to thispublic Complex add(Complex c)
c
- the number to addpublic void mutableSubtract(double r, double i)
r
- the real part of the other numberi
- the imaginary part of the other numberpublic void mutableSubtract(Complex c)
c
- the number to subtractpublic Complex subtract(Complex c)
c
- the number to subtractpublic static void cMul(double a, double b, double c, double d, double[] results)
a
- the real part of the first numberb
- the imaginary part of the first numberc
- the real part of the second numberd
- the imaginary part of the second numberresults
- an array to store the real and imaginary results in. First index is the real, 2nd is the imaginary.public void mutableMultiply(double c, double d)
c
- the real part of the other numberd
- the imaginary part of the other numberpublic void mutableMultiply(Complex c)
c
- the number to multiply bypublic Complex multiply(Complex c)
c
- the number to multiply bypublic static void cDiv(double a, double b, double c, double d, double[] results)
a
- the real part of the first numberb
- the imaginary part of the first numberc
- the real part of the second numberd
- the imaginary part of the second numberresults
- an array to store the real and imaginary results in. First
index is the real, 2nd is the imaginary.public void mutableDivide(double c, double d)
c
- the real part of the other numberd
- the imaginary part of the other numberpublic void mutableDivide(Complex c)
c
- the number to divide bypublic Complex divide(Complex c)
c
- the number to divide bypublic double getMagnitude()
public double getArg()
Double.NaN
, which occurs only for complex zero, the
result will be in the range [-pi, pi]public void mutateConjugate()
public Complex getConjugate()
public boolean equals(Object obj, double eps)
obj
- the object to compare againsteps
- the maximum acceptable difference between values to be
considered equalCopyright © 2017. All rights reserved.