|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.northwestern.at.utils.math.Complex
public class Complex
This class implements complex numbers. It provides the basic operations
(addition, subtraction, multiplication, division) as well as a set of
complex functions.
The binary operations have the form, where op is plus
,
minus
, times
or over
.
public static Complex op(Complex x, Complex y) // x op y public static Complex op(Complex x, double y) // x op y public static Complex op(double x, Complex y) // x op y public Complex op(Complex y) // this op y public Complex op(double y) // this op y public Complex opReverse(double x) // x op thisThe functions in this class follow the rules for complex arithmetic as defined C9x Annex G:"IEC 559-compatible complex arithmetic." The API is not the same, but handling of infinities, NaNs, and positive and negative zeros is intended to follow the same rules. This class depends on the standard java.lang.Math class following certain rules, as defined in the C9x Annex F, for the handling of infinities, NaNs, and positive and negative zeros. Sun's specification is that java.lang.Math should reproduce the results in the Sun's fdlibm C library. This library appears to follow the Annex F specification. At least on Windows, Sun's JDK 1.0 and 1.1 do NOT follow this specification. Sun's JDK 1.2(RC2) does follow the Annex F specification. Thesefore, this class will not give the expected results for edge cases with JDK 1.0 and 1.1.
Field Summary | |
---|---|
(package private) static long |
serialVersionUID
Serialization ID |
static java.lang.String |
suffix
String used in converting Complex to String. |
Constructor Summary | |
---|---|
Complex()
Constructs a Complex equal to zero. |
|
Complex(Complex z)
Constructs a Complex equal to the argument. |
|
Complex(double re)
Constructs a Complex with a zero imaginary part. |
|
Complex(double re,
double im)
Constructs a Complex with real and imaginary parts given by the input arguments. |
Method Summary | |
---|---|
static double |
abs(Complex z)
Returns the absolute value (modulus) of a Complex, |z|. |
static Complex |
acos(Complex z)
Returns the inverse cosine (arc cosine) of a Complex, with branch cuts outside the interval [-1,1] along the real axis. |
static Complex |
acosh(Complex z)
Returns the inverse hyperbolic cosine (arc cosh) of a Complex, with a branch cut at values less than one along the real axis. |
static double |
argument(Complex z)
Returns the argument (phase) of a Complex, in radians, with a branch cut along the negative real axis. |
static Complex |
asin(Complex z)
Returns the inverse sine (arc sine) of a Complex, with branch cuts outside the interval [-1,1] along the real axis. |
static Complex |
asinh(Complex z)
Returns the inverse hyperbolic sine (arc sinh) of a Complex, with a branch cuts outside the interval [-i,i]. |
static Complex |
atan(Complex z)
Returns the inverse tangent (arc tangent) of a Complex, with branch cuts outside the interval [-i,i] along the imaginary axis. |
static Complex |
atanh(Complex z)
Returns the inverse hyperbolic tangent (arc tanh) of a Complex, with a branch cuts outside the interval [-1,1] on the real axis. |
static Complex |
conjugate(Complex z)
Returns the complex conjugate of a Complex object. |
static Complex |
cos(Complex z)
Returns the cosine of a Complex. |
static Complex |
cosh(Complex z)
Returns the hyperbolic cosh of a Complex. |
boolean |
equals(Complex z)
Compares with another Complex. |
boolean |
equals(java.lang.Object obj)
Compares this object against the specified object. |
static Complex |
exp(Complex z)
Returns the exponential of a Complex z, exp(z). |
int |
hashCode()
Returns a hashcode for this Complex. |
double |
imag()
Returns the imaginary part of a Complex object. |
static double |
imag(Complex z)
Returns the imaginary part of a Complex object. |
static Complex |
log(Complex z)
Returns the logarithm of a Complex z, with a branch cut along the negative real axis. |
Complex |
minus(Complex y)
Returns the difference of this Complex object and another Complex object, this-y. |
static Complex |
minus(Complex x,
Complex y)
Returns the difference of two Complex objects, x-y. |
static Complex |
minus(Complex x,
double y)
Returns the difference of a Complex object and a double, x-y. |
Complex |
minus(double y)
Subtracts a double from this Complex and returns the difference, this-y. |
static Complex |
minus(double x,
Complex y)
Returns the difference of a double and a Complex object, x-y. |
Complex |
minusReverse(double x)
Returns the difference of this Complex object and a double, this-y. |
static Complex |
negative(Complex z)
Returns the negative of a Complex object, -z. |
Complex |
over(Complex y)
Returns this Complex object divided by another Complex object, this/y. |
static Complex |
over(Complex x,
Complex y)
Returns Complex object divided by a Complex object, x/y. |
static Complex |
over(Complex x,
double y)
Returns Complex object divided by a double, x/y. |
Complex |
over(double y)
Returns this Complex object divided by double, this/y. |
static Complex |
over(double x,
Complex y)
Returns a double divided by a Complex object, x/y. |
Complex |
overReverse(double x)
Returns a double dividied by this Complex object, x/this. |
Complex |
plus(Complex y)
Returns the sum of this Complex and another Complex, this+y. |
static Complex |
plus(Complex x,
Complex y)
Returns the sum of two Complex objects, x+y. |
static Complex |
plus(Complex x,
double y)
Returns the sum of a Complex and a double, x+y. |
Complex |
plus(double y)
Returns the sum of this Complex a double, this+y. |
static Complex |
plus(double x,
Complex y)
Returns the sum of a double and a Complex, x+y. |
Complex |
plusReverse(double x)
Returns the sum of this Complex and a double, x+this. |
static Complex |
pow(Complex x,
Complex y)
Returns the Complex x raised to the Complex y power. |
static Complex |
pow(Complex z,
double x)
Returns the Complex z raised to the x power, with a branch cut for the first parameter (z) along the negative real axis. |
double |
real()
Returns the real part of a Complex object. |
static double |
real(Complex z)
Returns the real part of a Complex object. |
static Complex |
sin(Complex z)
Returns the sine of a Complex. |
static Complex |
sinh(Complex z)
Returns the hyperbolic sine of a Complex. |
static Complex |
sqrt(Complex z)
Returns the square root of a Complex, with a branch cut along the negative real axis. |
static Complex |
tan(Complex z)
Returns the tangent of a Complex. |
static Complex |
tanh(Complex z)
Returns the hyperbolic tanh of a Complex. |
Complex |
times(Complex y)
Returns the product of this Complex object and another Complex object, this*y. |
static Complex |
times(Complex x,
Complex y)
Returns the product of two Complex objects, x*y. |
static Complex |
times(Complex x,
double y)
Returns the product of a Complex object and a double, x*y. |
Complex |
times(double y)
Returns the product of this Complex object and a double, this*y. |
static Complex |
times(double x,
Complex y)
Returns the product of a double and a Complex object, x*y. |
Complex |
timesReverse(double x)
Returns the product of a double and this Complex, x*this. |
java.lang.String |
toString()
Returns a String representation for the specified Complex. |
static Complex |
valueOf(java.lang.String s)
Parses a string into a Complex. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
static final long serialVersionUID
public static java.lang.String suffix
Constructor Detail |
---|
public Complex()
public Complex(double re)
re
- A double value equal to the real part of the Complex object. public Complex(double re, double im)
re
- A double value equal to the real part of the Complex object.im
- A double value equal to the imaginary part of the Complex object. public Complex(Complex z)
z
- A Complex object
If z is null then a NullPointerException is thrown. Method Detail |
---|
public static double abs(Complex z)
z
- A Complex object.
public static Complex acos(Complex z)
z
- A Complex object.
public static Complex acosh(Complex z)
z
- A Complex object.
public static double argument(Complex z)
z
- A Complex object.
public static Complex asin(Complex z)
z
- A Complex object.
public static Complex asinh(Complex z)
z
- A Complex object.
public static Complex atan(Complex z)
z
- A Complex object.
public static Complex atanh(Complex z)
z
- A Complex object.
public static Complex conjugate(Complex z)
z
- A Complex object.
public static Complex cos(Complex z)
z
- A Complex object.
public static Complex cosh(Complex z)
z
- A Complex object.
public boolean equals(Complex z)
Note: To be useful in hashtables this method considers two NaN double values to be equal. This is not according to IEEE specification.
z
- A Complex object.
public boolean equals(java.lang.Object obj)
Note: To be useful in hashtables this method considers two NaN double values to be equal. This is not according to IEEE specification
equals
in class java.lang.Object
obj
- The object to compare with.
public static Complex exp(Complex z)
z
- A Complex object.
public int hashCode()
hashCode
in class java.lang.Object
public double imag()
public static double imag(Complex z)
z
- A Complex object.
public static Complex log(Complex z)
z
- A Complex object.
public Complex minus(double y)
y
- A double value.
public static Complex minus(double x, Complex y)
x
- A double value.y
- A Complex object.
public Complex minus(Complex y)
y
- A Complex object.
public static Complex minus(Complex x, double y)
x
- A Complex object.y
- A double value.
public static Complex minus(Complex x, Complex y)
x
- A Complex object.y
- A Complex object.
public Complex minusReverse(double x)
x
- A double value.
public static Complex negative(Complex z)
z
- A Complex object.
public Complex over(double y)
y
- The denominator, a double.
public static Complex over(double x, Complex y)
x
- A double value.y
- The denominator, a Complex object.
public Complex over(Complex y)
y
- The denominator, a Complex object.
public static Complex over(Complex x, double y)
x
- The numerator, a Complex object.y
- The denominator, a double.
public static Complex over(Complex x, Complex y)
x
- The numerator, a Complex object.y
- The denominator, a Complex object.
public Complex overReverse(double x)
x
- The numerator, a double.
public Complex plus(double y)
y
- A double value.
public static Complex plus(double x, Complex y)
x
- A double value.y
- A Complex object.
public Complex plus(Complex y)
y
- A Complex object.
public static Complex plus(Complex x, double y)
x
- A Complex object.y
- A double value.
public static Complex plus(Complex x, Complex y)
x
- A Complex object.y
- A Complex object.
public Complex plusReverse(double x)
x
- A double value.
public static Complex pow(Complex z, double x)
z
- A Complex object.x
- A double value.
public static Complex pow(Complex x, Complex y)
x
- A Complex object.y
- A Complex object.
public double real()
public static double real(Complex z)
z
- A Complex object.
public static Complex sin(Complex z)
z
- A Complex object.
public static Complex sinh(Complex z)
z
- A Complex object.
public static Complex sqrt(Complex z)
z
- A Complex object.
public static Complex tan(Complex z)
z
- A Complex object.
public static Complex tanh(Complex z)
z
- A Complex object.
public Complex times(double y)
y
- A double value.
public static Complex times(double x, Complex y)
x
- A double value.y
- A Complex object.
public Complex times(Complex y)
y
- A Complex object.
public static Complex times(Complex x, double y)
x
- A Complex object.y
- A double value.
public static Complex times(Complex x, Complex y)
x
- A Complex object.y
- A Complex object.
public Complex timesReverse(double x)
x
- A double value.
public java.lang.String toString()
toString
in class java.lang.Object
public static Complex valueOf(java.lang.String s) throws java.lang.NumberFormatException
s
- The string to be parsed.
java.lang.NumberFormatException
- If the string does not contain a parsable Complex number.
java.lang.NullPointerException
- If the input argument is null.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |