|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object qcnn.Complex
class Complex
Allows manipulation of complex numbers. Implementation is such that a complex number is immutable; arithmetic operations may therefore be combined using any combination of composed or cascaded method invocations.
Field Summary | |
---|---|
static boolean |
DEBUG_WARNINGS
Set to true to enable warnings |
static Complex |
I
|
protected double |
im
|
static Complex |
ONE
|
protected double |
re
|
static Complex |
ZERO
|
Constructor Summary | |
---|---|
Complex(double d)
Creates a new complex number with no imaginary component |
|
Complex(double re,
double im)
Creates a new complex number |
Method Summary | |
---|---|
Complex |
add(Complex c)
|
Complex |
add(double d)
|
double |
argument()
If the modulus of the number is zero, then the argument returned will be zero. |
Complex |
conjugate()
|
Complex |
divide(Complex c)
|
Complex |
divide(double d)
|
static Complex |
e(Complex c)
Returns the exponent of a complex number |
boolean |
equals(java.lang.Object o)
|
double |
modulus()
|
double |
modulusSquared()
|
Complex |
multiply(Complex c)
|
Complex |
multiply(double d)
|
Complex |
negate()
|
static Complex |
polar(double r,
double theta)
Constructs a complex number from modulus and argument components |
double |
pow()
|
Complex |
reciprocal()
|
Complex |
sqrt()
|
Complex |
subtract(Complex c)
|
Complex |
subtract(double d)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected double re
protected double im
public static boolean DEBUG_WARNINGS
true
to enable warnings
public static final Complex ONE
public static final Complex ZERO
public static final Complex I
Constructor Detail |
---|
public Complex(double re, double im)
re
- The real part of this numberim
- The imaginary part of this numberpublic Complex(double d)
re
- The real part of this numberMethod Detail |
---|
public Complex add(double d)
public Complex add(Complex c)
public Complex subtract(double d)
public Complex subtract(Complex c)
public Complex multiply(double d)
public Complex multiply(Complex c)
public Complex divide(double d)
public Complex divide(Complex c)
public double modulus()
public double argument()
public Complex negate()
public Complex conjugate()
public Complex reciprocal()
public Complex sqrt()
public double pow()
public double modulusSquared()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- The complex number to compare to this one
true
if the specified complex number is equal to
this one, else false
java.lang.NullPointerException
- If o
is null
java.lang.ClassCastException
- If o
is not a complex
numberpublic java.lang.String toString()
toString
in class java.lang.Object
a+bi
, where a
and b
are real numberspublic static Complex polar(double r, double theta)
r
- The modulustheta
- The argument
public static Complex e(Complex c)
c
- The number to be exponentiated
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |