|
JMSLTM Numerical Library 4.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Number
com.imsl.math.Complex
Set of mathematical functions for 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 add,
subtract, multiply or divide.
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
Complex objects are immutable. Once created there is no way to change
their value.
The 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.
| Field Summary | |
static Complex |
i
The imaginary unit. |
static 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 Complex |
add(Complex x,
Complex y)
Returns the sum of two Complex objects, x+y. |
static Complex |
add(Complex x,
double y)
Returns the sum of a Complex and a double, x+y. |
static Complex |
add(double x,
Complex y)
Returns the sum of a double and a Complex, x+y. |
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 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 branch cuts outside the interval [-1,1] on the real axis. |
byte |
byteValue()
Returns the value of the real part as a byte. |
int |
compareTo(Complex z)
Compares two Complex objects. |
int |
compareTo(Object obj)
Compares this Complex to another Object. |
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. |
static Complex |
divide(Complex x,
Complex y)
Returns the result of a Complex object divided by a Complex object, x/y. |
static Complex |
divide(Complex x,
double y)
Returns the result of a Complex object divided by a double, x/y. |
static Complex |
divide(double x,
Complex y)
Returns the result of a double divided by a Complex object, x/y. |
double |
doubleValue()
Returns the value of the real part as a double. |
boolean |
equals(Complex z)
Compares with another Complex. |
boolean |
equals(Object obj)
Compares this object against the specified object. |
static Complex |
exp(Complex z)
Returns the exponential of a Complex z, exp(z). |
float |
floatValue()
Returns the value of the real part as a float. |
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. |
int |
intValue()
Returns the value of the real part as an int. |
static Complex |
log(Complex z)
Returns the logarithm of a Complex z,
with a branch cut along the negative real axis. |
long |
longValue()
Returns the value of the real part as a long. |
static Complex |
multiply(Complex x,
Complex y)
Returns the product of two Complex objects, x * y. |
static Complex |
multiply(Complex x,
double y)
Returns the product of a Complex object and a double,
x * y. |
static Complex |
multiply(double x,
Complex y)
Returns the product of a double and a Complex object,
x * y. |
static Complex |
multiplyImag(Complex x,
double y)
Returns the product of a Complex object and a pure
imaginary double, x * iy. |
static Complex |
multiplyImag(double x,
Complex y)
Returns the product of a pure imaginary double and a
Complex object, ix * y. |
static Complex |
negate(Complex z)
Returns the negative of a Complex object, -z. |
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. |
short |
shortValue()
Returns the value of the real part as a short. |
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 |
subtract(Complex x,
Complex y)
Returns the difference of two Complex objects, x-y. |
static Complex |
subtract(Complex x,
double y)
Returns the difference of a Complex object and a double, x-y. |
static Complex |
subtract(double x,
Complex y)
Returns the difference of a double and a Complex object, x-y. |
static Complex |
tan(Complex z)
Returns the tangent of a Complex. |
static Complex |
tanh(Complex z)
Returns the hyperbolic tanh of a Complex. |
String |
toString()
Returns a String representation for the specified Complex. |
static Complex |
valueOf(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 |
public static final Complex i
public static String suffix
Complex to String.
Default is i, but sometimes j is desired.
Note that this is set for the class, not for
a particular instance of a Complex.
| Constructor Detail |
public Complex()
Complex equal to zero.
public Complex(Complex z)
Complex equal to the argument.
z - a Complex object
NullPointerException - is thrown if z is nullpublic Complex(double re)
Complex with a zero imaginary part.
re - a double value equal to the real part of the Complex object
public Complex(double re,
double im)
Complex with real and imaginary parts given
by the input arguments.
re - a double value equal to the real part of the Complex objectim - a double value equal to the imaginary part of the Complex object| Method Detail |
public static double abs(Complex z)
Complex, |z|.
z - a Complex object
double value equal to the absolute value of the argumentpublic static Complex acos(Complex z)
Complex,
with branch cuts outside the interval [-1,1] along the
real axis.
Specifically, if z = x+iy,
.
returns
.
returns
.
returns
.
returns
, for finite x.
returns
, for positive-signed finite y.
returns
, for positive-signed finite y.
returns
(where the sign of the imaginary part of the result is unspecified).
returns
.
returns
.
returns
, for nonzero finite x.
returns
, for finite y.
returns
.
z - a Complex object
Complex initialized to the
inverse (arc) cosine of the argument.
The real part of the result is in the interval public static Complex acosh(Complex z)
Complex,
with a branch cut at values less than one along the real axis.
Specifically, if z = x+iy,
.
returns
.
returns
.
returns
.
returns
, for finite x.
returns
, for positive-signed finite y.
returns
, for positive-signed finite y.
returns
.
returns
.
returns
, for finite x.
returns
, for finite y.
returns
.
z - a Complex object
Complex initialized to the
inverse (arc) hyperbolic cosine of the argument.
The real part of the result is non-negative and its
imaginary part is in the interval
public static Complex add(Complex x,
Complex y)
Complex objects, x+y.
x - a Complex objecty - a Complex object
Complex initialized to x+y
public static Complex add(Complex x,
double y)
Complex and a double, x+y.
x - a Complex objecty - a double value
Complex initialized to x+y
public static Complex add(double x,
Complex y)
double and a Complex, x+y.
x - a double valuey - a Complex object
Complex initialized to x+ypublic static double argument(Complex z)
Complex, in radians,
with a branch cut along the negative real axis.
z - a Complex object
double value equal to the argument (or phase) of a Complex.
It is in the interval public static Complex asin(Complex z)
Complex,
with branch cuts outside the interval [-1,1] along the
real axis.
The value of asin is defined in terms of the function asinh, by
z - a Complex object
Complex initialized to the inverse
(arc) sine of the argument. The real part of the
result is in the interval asinh(com.imsl.math.Complex)public static Complex asinh(Complex z)
Complex,
with branch cuts outside the interval [-i,i].
Specifically, if z = x+iy,
and asinh is odd.
returns
.
returns
.
returns
for positive-signed finite x.
returns
for positive-signed finite y.
returns
(where the sign of the real part of the result is unspecified).
returns
.
returns
.
returns
, for finite nonzero y.
returns
, for finite x.
returns
.
z - a Complex object
Complex initialized to the
inverse (arc) hyperbolic sine of the argument.
Its imaginary part is in the interval public static Complex atan(Complex z)
Complex,
with branch cuts outside the interval [-i,i] along the
imaginary axis.
The value of atan is defined in terms of the function atanh, by
z - a Complex object
Complex initialized to the
inverse (arc) tangent of the argument.
Its real part is in the interval atanh(com.imsl.math.Complex)public static Complex atanh(Complex z)
Complex,
with branch cuts outside the interval [-1,1] on the real axis.
Specifically, if z = x+iy,
and atanh is odd.
returns
.
returns
.
returns
, for finite positive-signed y.
returns
, for finite positive-signed x.
returns
.
returns
(where the sign of the real part of the result is unspecified).
returns
.
returns
, for finite y.
returns
, for nonzero finite x.
returns
.
z - a Complex object
Complex initialized to the
inverse (arc) hyperbolic tangent of the argument.
The imaginary part of the result is in the interval
public byte byteValue()
Complex objectpublic int compareTo(Complex z)
Complex objects.
A lexagraphical ordering is used. First the real parts are compared in the sense of Double.compareTo. If the real parts are unequal this is the return value. If the return parts are equal then the comparison of the imaginary parts is returned.
z - a Complex to be compared
Complex;
a value less than 0 if this Complex is less than z;
and a value greater than 0 if this Complex is greater
than z.public int compareTo(Object obj)
Complex to another Object. If the Object is a Complex,
this function behaves like compareTo(Complex). Otherwise, it throws
a ClassCastException (as Complex objects are comparable only to other
Complex objects).
obj - an Object to be compared
int, 0 if obj is equal to this Complex;
a value less than 0 if this Complex is less than obj;
and a value greater than 0 if this Complex is greater
than obj.
ClassCastException - is thrown if obj is not a Complex objectpublic static Complex conjugate(Complex z)
Complex object.
z - a Complex object
Complex initialized to the complex
conjugate of Complex argument, zpublic static Complex cos(Complex z)
Complex.
The value of cos is defined in terms of the function cosh, by
z - a Complex object
Complex initialized to the cosine of
the argumentcosh(com.imsl.math.Complex)public static Complex cosh(Complex z)
Complex.
If z = x+iy,
and cosh is even.
returns
.
returns
(where the sign of the imaginary part of the result is unspecified).
returns
.
returns
.
returns
, for finite nonzero x.
returns
, for finite nonzero y.
returns
(where the sign of the imaginary part of the result is unspecified).
returns
.
returns
, for finite nonzero x.
returns
(where the sign of the imaginary part of the result is unspecified).
returns
, for all nonzero numbers y.
returns
.
z - a Complex object
Complex initialized to
the hyperbolic cosine of the argument
public static Complex divide(Complex x,
Complex y)
Complex object divided by a Complex object, x/y.
x - a Complex object representing the numeratory - a Complex object representing the denominator
Complex initialized to x/y
public static Complex divide(Complex x,
double y)
Complex object divided by a double, x/y.
x - a Complex object representing the numeratory - a double representing the denominator
Complex initialized to x/y
public static Complex divide(double x,
Complex y)
double divided by a Complex object, x/y.
x - a double valuey - a Complex object representing the denominator
Complex initialized to x/ypublic double doubleValue()
double.
double representing the value of the real part of a Complex objectpublic boolean equals(Complex z)
Complex.
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(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
obj - the object to compare with
public static Complex exp(Complex z)
Complex z, exp(z).
Specifically, if z = x+iy,
.
returns
.
returns
.
returns
(where the signs of the real and imaginary parts of the result are unspecified).
returns
(where the sign of the real part of the result is unspecified).
returns
, for finite x.
returns
, for finite y.
returns
, for finite nonzero y.
returns
(where the signs of the real and imaginary parts of the result are unspecified).
returns
(where the sign of the real part of the result is unspecified).
returns
.
returns
, for all non-zero numbers y.
returns
, for finite x.
z - a Complex object
Complex initialized to the exponential
of the argumentpublic float floatValue()
Complex objectpublic int hashCode()
Complex.
public double imag()
Complex object.
double representing the imaginary part of a Complex object, zpublic static double imag(Complex z)
Complex object.
z - a Complex object
double representing the imaginary part of the Complex object, zpublic int intValue()
Complex objectpublic static Complex log(Complex z)
Complex z,
with a branch cut along the negative real axis.
Specifically, if z = x+iy,
.
returns
.
returns
.
returns
.
returns
.
returns
, for finite x.
returns
, for finite positive-signed y.
returns
, for finite positive-signed y.
returns
.
returns
.
returns
, for finite x.
returns
, for finite y.
returns
.
z - a Complex object
Complex initialized to the logarithm
of the argument. Its imaginary part is in the
interval public long longValue()
Complex object
public static Complex multiply(Complex x,
Complex y)
Complex objects, x * y.
x - a Complex objecty - a Complex object
Complex initialized to
public static Complex multiply(Complex x,
double y)
Complex object and a double,
x * y.
x - a Complex objecty - a double value
Complex initialized to
public static Complex multiply(double x,
Complex y)
double and a Complex object,
x * y.
x - a double valuey - a Complex object
Complex initialized to
public static Complex multiplyImag(Complex x,
double y)
Complex object and a pure
imaginary double, x * iy.
x - a Complex objecty - a double value representing a pure imaginary
Complex initialized to x * iy
public static Complex multiplyImag(double x,
Complex y)
double and a
Complex object, ix * y.
x - a double value representing a pure imaginaryy - a Complex object
Complex initialized to public static Complex negate(Complex z)
Complex object, -z.
z - a Complex object
Complex initialized to
the negative of the Complex argument, z
public static Complex pow(Complex x,
Complex y)
Complex x raised to the Complex y power.
The value of pow is defined in terms of the functions exp and log, by
x - a Complex objecty - a Complex object
Complex initialized to exp(com.imsl.math.Complex),
log(com.imsl.math.Complex)
public static Complex pow(Complex z,
double x)
Complex z raised to the x power,
with a branch cut for the first parameter (z) along the
negative real axis.
z - a Complex objectx - a double value
Complex initialized to z to the power xpublic double real()
Complex object.
double representing the real part of a Complex object, zpublic static double real(Complex z)
Complex object.
z - a Complex object
double representing the real part of the Complex object, zpublic short shortValue()
Complex objectpublic static Complex sin(Complex z)
Complex.
The value of sin is defined in terms of the function sinh, by
z - a Complex object
Complex initialized to the sine
of the argumentsinh(com.imsl.math.Complex)public static Complex sinh(Complex z)
Complex.
If z = x+iy,
and sinh is odd.
returns
.
returns
(where the sign of the real part of the result is unspecified).
returns
.
returns
(where the sign of the real part of the result is unspecified).
returns
, for positive finite y.
returns
, for positive finite x.
returns
(where the sign of the real part of the result is unspecified).
returns
(where the sign of the real part of the result is unspecified).
returns
, for finite nonzero x.
returns
.
returns
, for all nonzero numbers y.
returns
.
z - a Complex object
Complex initialized to the hyperbolic
sine of the argumentpublic static Complex sqrt(Complex z)
Complex,
with a branch cut along the negative real axis.
Specifically, if z = x+iy,
.
returns
.
returns
,
for finite positive-signed y.
returns
,
for finite positive-signed y.
returns
, for all x (including NaN).
returns
(where the sign of the imaginary part of the result is unspecified).
returns
.
returns
and optionally raises the invalid exception, for finite x.
returns
and optionally raises the invalid exception, for finite y.
returns
.
z - a Complex object
Complex initialized
to square root of z.
public static Complex subtract(Complex x,
Complex y)
Complex objects, x-y.
x - a Complex objecty - a Complex object
Complex initialized to x-y
public static Complex subtract(Complex x,
double y)
Complex object and a double, x-y.
x - a Complex objecty - a double value
Complex initialized to x-y
public static Complex subtract(double x,
Complex y)
double and a Complex object, x-y.
x - a double valuey - a Complex object
Complex initialized to x-ypublic static Complex tan(Complex z)
Complex.
The value of tan is defined in terms of the function tanh, by
z - a Complex object
Complex initialized
to the tangent of the argumenttanh(com.imsl.math.Complex)public static Complex tanh(Complex z)
Complex.
If z = x+iy,
and tanh is odd.
returns
.
returns
, for all positive-signed numbers y.
returns
, for finite x.
returns
(where the sign of the imaginary part of the result is unspecified).
returns
.
returns
, for all nonzero numbers y.
returns
, for finite x.
returns
.
z - a Complex object
Complex initialized to
the hyperbolic tangent of the argumentpublic String toString()
String representation for the specified Complex.
String representation for this object
public static Complex valueOf(String s)
throws NumberFormatException
String into a Complex.
s - the String to be parsed
Complex initialized to the value
represented by the String argument
NumberFormatException - if the string does not contain a parsable Complex number
NullPointerException - if the input argument is null
|
JMSLTM Numerical Library 4.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||