|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.hedgehog.HObject
com.hedgehog.math.Complex
public class Complex
Title: Complex - represents a complex number.
Description: Represents a complex number consisting of real and imaginary parts, c(re,im).
Copyright: Copyright (c) Hedgehog Software 2007-2009.
Company: Hedgehog Software.
| Field Summary | |
|---|---|
protected double |
mImag
Imaginary parts of a complex number. |
protected double |
mReal
Real part of a complex number. |
static Complex |
NaN
A complex number representing (NaN + NaNi). |
static Complex |
ONE
A complex number representing (1.0 + 0.0i). |
static Complex |
ZERO
A complex number representing (0.0 + 0.0i). |
| Fields inherited from class com.hedgehog.HObject |
|---|
mID, mName |
| Constructor Summary | |
|---|---|
Complex()
Default constructor. |
|
Complex(Complex object)
Copy constructor. |
|
Complex(double real)
Constructor. |
|
Complex(java.lang.Double real)
Sets the real part to the specified value and the imaginary part to 0.0. |
|
Complex(double real,
double imag)
Constructor. |
|
Complex(java.lang.Double real,
java.lang.Double imag)
Constructor. |
|
Complex(HDouble real)
Constructor. |
|
Complex(HDouble real,
HDouble imag)
Constructor. |
|
| Method Summary | |
|---|---|
double |
abs()
Returns the absolute positive value of a complex number. |
Complex |
add(Complex c)
Adds the specified number to this number and returns the resultant. |
static Complex |
add(Complex c1,
Complex c2)
Addition (Complex,Complex) |
static void |
add(Complex c1,
Complex c2,
Complex c1c2)
Optimised complex-complex addition. |
static Complex |
add(Complex c1,
double c2)
Addition (Complex,double) |
Complex |
add(double c)
Adds the specified number to this number and returns the resultant. |
static Complex |
add(double c1,
Complex c2)
Addition (Complex,double) |
void |
addTo(Complex c)
Arithmetic addtion. |
void |
addTo(double c)
Arithmetic addtion. |
Complex |
arcCos()
Returns the arc cosine of a complex number. |
Complex |
arcCosh()
Returns the inverse cosh. |
Complex |
arcCot(double tolerance)
Returns the arc cotangent of a Complex object. |
Complex |
arcSin()
Returns the arc sine of a complex number. |
Complex |
arcSinh()
Returns the inverse sinh. |
Complex |
arcTan(double tolerance)
Returns the arc tangent of a Complex object. |
Complex |
arcTanh()
Returns the inverse tanh. |
double |
argument()
Returns the complex argument. |
Complex |
conjugate()
Returns the complex conjugate. |
static Complex |
cos(Complex c)
Returns the cosine of the specified complex number and implements the formula: |
static Complex |
cosh(Complex c)
Returns the hyperbolic cosine of the specified complex number and implements the formula: |
static Complex |
cot(Complex c)
Returns the cotangent of the specified complex number; ie cot(z) = 1/tan(z). |
Complex |
cubeRoot()
Returns the complex cube root. |
Complex[] |
cubeRoots()
Returns the 3 roots of this complex number. |
static Complex |
divide(Complex c1,
Complex c2,
double tolerance)
Division of two complex numbers. |
static void |
divide(Complex c1,
Complex c2,
double tolerance,
Complex c1c2)
Divisions (Complex,Complex) with the resultant returned via the argument object. |
Complex |
divide(Complex c,
double tolerance)
Divides this number by the specified number and returns the resultant. |
static Complex |
divide(Complex c1,
double c2,
double tolerance)
Division of a complex number by a scalar. |
static Complex |
divide(double c1,
Complex c2,
double tolerance)
Division of a scalar by a complex number. |
Complex |
divide(double c,
double tolerance)
Divides this number by the specified number and returns the resultant. |
void |
divideBy(Complex c,
double tolerance)
Arithmetic division. |
void |
divideBy(double c,
double tolerance)
Arithmetic division. |
boolean |
equals(java.lang.Object object)
Compares the specifieed object against this object. |
Complex |
exp()
Returns the exponential of a complex number. |
double |
getImag()
Returns the imaginary part of a complex number. |
double |
getReal()
Returns the real part of a complex number. |
int |
hashCode()
Returns a hash code for this complex number. |
Complex |
I()
Returns the complex number, i. |
boolean |
isFullyImaginary(double tolerance)
Tests whether or not a Complex object is fully imaginary; ie no real component relative to the specified tolerance. |
boolean |
isFullyReal(double tolerance)
Tests whether or not a Complex object is fully real; ie no imaginary component relative to the specified tolerance. |
boolean |
isInfinite()
Tests whether or not either the real or imaginary part of this complex number takes an infinite value (either Double.POSITIVE_INFINITY or
Double.NEGATIVE_INFINITY) and neither part is NaN. |
boolean |
isNaN()
Tests whether or not both real and imaginary parts of this complex number are NaN. |
boolean |
isSameImag(Complex c,
double tolerance)
Tests whether or not the specified complex object has the same imaginary value as this object. |
boolean |
isSameReal(Complex c,
double tolerance)
Tests whether or not the specified complex object has the same real value as this object. |
boolean |
isSameRealImag(Complex c,
double tolerance)
Tests whether or not the specified complex object has the same real and imaginary values as this object. |
boolean |
isZero(double tolerance)
Tests whether or not both the real and imaginary parts of this complex number are zero. |
Complex |
log()
Returns the logarithm of a complex number. |
Complex |
multiply(Complex c)
Multiples this number multiplied by the specified complex number. |
static Complex |
multiply(Complex c1,
Complex c2)
Multiplication (Complex,Complex) |
static void |
multiply(Complex c1,
Complex c2,
Complex c1c2)
Multiplication (Complex,Complex) with the resultant returned via the argument object. |
static Complex |
multiply(Complex c1,
double c2)
Multiplication (Complex,double) |
Complex |
multiply(double c)
Multiples this number multiplied by the specified real number. |
static Complex |
multiply(double c1,
Complex c2)
Multiplication (double,Complex) |
void |
multiplyBy(Complex c)
Arithmetic multiplication. |
void |
multiplyBy(double c)
Arithmetic multiplication. |
Complex |
negate()
Negates a complex number. |
Complex |
negateImag()
Negates the imaginary part of a complex number. |
Complex |
negateReal()
Negates the real part of a complex number. |
static Complex |
polar2Complex(double r,
double theta)
Returns the complex number from the given polar representation. |
Complex |
pow(double n)
Complex number to a floating-point power n. |
java.util.Vector |
rationalPow(int n)
Returns the rational power of a complex number. |
Complex |
reciprocal(double tolerance)
Returns the reciprocal of a complex number. |
Complex |
rTheta()
Returns the (r,theta) corresponding to (x,y). |
void |
set(Complex c)
Sets this complex number to the specified object. |
void |
setImag(double newImag)
Sets the imaginary part of a complex number. |
void |
setReal(double newReal)
Sets the real part of a complex number. |
void |
setRealImag(double newReal,
double newImag)
Sets the real and imaginary parts of a complex number. |
static Complex |
sin(Complex c)
Returns the sine of the specified complex number and implements the formula: |
static Complex |
sinh(Complex c)
Returns the hyperbolic sine of the specified complex number and implements the formula: |
Complex |
sqrt()
Returns the complex square root. |
Complex |
subtract(Complex c)
Sbtracts the specified number from this number and returns the resultant. |
static Complex |
subtract(Complex c1,
Complex c2)
Subtraction (Complex,Complex) |
static void |
subtract(Complex c1,
Complex c2,
Complex c1c2)
Optimised complex-complex subtraction. |
static Complex |
subtract(Complex c1,
double c2)
Subtraction (Complex,double) |
Complex |
subtract(double c)
Sbtracts the specified number from this number and returns the resultant. |
static Complex |
subtract(double c1,
Complex c2)
Subtraction (double,Complex) |
void |
subtractFrom(Complex c)
Arithmetic subtraction. |
void |
subtractFrom(double c)
Arithmetic subtraction. |
static Complex |
tan(Complex c)
Returns the tangent of the specified complex number and implements the formula: |
static Complex |
tanh(Complex c)
Returns the hyperbolic tangent of the specified complex number and implements the formula: |
java.lang.String |
toString()
Returns a String representation of a Complex object. |
| Methods inherited from class com.hedgehog.HObject |
|---|
clone, compare, compareTo, copy, getID, getName, hasID, hasName, setID, setName |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected double mReal
protected double mImag
public static final Complex NaN
public static final Complex ONE
public static final Complex ZERO
| Constructor Detail |
|---|
public Complex()
public Complex(double real)
real - Real value.
public Complex(double real,
double imag)
real - The real part.imag - The imaginary part.
public Complex(java.lang.Double real,
java.lang.Double imag)
real - The real part.imag - The imaginary part.public Complex(java.lang.Double real)
real - Real value.
public Complex(HDouble real,
HDouble imag)
real - The real part.imag - The imaginary part.public Complex(HDouble real)
real - Real value.public Complex(Complex object)
object - Complex number to copy.| Method Detail |
|---|
public double abs()
public void addTo(Complex c)
c - Complex number to add.public void addTo(double c)
c - Real number to add.public Complex add(Complex c)
c - Complex number to add this number.
public Complex add(double c)
c - Real number to add this number.
public Complex arcCos()
public Complex arcSin()
public Complex arcTan(double tolerance)
throws DivisionByZeroException
tolerance - Value below which a number is assumed to be effectively equal to zero. Used for preventing division by zero and typically set to 1e-06.
DivisionByZeroException - Thrown to prevent a division by zero.
public Complex arcCot(double tolerance)
throws DivisionByZeroException
For further details refer to MathWorld.
tolerance - Value below which a number is assumed to be effectively equal to zero. Used for preventing division by zero and typically set to 1e-06.
DivisionByZeroException - Thrown to prevent a division by zero.public Complex arcCosh()
public Complex arcSinh()
public Complex arcTanh()
public double argument()
public Complex conjugate()
public void divideBy(Complex c,
double tolerance)
throws DivisionByZeroException
c - Complex number to divide this number by.tolerance - Tolerance below which a number is assumed to be effectively equal to zero. Typically
set to 1e-06.
DivisionByZeroException - If a potential division by zero could occur.
public void divideBy(double c,
double tolerance)
throws DivisionByZeroException
c - Real number to divide this number by.tolerance - Tolerance below which a number is assumed to be effectively equal to zero. Typically set to 1e-06.
DivisionByZeroException - If a potential division by zero could occur.
public Complex divide(Complex c,
double tolerance)
throws DivisionByZeroException
c - Complex number to divide this number by.tolerance - Required tolerance.
DivisionByZeroException - Thrown if a division by zero would occur.
public Complex divide(double c,
double tolerance)
throws DivisionByZeroException
c - Real number to divide this number by.tolerance - Required tolerance.
DivisionByZeroException - Thrown if a division by zero would occur.public boolean equals(java.lang.Object object)
If both the real and imaginary parts are equivalent, and neither is Double.NaN, the two
objects are considered to be equal.
All NaN values are considered to be equal; ie if either
(or both) real and imaginary parts of the complex number are equal
to Double.NaN then the complex number is equal to Complex.NaN.
equals in interface java.util.Comparatorequals in class HObjectobject - Object to compare.
public int hashCode()
hashCode in class HObjectpublic boolean isNaN()
public boolean isInfinite()
Double.POSITIVE_INFINITY or
Double.NEGATIVE_INFINITY) and neither part is NaN.
NaN.public Complex exp()
public Complex I()
public boolean isFullyReal(double tolerance)
tolerance - Tolerance to compare imaginary part of Complex object. If
imagpublic boolean isFullyImaginary(double tolerance)
tolerance - Tolerance to compare real part of Complex object. If
realpublic boolean isZero(double tolerance)
tolerance - Required tolerance.
public boolean isSameReal(Complex c,
double tolerance)
c - Other obejct.tolerance - Required tolerance.
public boolean isSameImag(Complex c,
double tolerance)
c - Other obejct.tolerance - Required tolerance.
public boolean isSameRealImag(Complex c,
double tolerance)
c - Other obejct.tolerance - Required tolerance.
public double getImag()
public void setImag(double newImag)
newImag - New imaginary part of a complex number.public Complex log()
public Complex negate()
public Complex negateReal()
public Complex negateImag()
public Complex pow(double n)
n - power.
public Complex reciprocal(double tolerance)
throws DivisionByZeroException
tolerance - Tolerance below which a number is assumed to be equal to zero. typically
set to 1e-06.
DivisionByZeroException - Thrown to prevent a potential division by zero.public Complex rTheta()
public java.util.Vector rationalPow(int n)
n - Power n.
public double getReal()
public void setReal(double newReal)
newReal - New real part.
public void setRealImag(double newReal,
double newImag)
newReal - New real part.newImag - New imaginary part.public void set(Complex c)
c - Complex object.public Complex sqrt()
public Complex cubeRoot()
public Complex[] cubeRoots()
public void multiplyBy(Complex c)
c - Complex number to multiply.public void multiplyBy(double c)
c - Real number to multiply.public Complex multiply(Complex c)
c - Complex number to multiply this complex number by.
public Complex multiply(double c)
c - Real number to multiply this complex number by.
public void subtractFrom(Complex c)
c - Complex number to subtract.public void subtractFrom(double c)
c - Real number to subtract.public Complex subtract(Complex c)
c - Complex number to subtract from this number.
public Complex subtract(double c)
c - Real number to subtract from this number.
public java.lang.String toString()
toString in class java.lang.Object
public static Complex add(Complex c1,
Complex c2)
c1 - One complex number.c2 - Second complex number.
public static Complex add(Complex c1,
double c2)
c1 - One complex number.c2 - Second double number.
public static Complex add(double c1,
Complex c2)
c1 - Scalar number.c2 - Complex number.
public static void add(Complex c1,
Complex c2,
Complex c1c2)
c1 - One complex number.c2 - Second complex number.c1c2 - Set upon return to the resultant.
public static Complex divide(Complex c1,
Complex c2,
double tolerance)
throws DivisionByZeroException
c1 - One complex number.c2 - Second complex number.tolerance - Tolerance below which a number is assumed to be effectively equal to zero. Typically set to 1e-06.
DivisionByZeroException - If a potential division by zero could occur.
public static Complex divide(double c1,
Complex c2,
double tolerance)
throws DivisionByZeroException
c1 - Scalar .c2 - Complex number.tolerance - Tolerance below which a number is assumed to be effectively equal to zero. Typically set to 1e-06.
DivisionByZeroException - If a potential division by zero could occur.
public static Complex divide(Complex c1,
double c2,
double tolerance)
throws DivisionByZeroException
c1 - Complex number.c2 - Scalar.tolerance - Tolerance below which a number is assumed to be effectively equal to zero. Typically set to 1e-06.
DivisionByZeroException - If a potential division by zero could occur.
public static void divide(Complex c1,
Complex c2,
double tolerance,
Complex c1c2)
throws DivisionByZeroException
c1 - One complex number.c2 - Second complex number.tolerance - Required tolerance.c1c2 - Set upon return to the resultant.
DivisionByZeroException - If a potential division by zero could occur.
public static Complex multiply(Complex c1,
Complex c2)
c1 - One complex number.c2 - Second complex number.
public static Complex multiply(Complex c1,
double c2)
c1 - One complex number.c2 - Second double number.
public static Complex multiply(double c1,
Complex c2)
c1 - One double number.c2 - Second complex number.
public static void multiply(Complex c1,
Complex c2,
Complex c1c2)
c1 - One complex number.c2 - Second complex number.c1c2 - Set upon return to the resultant.
public static Complex subtract(Complex c1,
Complex c2)
c1 - One complex number.c2 - Second complex number.
public static Complex subtract(Complex c1,
double c2)
c1 - One complex number.c2 - Second double number.
public static Complex subtract(double c1,
Complex c2)
c1 - One double number.c2 - Second complex number.
public static void subtract(Complex c1,
Complex c2,
Complex c1c2)
c1 - One complex number.c2 - Second complex number.c1c2 - Set upon return to the resultant.public static Complex cos(Complex c)
cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i
c - Complex number.
NaN if either the real or imaginary part of the
input argument is NaN.public static Complex sin(Complex c)
sin(a + bi) = sin(a)cosh(b) - cos(a)sinh(b)i
c - Complex number.
NaN if either the real or imaginary part of the
input argument is NaN.public static Complex tan(Complex c)
tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i
c - Complex number.
NaN if either the real or imaginary part of the
input argument is NaN.
public static Complex cot(Complex c)
throws DivisionByZeroException
c - Complex number.
DivisionByZeroException - Thrown to prevent potential division by zero.public static Complex cosh(Complex c)
cosh(a + bi) = cosh(a)cos(b) + sinh(a)sin(b)i
c - Complex number.
NaN if either the real or imaginary part of the
input argument is NaN.public static Complex sinh(Complex c)
sinh(a + bi) = sinh(a)cos(b)) + cosh(a)sin(b)i
c - Complex number.
NaN if either the real or imaginary part of the
input argument is NaN.public static Complex tanh(Complex c)
tanh(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i
c - Complex number.
NaN if either the real or imaginary part of the
input argument is NaN.
public static Complex polar2Complex(double r,
double theta)
The value returned is r·ei·theta,
computed as r·cos(theta) + r·sin(theta)i
If either r or theta is NaN, or
theta is infinite, NaN is returned.
r - Radius.theta - Angle.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||