|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opensourcephysics.numerics.Complex
public class Complex
Constructor Summary | |
---|---|
Complex()
Default constructor. |
|
Complex(Complex z)
Copy constructor |
|
Complex(double re_in)
Constructor from a single double value. |
|
Complex(double re_in,
double im_in)
Initialize the real and imaginary components to the values given by the parameters. |
|
Complex(java.lang.Number re_in)
Construct from a Number. |
Method Summary | |
---|---|
double |
abs()
Returns the absolute value of the complex number. |
double |
abs2()
Returns the square of the absolute value (re*re+im*im). |
Complex |
acos()
|
Complex |
acosh()
|
Complex |
add(Complex z)
Returns the sum of two complex numbers |
Complex |
add(double d)
Returns the sum of a complex number and a double |
double |
arg()
Returns the argument of this complex number (Math.atan2(re,im)) |
Complex |
asin()
|
Complex |
asinh()
|
Complex |
atan()
|
Complex |
atanh()
|
Complex |
cartesian()
Convert polar to Cartesian |
Complex |
conjugate()
Conjugats the complex number |
Complex |
cos()
Returns the cosine of this complex number. |
Complex |
cosh()
|
Complex |
div(Complex b)
Returns the result of dividing this complex number by the parameter. |
Complex |
div(double d)
Devide the complex number by a double value. |
boolean |
equals(Complex b,
double tolerance)
Compares this object with the Complex number given as parameter |
Complex |
exp()
Returns e to the power of the complex number |
double |
im()
Returns the imaginary component of this object |
Complex |
invert()
|
boolean |
isInfinite()
Returns true if either the real or imaginary component of this Complex is an infinite value. |
boolean |
isNaN()
Returns true if either the real or imaginary component of this Complex is a Not-a-Number (NaN) value. |
Complex |
log()
Returns the logarithm of this complex number. |
double |
mag()
Returns the magnitude of the complex number |
Complex |
mul(Complex b)
Multiplies the complex number with another complex value. |
Complex |
mul(double b)
Multiplies the complex number with a double value. |
Complex |
neg()
Returns the negative value of this complex number. |
static Complex |
parseComplex(java.lang.String s)
Convert text representation to a Complex. |
Complex |
polar()
Convert Cartesian to polar |
Complex |
power(Complex exponent)
Returns the value of this complex number raised to the power of a complex exponent |
Complex |
power(double exponent)
Returns the value of this complex number raised to the power of a real component (in double precision). |
double |
re()
Returns the real component of this object |
void |
set(Complex z)
Copies the values from the parameter object to this object |
void |
set(double re_in,
double im_in)
Sets the real and imaginary values of the object. |
void |
setIm(double im_in)
Sets the imaginary component of the object |
void |
setRe(double re_in)
Sets the real component of the object |
Complex |
sin()
Returns the sine of this complex number. |
Complex |
sinh()
|
Complex |
sqrt()
Calculates the square root of this object. |
Complex |
subtract(Complex z)
Returns the subtraction of complex z from a complex number |
Complex |
subtract(double d)
Subtracts the double d from the complex number Returns the subtraction of complex z from a complex number |
Complex |
tan()
Returns the tangent of this complex number. |
Complex |
tanh()
|
java.lang.String |
toString()
Returns the value of this complex number as a string in the format: |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Complex()
public Complex(double re_in)
re_in
- public Complex(java.lang.Number re_in)
re_in
- public Complex(Complex z)
z
- public Complex(double re_in, double im_in)
re_in
- im_in
- Method Detail |
---|
public Complex polar()
public Complex cartesian()
public double re()
public double im()
public void set(Complex z)
public void set(double re_in, double im_in)
public void setRe(double re_in)
public void setIm(double im_in)
public boolean equals(Complex b, double tolerance)
b. The
toleranceparameter is the radius within which the
bnumber must lie for the two complex numbers to be considered equal.
trueif the complex number are considered equal,
falseotherwise.
public java.lang.String toString()
(real, imaginary).
toString
in class java.lang.Object
public double abs()
public double abs2()
public double mag()
public double arg()
public static Complex parseComplex(java.lang.String s)
public Complex add(Complex z)
public Complex add(double d)
public Complex subtract(Complex z)
public Complex subtract(double d)
public Complex neg()
public Complex mul(double b)
public Complex mul(Complex b)
public Complex div(Complex b)
public Complex div(double d)
public Complex invert()
public Complex conjugate()
public Complex power(double exponent)
This method considers special cases where a simpler algorithm
would return "ugly" results.
For example when the expression (-1e40)^0.5 is evaluated without
considering the special case, the argument of the base is the
double number closest to pi. When sin and cos are used for the
final evaluation of the result, the slight difference of the
argument from pi causes a non-zero value for the real component
of the result. Because the value of the base is so high, the error
is magnified.Although the error is normal for floating
point calculations, the consideration of commonly occurring special
cases improves the accuracy and esthetics of the results.
If you know a more elegant way to solve this problem, please let me know at nathanfunk@hotmail.com .
public Complex power(Complex exponent)
public Complex exp()
public Complex log()
public Complex sqrt()
public Complex sin()
public Complex cos()
public Complex tan()
public Complex asin()
public Complex acos()
public Complex atan()
public Complex sinh()
public Complex cosh()
public Complex tanh()
public Complex asinh()
public Complex acosh()
public Complex atanh()
public boolean isInfinite()
public boolean isNaN()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |