public class Complex extends Object
Complex, a complex number z is internally
represented by a double-array of length 2, where
z[0] = x = Re z, and
z[1] = y = Im z.
In the sequel this representation is called array representation
of complex numbers. It is the purpose of the static methods to provide
this fast representation directly without generating complex number objects.| Modifier and Type | Field and Description |
|---|---|
static double |
ACCURACY
Accuracy up to which equality of double values are computed in
methods of this class.
|
static Complex |
I
Constant i ∈ ℂ.
|
static Complex |
ONE
Constant 1 ∈ ℂ.
|
static Complex |
ZERO
Constant 0 ∈ ℂ.
|
| Constructor and Description |
|---|
Complex(double[] z)
Creates a complex number z = z[0] + iz[1]
from the "array representation," i.e.,
with real part z[0] and imaginary part z[1].
|
Complex(double x,
double y)
Creates a complex number z = x + iy
with real part x and imaginary part y.
|
| Modifier and Type | Method and Description |
|---|---|
double |
abs()
Returns the absolute value, or complex modulus,
|z| of z ∈ ℂ
of this complex number z.
|
static double |
abs(Complex z)
Returns the absolute value, or complex modulus,
|z| of z ∈ ℂ
of the complex number z.
|
static double |
abs(double[] z)
Returns the absolute value, or complex modulus,
|z| of z ∈ ℂ.
|
Complex |
add(Complex z)
Returns the sum of this number and the complex number z.
|
static double[] |
add(double[] x,
double[] y)
Returns the sum of two complex numbers x and y.
|
double |
arg()
Returns the argument of this complex number z.
|
static double |
arg(Complex z)
Returns the argument of the complex number z.
|
static double |
arg(double[] z)
Returns the argument of the complex number z.
|
static Complex |
cos(Complex z)
Returns the cosine of this complex number.
|
static double[] |
cos(double[] z)
Returns the cosine of a complex number z.
|
Complex |
divide(Complex z)
divides this complex numbers by z.
|
static double[] |
divide(double[] x,
double[] y)
divides two complex numbers x and y.
|
static Complex |
divide(double x,
Complex y)
divides a real number x by a complex number y.
|
static double[] |
divide(double x,
double[] y)
divides a real number x by a complex number y.
|
static Complex |
exp(Complex z)
The exponential function of the complex number z.
|
static double[] |
exp(double[] z)
The exponential function of a complex number z.
|
static Complex |
gamma(Complex z)
The Euler gamma function Γ(z) of a complex number z.
|
static double[] |
gamma(double[] z)
The Euler gamma function Γ(z) of a complex number z.
|
double |
getIm()
Returns the imaginary part Imz of this complex number z.
|
double |
getRe()
Returns the real part Rez of this complex number z.
|
static Complex |
ln(Complex z)
Logarithm of this complex number z.
|
static double[] |
ln(double[] z)
Logarithm of a complex number z.
|
static double[] |
lnCos(double[] z)
Returns the natural logarithm of the cosine of a complex number z.
|
static Complex |
lnGamma(Complex z)
Logarithm of the Euler gamma function of a complex number z.
|
static double[] |
lnGamma(double[] z)
Logarithm of the Euler gamma function of a complex number z.
|
static Complex |
lnSin(Complex z)
Returns the natural logarithm of the sine of a complex number z.
|
static double[] |
lnSin(double[] z)
Returns the natural logarithm of the sine of a complex number z.
|
Complex |
minus(Complex z)
subtracts z from this complex number.
|
Complex |
multiply(Complex z)
Returns the product of this complex number and the complex number z.
|
static Complex |
multiply(Complex x,
Complex y)
The product of two complex numbers.
|
Complex |
multiply(double x)
The product of a real number x with this complex number.
|
static double[] |
multiply(double[] x,
double[] y)
The product of two complex numbers.
|
static double[] |
multiply(double x,
double[] z)
The product of a real number x and a complex number z.
|
Complex |
plus(Complex z)
Returns the sum of this number and the complex number z.
|
Complex |
pow(Complex s)
Returns zs where z is this complex number,
and s is a complex number.
|
static double[] |
power(double[] z,
double[] s)
Returns zs for two complex numbers z, s.
|
static Complex |
power(double x,
Complex s)
Returns xs for a real number x and a complex number s.
|
static double[] |
power(double x,
double[] s)
Returns xs for a real number x and a complex number s.
|
Complex |
reciprocal()
Returns the reciprocal of this number.
|
static double[] |
reciprocal(double[] y)
Returns the reciprocal of a complex number y.
|
Complex |
sin()
Returns the sine of this complex number.
|
static Complex |
sin(Complex z)
Returns the sine of a complex number z.
|
static double[] |
sin(double[] z)
Returns the sine of a complex number z.
|
static Complex |
sqrt(Complex z)
Returns the square root of a complex number z.
|
static double[] |
sqrt(double[] z)
Returns the square root of a complex number z.
|
Complex |
subtract(Complex z)
subtracts z from this complex number.
|
static double[] |
subtract(double[] x,
double[] y)
subtracts two complex numbers x and y.
|
String |
toString()
Returns a string representation of this complex number in a "readable" standard format.
|
static String |
toString(Complex z)
Returns a string representation of the complex number z
in a "readable" standard format.
|
static String |
toString(Complex z,
DecimalFormat digit)
Returns a string representation of this complex number in a "readable" standard format.
|
static String |
toString(double[] z)
displays a complex number to a "readable" standard format.
|
static String |
toString(double[] z,
DecimalFormat digit)
displays a complex number to the "readable" format
digit. |
public static final double ACCURACY
gamma(Complex),
lnGamma(Complex), or pow(Complex).public static final Complex ZERO
public static final Complex ONE
public static final Complex I
public Complex(double x,
double y)
x - the real part of the complex numbery - the imaginary part of the complex numberpublic Complex(double[] z)
z - an array with z[0] representing the real part
and z[1] representing the imaginary part of the complex numberpublic double getRe()
public double getIm()
public static double abs(double[] z)
z - the complex number z in the array representationpublic static double abs(Complex z)
z - a complex numberpublic double abs()
this|public static double[] add(double[] x,
double[] y)
x + y = x0 + y0 + i (x1 + y1)
x - the first addend in the array representationy - the second addend in the array representationadd(Complex)public Complex add(Complex z)
x + y = x0 + y0 + i (x1 + y1)
z - the addendthis + zplus(Complex),
add(double[],double[])public static double arg(double[] z)
z - a complex numberarg(Complex)public static double arg(Complex z)
z - a complex numberarg(),
arg(double[])public double arg()
thisarg(Complex),
arg(double[])public static double[] cos(double[] z)
z - the argumentpublic static Complex cos(Complex z)
z - the argumentpublic static double[] divide(double x,
double[] y)
x - the dividendy - the divisordivide(double, Complex),
divide(double[], double[])public static Complex divide(double x, Complex y)
x - the dividendy - the divisordivide(double, double[])public static double[] divide(double[] x,
double[] y)
x - dividendy - divisordivide(double, double[])public Complex divide(Complex z)
z - divisorthis/zdivide(double[], double[])public static double[] exp(double[] z)
exp(z) = ex (cosy + i sin y).
z - a complex numberln(double[])public static Complex exp(Complex z)
exp(z) = ex (cosy + i sin y),
where z is this complex number.z - the argumentln(Complex)public static double[] gamma(double[] z)
| Γ(z) | = |
|
| [ | ( | 1 + |
| )-1 | ez/n | ] |
accuracy.
Here γ denotes the Euler-Mascheroni constant.z - a complex numbergamma(Complex),
lnGamma(double[]),
Numbers.gamma(double)public static Complex gamma(Complex z)
| Γ(z) | = |
|
| [ | ( | 1 + |
| )-1 | ez/n | ] |
accuracy.
Here γ denotes the Euler-Mascheroni constant.z - a complex numberexp(double[]),
Numbers.gamma(double)public static double[] lnCos(double[] z)
z - the argumentpublic static Complex ln(Complex z)
z - the argumentabs(Complex),
arg(Complex),
exp(Complex),
ln(double[])public static double[] ln(double[] z)
z - complex numberabs(double[]),
arg(double[]),
exp(double[]),
ln(Complex)public static double[] lnGamma(double[] z)
| ln Γ(z) | = | - ln z - γz | + |
| [ |
| - ln | ( | 1 + |
| ) | ] |
Euler-Mascheroni constant.z - a complex numberlnGamma(Complex),
gamma(double[])public static Complex lnGamma(Complex z)
| ln Γ(z) | = | - ln z - γz | + |
| [ |
| - ln | ( | 1 + |
| ) | ] |
Euler-Mascheroni constant.z - a complex numbergamma(Complex),
lnGamma(double[])public static Complex lnSin(Complex z)
z - a complex number in the array representationpublic static double[] lnSin(double[] z)
z - a complex number in the array representationpublic Complex minus(Complex z)
this.subtract(z) = this - z
= Re (this - y) + Im (this - z).z - a complex numberthis - zsubtract(Complex)public static double[] multiply(double x,
double[] z)
x - a real numberz - a complex number in the array representationpublic Complex multiply(double x)
x - a real numberpublic static Complex multiply(Complex x, Complex y)
xy = x0y0 - x1y1 + i (x1y0 + x0y1)
x - the first factor in the array representationy - the second factor in the array representationpublic static double[] multiply(double[] x,
double[] y)
xy = x0y0 - x1y1 + i (x1y0 + x0y1)
x - the first factor in the array representationy - the second factor in the array representationpublic Complex multiply(Complex z)
xy = x0y0 - x1y1 + i (x1y0 + x0y1)
z - a complex numberthis∙zpublic Complex plus(Complex z)
x + y = x0 + y0 + i (x1 + y1)
z - the addendthis + zadd(Complex)public static Complex power(double x, Complex s)
xs = xs0 [ cos( s1 ln x ) + i sin( s1 ln x ) ].
if x > 0, and
xs = |x|s0 [ cos( s1 ln |x| + s0π) + i sin( s1 ln |x| + s0π) ].
x - a real number as the bases - a complex number as the exponentpow(Complex),
power(double,double[])public static double[] power(double x,
double[] s)
xs = xs0 [ cos( s1 ln x ) + i sin( s1 ln x ) ].
if x > 0, and
xs = |x|s0 [ cos( s1 ln |x| + s0π) + i sin( s1 ln |x| + s0π) ].
x - a real number as the bases - a complex number in the array representation as the exponentpower(double,double[]),
pow(Complex)public Complex pow(Complex s)
zs = rx e-yφ [ cos( xφ + y ln r ) + i sin( xφ + y ln r ) ].
s - the exponentpower(double[],double[])public static double[] power(double[] z,
double[] s)
zs = rx e-yφ [ cos( xφ + y ln r ) + i sin( xφ + y ln r ) ].
z - the bases - the exponentpower(double,double[])public static double[] reciprocal(double[] y)
y - a complex numberdivide(double, double[]),
reciprocal()public Complex reciprocal()
thisreciprocal(double[])public static double[] sin(double[] z)
z - a complex number in the array representationpublic static Complex sin(Complex z)
z - a complex numberpublic Complex sin()
public static double[] sqrt(double[] z)
z - a complex number in the array representationpublic static Complex sqrt(Complex z)
z - a complex numberpublic static double[] subtract(double[] x,
double[] y)
x - a complex number in the array representationy - a complex number in the array representationpublic Complex subtract(Complex z)
this.subtract(z) = this - z
= Re (this - y) + Im (this - z).z - a complex numberthis - zminus(Complex),
subtract(double[],double[])public String toString()
toString in class ObjecttoString(double[],java.text.DecimalFormat)public static String toString(Complex z)
z - the complex number to be formattedtoString(double[])public static String toString(double[] z)
z - the complex number to be formattedtoString(double[],java.text.DecimalFormat)public static String toString(Complex z, DecimalFormat digit)
z - the complex number to be formatteddigit - the decimal format in which z is to be displayedtoString(double[],java.text.DecimalFormat)public static String toString(double[] z, DecimalFormat digit)
digit.
If the real or the imaginary part are too large or too small,
scientific notation is used.z - the complex number to be formatteddigit - the decimal format in which z is to be displayedtoString(double[])