public class Complex extends Object implements CalculusFieldElement<Complex>, Serializable
Implementations of arithmetic operations handle NaN and
infinite values according to the rules for Double, i.e.
equals(java.lang.Object) is an equivalence relation for all instances that have
a NaN in either real or imaginary part, e.g. the following are
considered equal:
1 + NaNiNaN + iNaN + NaNi
Note that this contradicts the IEEE-754 standard for floating
point numbers (according to which the test x == x must fail if
x is NaN). The method
equals for primitive double in Precision
conforms with IEEE-754 while this class conforms with the standard behavior
for Java object types.
| Modifier and Type | Field and Description |
|---|---|
static Complex |
I
The square root of -1.
|
static Complex |
INF
A complex number representing "+INF + INFi"
|
static Complex |
MINUS_I
The square root of -1.
|
static Complex |
MINUS_ONE
A complex number representing "-1.0 + 0.0i".
|
static Complex |
NaN
A complex number representing "NaN + NaNi".
|
static Complex |
ONE
A complex number representing "1.0 + 0.0i".
|
static Complex |
PI
A complex number representing "π + 0.0i".
|
static Complex |
ZERO
A complex number representing "0.0 + 0.0i".
|
| Constructor and Description |
|---|
Complex(double real)
Create a complex number given only the real part.
|
Complex(double real,
double imaginary)
Create a complex number given the real and imaginary parts.
|
| Modifier and Type | Method and Description |
|---|---|
Complex |
abs()
Return the absolute value of this complex number.
|
Complex |
acos()
Compute the
inverse cosine of this complex number.
|
Complex |
acosh()
Inverse hyperbolic cosine operation.
|
Complex |
add(Complex addend)
Returns a
Complex whose value is
(this + addend). |
Complex |
add(double addend)
Returns a
Complex whose value is (this + addend),
with addend interpreted as a real number. |
Complex |
asin()
Compute the
inverse sine of this complex number.
|
Complex |
asinh()
Inverse hyperbolic sine operation.
|
Complex |
atan()
Compute the
inverse tangent of this complex number.
|
Complex |
atan2(Complex x)
Two arguments arc tangent operation.
|
Complex |
atanh()
Inverse hyperbolic tangent operation.
|
Complex |
cbrt()
Cubic root.
|
Complex |
ceil()
Get the smallest whole number larger than instance.
|
Complex |
conjugate()
Returns the conjugate of this complex number.
|
Complex |
copySign(Complex z)
Returns the instance with the sign of the argument.
|
Complex |
copySign(double r)
Returns the instance with the sign of the argument.
|
Complex |
cos()
Compute the
cosine of this complex number.
|
Complex |
cosh()
Compute the
hyperbolic cosine of this complex number.
|
protected Complex |
createComplex(double realPart,
double imaginaryPart)
Create a complex number given the real and imaginary parts.
|
Complex |
divide(Complex divisor)
Returns a
Complex whose value is
(this / divisor). |
Complex |
divide(double divisor)
Returns a
Complex whose value is (this / divisor),
with divisor interpreted as a real number. |
static boolean |
equals(Complex x,
Complex y)
Returns
true iff the values are equal as defined by
equals(x, y, 1). |
static boolean |
equals(Complex x,
Complex y,
double eps)
Returns
true if, both for the real part and for the imaginary
part, there is no double value strictly between the arguments or the
difference between them is within the range of allowed error
(inclusive). |
static boolean |
equals(Complex x,
Complex y,
int maxUlps)
Test for the floating-point equality between Complex objects.
|
boolean |
equals(Object other)
Test for equality with another object.
|
static boolean |
equalsWithRelativeTolerance(Complex x,
Complex y,
double eps)
Returns
true if, both for the real part and for the imaginary
part, there is no double value strictly between the arguments or the
relative difference between them is smaller or equal to the given
tolerance. |
Complex |
exp()
Compute the
exponential function of this complex number.
|
Complex |
expm1()
Exponential minus 1.
|
Complex |
floor()
Get the largest whole number smaller than instance.
|
double |
getArgument()
Compute the argument of this complex number.
|
ComplexField |
getField()
Get the
Field to which the instance belongs. |
double |
getImaginary()
Access the imaginary part.
|
double |
getImaginaryPart()
Access the imaginary part.
|
Complex |
getPi()
Get the Archimedes constant π.
|
double |
getReal()
Access the real part.
|
double |
getRealPart()
Access the real part.
|
int |
hashCode()
Get a hashCode for the complex number.
|
Complex |
hypot(Complex y)
Returns the hypotenuse of a triangle with sides
this and y
- sqrt(this2 +y2)
avoiding intermediate overflow or underflow. |
boolean |
isInfinite()
Checks whether 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 |
isMathematicalInteger()
Check whether the instance is an integer (i.e.
|
boolean |
isNaN()
Checks whether either or both parts of this complex number is
NaN. |
boolean |
isReal()
Check whether the instance is real (i.e.
|
boolean |
isZero()
Check if an element is semantically equal to zero.
|
Complex |
linearCombination(Complex[] a,
Complex[] b)
Compute a linear combination.
|
Complex |
linearCombination(Complex a1,
Complex b1,
Complex a2,
Complex b2)
Compute a linear combination.
|
Complex |
linearCombination(Complex a1,
Complex b1,
Complex a2,
Complex b2,
Complex a3,
Complex b3)
Compute a linear combination.
|
Complex |
linearCombination(Complex a1,
Complex b1,
Complex a2,
Complex b2,
Complex a3,
Complex b3,
Complex a4,
Complex b4)
Compute a linear combination.
|
Complex |
linearCombination(double[] a,
Complex[] b)
Compute a linear combination.
|
Complex |
linearCombination(double a1,
Complex b1,
double a2,
Complex b2)
Compute a linear combination.
|
Complex |
linearCombination(double a1,
Complex b1,
double a2,
Complex b2,
double a3,
Complex b3)
Compute a linear combination.
|
Complex |
linearCombination(double a1,
Complex b1,
double a2,
Complex b2,
double a3,
Complex b3,
double a4,
Complex b4)
Compute a linear combination.
|
Complex |
log()
Compute the
natural logarithm of this complex number.
|
Complex |
log10()
Base 10 logarithm.
|
Complex |
log1p()
Shifted natural logarithm.
|
Complex |
multiply(Complex factor)
Returns a
Complex whose value is this * factor. |
Complex |
multiply(double factor)
Returns a
Complex whose value is this * factor, with factor
interpreted as a real number. |
Complex |
multiply(int factor)
Returns a
Complex whose value is this * factor, with factor
interpreted as a integer number. |
Complex |
multiplyMinusI()
Compute this *- -i.
|
Complex |
multiplyPlusI()
Compute this * i.
|
Complex |
negate()
Returns a
Complex whose value is (-this). |
Complex |
newInstance(double realPart)
Create an instance corresponding to a constant real value.
|
double |
norm()
norm.
|
List<Complex> |
nthRoot(int n)
Computes the n-th roots of this complex number.
|
Complex |
pow(Complex x)
Returns of value of this complex number raised to the power of
x. |
Complex |
pow(double x)
Returns of value of this complex number raised to the power of
x. |
Complex |
pow(int n)
Integer power operation.
|
protected Object |
readResolve()
Resolve the transient fields in a deserialized Complex Object.
|
Complex |
reciprocal()
Returns the multiplicative inverse of
this element. |
Complex |
remainder(Complex a)
IEEE remainder operator.
|
Complex |
remainder(double a)
IEEE remainder operator.
|
Complex |
rint()
Get the whole number that is the nearest to the instance, or the even one if x is exactly half way between two integers.
|
Complex |
rootN(int n)
Nth root.
|
Complex |
scalb(int n)
Multiply the instance by a power of 2.
|
Complex |
sign()
Compute the sign of the instance.
|
Complex |
sin()
Compute the
sine
of this complex number.
|
FieldSinCos<Complex> |
sinCos()
Combined Sine and Cosine operation.
|
Complex |
sinh()
Compute the
hyperbolic sine of this complex number.
|
FieldSinhCosh<Complex> |
sinhCosh()
Combined hyperbolic sine and sosine operation.
|
Complex |
sqrt()
Compute the
square root of this complex number.
|
Complex |
sqrt1z()
Compute the
square root of
1 - this2 for this complex
number. |
Complex |
subtract(Complex subtrahend)
Returns a
Complex whose value is
(this - subtrahend). |
Complex |
subtract(double subtrahend)
Returns a
Complex whose value is
(this - subtrahend). |
Complex |
tan()
Compute the
tangent of this complex number.
|
Complex |
tanh()
Compute the
hyperbolic tangent of this complex number.
|
Complex |
toDegrees()
Convert radians to degrees, with error of less than 0.5 ULP
|
Complex |
toRadians()
Convert degrees to radians, with error of less than 0.5 ULP
|
String |
toString() |
Complex |
ulp()
Compute least significant bit (Unit in Last Position) for a number.
|
static Complex |
valueOf(double realPart)
Create a complex number given only the real part.
|
static Complex |
valueOf(double realPart,
double imaginaryPart)
Create a complex number given the real and imaginary parts.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetExponent, isFinite, roundpublic static final Complex I
public static final Complex MINUS_I
public static final Complex NaN
public static final Complex INF
public static final Complex ONE
public static final Complex MINUS_ONE
public static final Complex ZERO
public static final Complex PI
public Complex(double real)
real - Real part.public Complex(double real,
double imaginary)
real - Real part.imaginary - Imaginary part.public Complex abs()
NaN if either real or imaginary part is NaN
and Double.POSITIVE_INFINITY if neither part is NaN,
but at least one part is infinite.abs in interface CalculusFieldElement<Complex>public double norm()
norm in interface CalculusFieldElement<Complex>public Complex add(Complex addend) throws NullArgumentException
Complex whose value is
(this + addend).
Uses the definitional formula
(a + bi) + (c + di) = (a+c) + (b+d)i
this or addend has a NaN value in
either part, NaN is returned; otherwise Infinite
and NaN values are returned in the parts of the result
according to the rules for Double arithmetic.add in interface FieldElement<Complex>addend - Value to be added to this Complex.this + addend.NullArgumentException - if addend is null.public Complex add(double addend)
Complex whose value is (this + addend),
with addend interpreted as a real number.add in interface CalculusFieldElement<Complex>addend - Value to be added to this Complex.this + addend.add(Complex)public Complex conjugate()
a + bi is a - bi.
NaN is returned if either the real or imaginary
part of this Complex number equals Double.NaN.
If the imaginary part is infinite, and the real part is not
NaN, the returned value has infinite imaginary part
of the opposite sign, e.g. the conjugate of
1 + POSITIVE_INFINITY i is 1 - NEGATIVE_INFINITY i.
public Complex divide(Complex divisor) throws NullArgumentException
Complex whose value is
(this / divisor).
Implements the definitional formula
a + bi ac + bd + (bc - ad)i
----------- = -------------------------
c + di c2 + d2
but uses
prescaling of operands to limit the effects of overflows and
underflows in the computation.
Infinite and NaN values are handled according to the
following rules, applied in the order presented:
this or divisor has a NaN value
in either part, NaN is returned.
divisor equals ZERO, NaN is returned.
this and divisor are both infinite,
NaN is returned.
this is finite (i.e., has no Infinite or
NaN parts) and divisor is infinite (one or both parts
infinite), ZERO is returned.
this is infinite and divisor is finite,
NaN values are returned in the parts of the result if the
Double rules applied to the definitional formula
force NaN results.
divide in interface FieldElement<Complex>divisor - Value by which this Complex is to be divided.this / divisor.NullArgumentException - if divisor is null.public Complex divide(double divisor)
Complex whose value is (this / divisor),
with divisor interpreted as a real number.divide in interface CalculusFieldElement<Complex>divisor - Value by which this Complex is to be divided.this / divisor.divide(Complex)public Complex reciprocal()
this element.reciprocal in interface CalculusFieldElement<Complex>reciprocal in interface FieldElement<Complex>this.public boolean equals(Object other)
Double.NaN, the two
Complex objects are considered to be equal.
The behavior is the same as for JDK's Double:
NaN values are considered to be equal,
i.e, if either (or both) real and imaginary parts of the complex
number are equal to Double.NaN, the complex number is equal
to NaN.
public static boolean equals(Complex x, Complex y, int maxUlps)
true if both arguments are equal or within the
range of allowed error (inclusive).x - First value (cannot be null).y - Second value (cannot be null).maxUlps - (maxUlps - 1) is the number of floating point
values between the real (resp. imaginary) parts of x and
y.true if there are fewer than maxUlps floating
point values between the real (resp. imaginary) parts of x
and y.Precision.equals(double,double,int)public static boolean equals(Complex x, Complex y)
true iff the values are equal as defined by
equals(x, y, 1).x - First value (cannot be null).y - Second value (cannot be null).true if the values are equal.public static boolean equals(Complex x, Complex y, double eps)
true if, both for the real part and for the imaginary
part, there is no double value strictly between the arguments or the
difference between them is within the range of allowed error
(inclusive). Returns false if either of the arguments is NaN.x - First value (cannot be null).y - Second value (cannot be null).eps - Amount of allowed absolute error.true if the values are two adjacent floating point
numbers or they are within range of each other.Precision.equals(double,double,double)public static boolean equalsWithRelativeTolerance(Complex x, Complex y, double eps)
true if, both for the real part and for the imaginary
part, there is no double value strictly between the arguments or the
relative difference between them is smaller or equal to the given
tolerance. Returns false if either of the arguments is NaN.x - First value (cannot be null).y - Second value (cannot be null).eps - Amount of allowed relative error.true if the values are two adjacent floating point
numbers or they are within range of each other.Precision.equalsWithRelativeTolerance(double,double,double)public int hashCode()
Double.NaN value in real or imaginary part produces
the same hash code 7.public boolean isZero()
The default implementation simply calls equals(getField().getZero()).
However, this may need to be overridden in some cases as due to
compatibility with hashCode() some classes implements
equals(Object) in such a way that -0.0 and +0.0 are different,
which may be a problem. It prevents for example identifying a diagonal
element is zero and should be avoided when doing partial pivoting in
LU decomposition.
This implementation considers +0.0 and -0.0 to be equal for both real and imaginary components.
isZero in interface FieldElement<Complex>public double getImaginary()
public double getImaginaryPart()
public double getReal()
getReal in interface FieldElement<Complex>public double getRealPart()
public boolean isNaN()
NaN.isNaN in interface CalculusFieldElement<Complex>NaN; false otherwise.public boolean isReal()
public boolean isMathematicalInteger()
public boolean isInfinite()
Double.POSITIVE_INFINITY or
Double.NEGATIVE_INFINITY) and neither part
is NaN.isInfinite in interface CalculusFieldElement<Complex>NaN.public Complex multiply(Complex factor) throws NullArgumentException
Complex whose value is this * factor.
Implements preliminary checks for NaN and infinity followed by
the definitional formula:
(a + bi)(c + di) = (ac - bd) + (ad + bc)i
NaN if either this or factor has one or
more NaN parts.
Returns INF if neither this nor factor has one
or more NaN parts and if either this or factor
has one or more infinite parts (same result is returned regardless of
the sign of the components).
Returns finite values in components of the result per the definitional formula in all remaining cases.
multiply in interface FieldElement<Complex>factor - value to be multiplied by this Complex.this * factor.NullArgumentException - if factor is null.public Complex multiply(int factor)
Complex whose value is this * factor, with factor
interpreted as a integer number.multiply in interface FieldElement<Complex>factor - value to be multiplied by this Complex.this * factor.multiply(Complex)public Complex multiply(double factor)
Complex whose value is this * factor, with factor
interpreted as a real number.multiply in interface CalculusFieldElement<Complex>factor - value to be multiplied by this Complex.this * factor.multiply(Complex)public Complex multiplyPlusI()
public Complex multiplyMinusI()
public Complex negate()
Complex whose value is (-this).
Returns NaN if either real or imaginary
part of this Complex number is Double.NaN.negate in interface FieldElement<Complex>-this.public Complex subtract(Complex subtrahend) throws NullArgumentException
Complex whose value is
(this - subtrahend).
Uses the definitional formula
(a + bi) - (c + di) = (a-c) + (b-d)i
this or subtrahend has a NaN] value in either part,
NaN is returned; otherwise infinite and NaN values are
returned in the parts of the result according to the rules for
Double arithmetic.subtract in interface FieldElement<Complex>subtrahend - value to be subtracted from this Complex.this - subtrahend.NullArgumentException - if subtrahend is null.public Complex subtract(double subtrahend)
Complex whose value is
(this - subtrahend).subtract in interface CalculusFieldElement<Complex>subtrahend - value to be subtracted from this Complex.this - subtrahend.subtract(Complex)public Complex acos()
acos(z) = -i (log(z + i (sqrt(1 - z<sup>2</sup>))))
NaN if either real or imaginary part of the
input argument is NaN or infinite.acos in interface CalculusFieldElement<Complex>public Complex asin()
asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz))
Returns NaN if either real or imaginary part of the
input argument is NaN or infinite.
asin in interface CalculusFieldElement<Complex>public Complex atan()
atan(z) = (i/2) log((1 - iz)/(1 + iz))
Returns NaN if either real or imaginary part of the
input argument is NaN or infinite.
atan in interface CalculusFieldElement<Complex>public Complex cos()
cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i
where the (real) functions on the right-hand side are
FastMath.sin(double), FastMath.cos(double),
FastMath.cosh(double) and FastMath.sinh(double).
Returns NaN if either real or imaginary part of the
input argument is NaN.
Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
Examples:
cos(1 ± INFINITY i) = 1 ∓ INFINITY i
cos(±INFINITY + i) = NaN + NaN i
cos(±INFINITY ± INFINITY i) = NaN + NaN i
cos in interface CalculusFieldElement<Complex>public Complex cosh()
cosh(a + bi) = cosh(a)cos(b) + sinh(a)sin(b)i
where the (real) functions on the right-hand side are
FastMath.sin(double), FastMath.cos(double),
FastMath.cosh(double) and FastMath.sinh(double).
Returns NaN if either real or imaginary part of the
input argument is NaN.
Examples:
cosh(1 ± INFINITY i) = NaN + NaN i
cosh(±INFINITY + i) = INFINITY ± INFINITY i
cosh(±INFINITY ± INFINITY i) = NaN + NaN i
cosh in interface CalculusFieldElement<Complex>public Complex exp()
exp(a + bi) = exp(a)cos(b) + exp(a)sin(b)i
where the (real) functions on the right-hand side are
FastMath.exp(double), FastMath.cos(double), and
FastMath.sin(double).
Returns NaN if either real or imaginary part of the
input argument is NaN.
Examples:
exp(1 ± INFINITY i) = NaN + NaN i
exp(INFINITY + i) = INFINITY + INFINITY i
exp(-INFINITY + i) = 0 + 0i
exp(±INFINITY ± INFINITY i) = NaN + NaN i
exp in interface CalculusFieldElement<Complex>ethis.public Complex expm1()
expm1 in interface CalculusFieldElement<Complex>public Complex log()
log(a + bi) = ln(|a + bi|) + arg(a + bi)i
where ln on the right hand side is FastMath.log(double),
|a + bi| is the modulus, abs(), and
arg(a + bi) = FastMath.atan2(double, double)(b, a).
Returns NaN if either real or imaginary part of the
input argument is NaN.
Examples:
log(1 ± INFINITY i) = INFINITY ± (π/2)i
log(INFINITY + i) = INFINITY + 0i
log(-INFINITY + i) = INFINITY + πi
log(INFINITY ± INFINITY i) = INFINITY ± (π/4)i
log(-INFINITY ± INFINITY i) = INFINITY ± (3π/4)i
log(0 + 0i) = -INFINITY + 0i
log in interface CalculusFieldElement<Complex>ln this, the natural logarithm
of this.public Complex log1p()
log1p in interface CalculusFieldElement<Complex>public Complex log10()
log10 in interface CalculusFieldElement<Complex>public Complex pow(Complex x) throws NullArgumentException
x.
If x is a real number whose real part has an integer value, returns pow(int),
if both this and x are real and FastMath.pow(double, double)
with the corresponding real arguments would return a finite number (neither NaN
nor infinite), then returns the same value converted to Complex,
with the same special cases.
In all other cases real cases, implements yx = exp(x·log(y)).
pow in interface CalculusFieldElement<Complex>x - exponent to which this Complex is to be raised. thisx.NullArgumentException - if x is null.public Complex pow(double x)
x.
If x has an integer value, returns pow(int),
if this is real and FastMath.pow(double, double)
with the corresponding real arguments would return a finite number (neither NaN
nor infinite), then returns the same value converted to Complex,
with the same special cases.
In all other cases real cases, implements yx = exp(x·log(y)).
pow in interface CalculusFieldElement<Complex>x - exponent to which this Complex is to be raised. thisx.public Complex pow(int n)
pow in interface CalculusFieldElement<Complex>n - power to applypublic Complex sin()
sin(a + bi) = sin(a)cosh(b) + cos(a)sinh(b)i
where the (real) functions on the right-hand side are
FastMath.sin(double), FastMath.cos(double),
FastMath.cosh(double) and FastMath.sinh(double).
Returns NaN if either real or imaginary part of the
input argument is NaN.
Infinite values in real or imaginary parts of the input may result in
infinite or NaN values returned in parts of the result.
Examples:
sin(1 ± INFINITY i) = 1 ± INFINITY i
sin(±INFINITY + i) = NaN + NaN i
sin(±INFINITY ± INFINITY i) = NaN + NaN i
sin in interface CalculusFieldElement<Complex>public FieldSinCos<Complex> sinCos()
sinCos in interface CalculusFieldElement<Complex>public Complex atan2(Complex x)
Beware of the order or arguments! As this is based on a
two-arguments functions, in order to be consistent with
arguments order, the instance is the first argument
and the single provided argument is the second argument.
In order to be consistent with programming languages atan2,
this method computes atan2(this, x), i.e. the instance
represents the y argument and the x argument is
the one passed as a single argument. This may seem confusing especially
for users of Wolfram alpha, as this site is not consistent
with programming languages atan2 two-arguments arc tangent
and puts x as its first argument.
atan2 in interface CalculusFieldElement<Complex>x - second argument of the arc tangentpublic Complex acosh()
Branch cuts are on the real axis, below +1.
acosh in interface CalculusFieldElement<Complex>public Complex asinh()
Branch cuts are on the imaginary axis, above +i and below -i.
asinh in interface CalculusFieldElement<Complex>public Complex atanh()
Branch cuts are on the real axis, above +1 and below -1.
atanh in interface CalculusFieldElement<Complex>public Complex sinh()
sinh(a + bi) = sinh(a)cos(b)) + cosh(a)sin(b)i
where the (real) functions on the right-hand side are
FastMath.sin(double), FastMath.cos(double),
FastMath.cosh(double) and FastMath.sinh(double).
Returns NaN if either real or imaginary part of the
input argument is NaN.
Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
Examples:
sinh(1 ± INFINITY i) = NaN + NaN i
sinh(±INFINITY + i) = ± INFINITY + INFINITY i
sinh(±INFINITY ± INFINITY i) = NaN + NaN i
sinh in interface CalculusFieldElement<Complex>this.public FieldSinhCosh<Complex> sinhCosh()
sinhCosh in interface CalculusFieldElement<Complex>public Complex sqrt()
sqrt(a + bi):
t = sqrt((|a| + |a + bi|) / 2)ifa ≥ 0returnt + (b/2t)ielse return|b|/2t + sign(b)t i
|a| = abs(a)|a + bi| = hypot(a, b)sign(b) = copySign(1, b)
Returns NaN if either real or imaginary part of the
input argument is NaN.
Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
Examples:
sqrt(1 ± ∞ i) = ∞ + NaN i
sqrt(∞ + i) = ∞ + 0i
sqrt(-∞ + i) = 0 + ∞ i
sqrt(∞ ± ∞ i) = ∞ + NaN i
sqrt(-∞ ± ∞ i) = NaN ± ∞ i
sqrt in interface CalculusFieldElement<Complex>this with nonnegative real part.public Complex sqrt1z()
1 - this2 for this complex
number.
Computes the result directly as
sqrt(ONE.subtract(z.multiply(z))).
Returns NaN if either real or imaginary part of the
input argument is NaN.
1 - this2.public Complex cbrt()
This implementation compute the principal cube root by using a branch cut along real negative axis.
cbrt in interface CalculusFieldElement<Complex>public Complex rootN(int n)
This implementation compute the principal nth root by using a branch cut along real negative axis.
rootN in interface CalculusFieldElement<Complex>n - order of the rootpublic Complex tan()
tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i
where the (real) functions on the right-hand side are
FastMath.sin(double), FastMath.cos(double), FastMath.cosh(double) and
FastMath.sinh(double).
Returns NaN if either real or imaginary part of the
input argument is NaN.
Examples:
tan(a ± INFINITY i) = 0 ± i
tan(±INFINITY + bi) = NaN + NaN i
tan(±INFINITY ± INFINITY i) = NaN + NaN i
tan(±π/2 + 0 i) = ±INFINITY + NaN i
tan in interface CalculusFieldElement<Complex>this.public Complex tanh()
tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i
where the (real) functions on the right-hand side are
FastMath.sin(double), FastMath.cos(double), FastMath.cosh(double) and
FastMath.sinh(double).
Returns NaN if either real or imaginary part of the
input argument is NaN.
Examples:
tanh(a ± INFINITY i) = NaN + NaN i
tanh(±INFINITY + bi) = ±1 + 0 i
tanh(±INFINITY ± INFINITY i) = NaN + NaN i
tanh(0 + (π/2)i) = NaN + INFINITY i
tanh in interface CalculusFieldElement<Complex>this.public double getArgument()
If either real or imaginary part (or both) is NaN, NaN is returned.
Infinite parts are handled as Math.atan2 handles them,
essentially treating finite parts as zero in the presence of an
infinite coordinate and returning a multiple of pi/4 depending on
the signs of the infinite parts.
See the javadoc for Math.atan2 for full details.
this.public List<Complex> nthRoot(int n) throws MathIllegalArgumentException
zk = abs1/n (cos(phi + 2πk/n) + i (sin(phi + 2πk/n))
for k=0, 1, ..., n-1, where abs and phi
are respectively the modulus and
argument of this complex number.
If one or both parts of this complex number is NaN, a list with just
one element, NaN is returned.
if neither part is NaN, but at least one part is infinite, the result
is a one-element list containing INF.
n - Degree of root.n-th roots of this.MathIllegalArgumentException - if n <= 0.protected Complex createComplex(double realPart, double imaginaryPart)
realPart - Real part.imaginaryPart - Imaginary part.valueOf(double, double)public static Complex valueOf(double realPart, double imaginaryPart)
realPart - Real part.imaginaryPart - Imaginary part.public static Complex valueOf(double realPart)
realPart - Real part.public Complex newInstance(double realPart)
newInstance in interface CalculusFieldElement<Complex>realPart - constant real valueprotected final Object readResolve()
createComplex(double, double) to
deserialize properly.public ComplexField getField()
Field to which the instance belongs.getField in interface FieldElement<Complex>Field to which the instance belongspublic Complex scalb(int n)
scalb in interface CalculusFieldElement<Complex>n - power of 2public Complex ulp()
ulp in interface CalculusFieldElement<Complex>public Complex hypot(Complex y)
this and y
- sqrt(this2 +y2)
avoiding intermediate overflow or underflow.
hypot in interface CalculusFieldElement<Complex>y - a valuepublic Complex linearCombination(Complex[] a, Complex[] b) throws MathIllegalArgumentException
linearCombination in interface CalculusFieldElement<Complex>a - Factors.b - Factors.Σi ai bi.MathIllegalArgumentException - if arrays dimensions don't matchpublic Complex linearCombination(double[] a, Complex[] b) throws MathIllegalArgumentException
linearCombination in interface CalculusFieldElement<Complex>a - Factors.b - Factors.Σi ai bi.MathIllegalArgumentException - if arrays dimensions don't matchpublic Complex linearCombination(Complex a1, Complex b1, Complex a2, Complex b2)
linearCombination in interface CalculusFieldElement<Complex>a1 - first factor of the first termb1 - second factor of the first terma2 - first factor of the second termb2 - second factor of the second termCalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement),
CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement)public Complex linearCombination(double a1, Complex b1, double a2, Complex b2)
linearCombination in interface CalculusFieldElement<Complex>a1 - first factor of the first termb1 - second factor of the first terma2 - first factor of the second termb2 - second factor of the second termCalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement, double, FieldElement),
CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement, double, FieldElement, double, FieldElement)public Complex linearCombination(Complex a1, Complex b1, Complex a2, Complex b2, Complex a3, Complex b3)
linearCombination in interface CalculusFieldElement<Complex>a1 - first factor of the first termb1 - second factor of the first terma2 - first factor of the second termb2 - second factor of the second terma3 - first factor of the third termb3 - second factor of the third termCalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement),
CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement)public Complex linearCombination(double a1, Complex b1, double a2, Complex b2, double a3, Complex b3)
linearCombination in interface CalculusFieldElement<Complex>a1 - first factor of the first termb1 - second factor of the first terma2 - first factor of the second termb2 - second factor of the second terma3 - first factor of the third termb3 - second factor of the third termCalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement),
CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement, double, FieldElement, double, FieldElement)public Complex linearCombination(Complex a1, Complex b1, Complex a2, Complex b2, Complex a3, Complex b3, Complex a4, Complex b4)
linearCombination in interface CalculusFieldElement<Complex>a1 - first factor of the first termb1 - second factor of the first terma2 - first factor of the second termb2 - second factor of the second terma3 - first factor of the third termb3 - second factor of the third terma4 - first factor of the fourth termb4 - second factor of the fourth termCalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement),
CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement)public Complex linearCombination(double a1, Complex b1, double a2, Complex b2, double a3, Complex b3, double a4, Complex b4)
linearCombination in interface CalculusFieldElement<Complex>a1 - first factor of the first termb1 - second factor of the first terma2 - first factor of the second termb2 - second factor of the second terma3 - first factor of the third termb3 - second factor of the third terma4 - first factor of the fourth termb4 - second factor of the fourth termCalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement),
CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement, double, FieldElement)public Complex getPi()
Archimedes constant is the ratio of a circle's circumference to its diameter.
getPi in interface CalculusFieldElement<Complex>public Complex ceil()
ceil in interface CalculusFieldElement<Complex>public Complex floor()
floor in interface CalculusFieldElement<Complex>public Complex rint()
rint in interface CalculusFieldElement<Complex>public Complex remainder(double a)
for complex numbers, the integer n corresponding to this.subtract(remainder(a)).divide(a)
is a Wikipedia - Gaussian integer.
remainder in interface CalculusFieldElement<Complex>a - right hand side parameter of the operatorpublic Complex remainder(Complex a)
for complex numbers, the integer n corresponding to this.subtract(remainder(a)).divide(a)
is a Wikipedia - Gaussian integer.
remainder in interface CalculusFieldElement<Complex>a - right hand side parameter of the operatorpublic Complex sign()
sign in interface CalculusFieldElement<Complex>public Complex copySign(Complex z)
sign argument is treated as positive.
The signs of real and imaginary parts are copied independently.
copySign in interface CalculusFieldElement<Complex>z - the sign for the returned valuesign argumentpublic Complex copySign(double r)
sign argument is treated as positive.copySign in interface CalculusFieldElement<Complex>r - the sign for the returned valuesign argumentpublic Complex toDegrees()
toDegrees in interface CalculusFieldElement<Complex>public Complex toRadians()
toRadians in interface CalculusFieldElement<Complex>Copyright © 2016-2022 CS GROUP. All rights reserved.