T
- the type of the field elementspublic class FieldComplex<T extends CalculusFieldElement<T>> extends Object implements CalculusFieldElement<FieldComplex<T>>
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 + NaNi
NaN + i
NaN + 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.
Constructor and Description |
---|
FieldComplex(T real)
Create a complex number given only the real part.
|
FieldComplex(T real,
T imaginary)
Create a complex number given the real and imaginary parts.
|
Modifier and Type | Method and Description |
---|---|
FieldComplex<T> |
abs()
Return the absolute value of this complex number.
|
FieldComplex<T> |
acos()
Compute the
inverse cosine of this complex number.
|
FieldComplex<T> |
acosh()
Inverse hyperbolic cosine operation.
|
FieldComplex<T> |
add(double addend)
Returns a
Complex whose value is (this + addend) ,
with addend interpreted as a real number. |
FieldComplex<T> |
add(FieldComplex<T> addend)
Returns a
Complex whose value is
(this + addend) . |
FieldComplex<T> |
add(T addend)
Returns a
Complex whose value is (this + addend) ,
with addend interpreted as a real number. |
FieldComplex<T> |
asin()
Compute the
inverse sine of this complex number.
|
FieldComplex<T> |
asinh()
Inverse hyperbolic sine operation.
|
FieldComplex<T> |
atan()
Compute the
inverse tangent of this complex number.
|
FieldComplex<T> |
atan2(FieldComplex<T> x)
Two arguments arc tangent operation.
|
FieldComplex<T> |
atanh()
Inverse hyperbolic tangent operation.
|
FieldComplex<T> |
cbrt()
Cubic root.
|
FieldComplex<T> |
ceil()
Get the smallest whole number larger than instance.
|
FieldComplex<T> |
conjugate()
Returns the conjugate of this complex number.
|
FieldComplex<T> |
copySign(double r)
Returns the instance with the sign of the argument.
|
FieldComplex<T> |
copySign(FieldComplex<T> z)
Returns the instance with the sign of the argument.
|
FieldComplex<T> |
cos()
Compute the
cosine of this complex number.
|
FieldComplex<T> |
cosh()
Compute the
hyperbolic cosine of this complex number.
|
protected FieldComplex<T> |
createComplex(T realPart,
T imaginaryPart)
Create a complex number given the real and imaginary parts.
|
FieldComplex<T> |
divide(double divisor)
Returns a
Complex whose value is (this / divisor) ,
with divisor interpreted as a real number. |
FieldComplex<T> |
divide(FieldComplex<T> divisor)
Returns a
Complex whose value is
(this / divisor) . |
FieldComplex<T> |
divide(T divisor)
Returns a
Complex whose value is (this / divisor) ,
with divisor interpreted as a real number. |
static <T extends CalculusFieldElement<T>> |
equals(FieldComplex<T> x,
FieldComplex<T> y)
Returns
true iff the values are equal as defined by
equals(x, y, 1) . |
static <T extends CalculusFieldElement<T>> |
equals(FieldComplex<T> x,
FieldComplex<T> y,
double eps)
Returns
true if, both for the real part and for the imaginary
part, there is no T value strictly between the arguments or the
difference between them is within the range of allowed error
(inclusive). |
static <T extends CalculusFieldElement<T>> |
equals(FieldComplex<T> x,
FieldComplex<T> y,
int maxUlps)
Test for the floating-point equality between Complex objects.
|
boolean |
equals(Object other)
Test for equality with another object.
|
static <T extends CalculusFieldElement<T>> |
equalsWithRelativeTolerance(FieldComplex<T> x,
FieldComplex<T> y,
double eps)
Returns
true if, both for the real part and for the imaginary
part, there is no T value strictly between the arguments or the
relative difference between them is smaller or equal to the given
tolerance. |
FieldComplex<T> |
exp()
Compute the
exponential function of this complex number.
|
FieldComplex<T> |
expm1()
Exponential minus 1.
|
FieldComplex<T> |
floor()
Get the largest whole number smaller than instance.
|
T |
getArgument()
Compute the argument of this complex number.
|
FieldComplexField<T> |
getField()
Get the
Field to which the instance belongs. |
static <T extends CalculusFieldElement<T>> |
getI(Field<T> field)
Get the square root of -1.
|
T |
getImaginary()
Access the imaginary part.
|
T |
getImaginaryPart()
Access the imaginary part.
|
static <T extends CalculusFieldElement<T>> |
getInf(Field<T> field)
Get a complex number representing "+INF + INFi".
|
static <T extends CalculusFieldElement<T>> |
getMinusI(Field<T> field)
Get the square root of -1.
|
static <T extends CalculusFieldElement<T>> |
getMinusOne(Field<T> field)
Get a complex number representing "-1.0 + 0.0i".
|
static <T extends CalculusFieldElement<T>> |
getNaN(Field<T> field)
Get a complex number representing "NaN + NaNi".
|
static <T extends CalculusFieldElement<T>> |
getOne(Field<T> field)
Get a complex number representing "1.0 + 0.0i".
|
Field<T> |
getPartsField()
Get the
Field the real and imaginary parts belong to. |
FieldComplex<T> |
getPi()
Get the Archimedes constant π.
|
static <T extends CalculusFieldElement<T>> |
getPi(Field<T> field)
Get a complex number representing "π + 0.0i".
|
double |
getReal()
Access the real part.
|
T |
getRealPart()
Access the real part.
|
static <T extends CalculusFieldElement<T>> |
getZero(Field<T> field)
Get a complex number representing "0.0 + 0.0i".
|
int |
hashCode()
Get a hashCode for the complex number.
|
FieldComplex<T> |
hypot(FieldComplex<T> 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.
|
FieldComplex<T> |
linearCombination(double[] a,
FieldComplex<T>[] b)
Compute a linear combination.
|
FieldComplex<T> |
linearCombination(double a1,
FieldComplex<T> b1,
double a2,
FieldComplex<T> b2)
Compute a linear combination.
|
FieldComplex<T> |
linearCombination(double a1,
FieldComplex<T> b1,
double a2,
FieldComplex<T> b2,
double a3,
FieldComplex<T> b3)
Compute a linear combination.
|
FieldComplex<T> |
linearCombination(double a1,
FieldComplex<T> b1,
double a2,
FieldComplex<T> b2,
double a3,
FieldComplex<T> b3,
double a4,
FieldComplex<T> b4)
Compute a linear combination.
|
FieldComplex<T> |
linearCombination(FieldComplex<T>[] a,
FieldComplex<T>[] b)
Compute a linear combination.
|
FieldComplex<T> |
linearCombination(FieldComplex<T> a1,
FieldComplex<T> b1,
FieldComplex<T> a2,
FieldComplex<T> b2)
Compute a linear combination.
|
FieldComplex<T> |
linearCombination(FieldComplex<T> a1,
FieldComplex<T> b1,
FieldComplex<T> a2,
FieldComplex<T> b2,
FieldComplex<T> a3,
FieldComplex<T> b3)
Compute a linear combination.
|
FieldComplex<T> |
linearCombination(FieldComplex<T> a1,
FieldComplex<T> b1,
FieldComplex<T> a2,
FieldComplex<T> b2,
FieldComplex<T> a3,
FieldComplex<T> b3,
FieldComplex<T> a4,
FieldComplex<T> b4)
Compute a linear combination.
|
FieldComplex<T> |
log()
Compute the
natural logarithm of this complex number.
|
FieldComplex<T> |
log10()
Base 10 logarithm.
|
FieldComplex<T> |
log1p()
Shifted natural logarithm.
|
FieldComplex<T> |
multiply(double factor)
Returns a
Complex whose value is this * factor , with factor
interpreted as a real number. |
FieldComplex<T> |
multiply(FieldComplex<T> factor)
Returns a
Complex whose value is this * factor . |
FieldComplex<T> |
multiply(int factor)
Returns a
Complex whose value is this * factor , with factor
interpreted as a integer number. |
FieldComplex<T> |
multiply(T factor)
Returns a
Complex whose value is this * factor , with factor
interpreted as a real number. |
FieldComplex<T> |
multiplyMinusI()
Compute this *- -i.
|
FieldComplex<T> |
multiplyPlusI()
Compute this * i.
|
FieldComplex<T> |
negate()
Returns a
Complex whose value is (-this) . |
FieldComplex<T> |
newInstance(double realPart)
Create an instance corresponding to a constant real value.
|
List<FieldComplex<T>> |
nthRoot(int n)
Computes the n-th roots of this complex number.
|
FieldComplex<T> |
pow(double x)
Returns of value of this complex number raised to the power of
x . |
FieldComplex<T> |
pow(FieldComplex<T> x)
Returns of value of this complex number raised to the power of
x . |
FieldComplex<T> |
pow(int n)
Integer power operation.
|
FieldComplex<T> |
pow(T x)
Returns of value of this complex number raised to the power of
x . |
FieldComplex<T> |
reciprocal()
Returns the multiplicative inverse of
this element. |
FieldComplex<T> |
remainder(double a)
IEEE remainder operator.
|
FieldComplex<T> |
remainder(FieldComplex<T> a)
IEEE remainder operator.
|
FieldComplex<T> |
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.
|
FieldComplex<T> |
rootN(int n)
Nth root.
|
FieldComplex<T> |
scalb(int n)
Multiply the instance by a power of 2.
|
FieldComplex<T> |
sign()
Compute the sign of the instance.
|
FieldComplex<T> |
sin()
Compute the
sine
of this complex number.
|
FieldSinCos<FieldComplex<T>> |
sinCos()
Combined Sine and Cosine operation.
|
FieldComplex<T> |
sinh()
Compute the
hyperbolic sine of this complex number.
|
FieldSinhCosh<FieldComplex<T>> |
sinhCosh()
Combined hyperbolic sine and sosine operation.
|
FieldComplex<T> |
sqrt()
Compute the
square root of this complex number.
|
FieldComplex<T> |
sqrt1z()
Compute the
square root of
1 - this2 for this complex
number. |
FieldComplex<T> |
subtract(double subtrahend)
Returns a
Complex whose value is
(this - subtrahend) . |
FieldComplex<T> |
subtract(FieldComplex<T> subtrahend)
Returns a
Complex whose value is
(this - subtrahend) . |
FieldComplex<T> |
subtract(T subtrahend)
Returns a
Complex whose value is
(this - subtrahend) . |
FieldComplex<T> |
tan()
Compute the
tangent of this complex number.
|
FieldComplex<T> |
tanh()
Compute the
hyperbolic tangent of this complex number.
|
FieldComplex<T> |
toDegrees()
Convert radians to degrees, with error of less than 0.5 ULP
|
FieldComplex<T> |
toRadians()
Convert degrees to radians, with error of less than 0.5 ULP
|
String |
toString() |
FieldComplex<T> |
ulp()
Compute least significant bit (Unit in Last Position) for a number.
|
static <T extends CalculusFieldElement<T>> |
valueOf(T realPart)
Create a complex number given only the real part.
|
static <T extends CalculusFieldElement<T>> |
valueOf(T realPart,
T imaginaryPart)
Create a complex number given the real and imaginary parts.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getExponent, isFinite, norm, round
public FieldComplex(T real)
real
- Real part.public static <T extends CalculusFieldElement<T>> FieldComplex<T> getI(Field<T> field)
T
- the type of the field elementsfield
- field the complex components belong topublic static <T extends CalculusFieldElement<T>> FieldComplex<T> getMinusI(Field<T> field)
T
- the type of the field elementsfield
- field the complex components belong topublic static <T extends CalculusFieldElement<T>> FieldComplex<T> getNaN(Field<T> field)
T
- the type of the field elementsfield
- field the complex components belong topublic static <T extends CalculusFieldElement<T>> FieldComplex<T> getInf(Field<T> field)
T
- the type of the field elementsfield
- field the complex components belong topublic static <T extends CalculusFieldElement<T>> FieldComplex<T> getOne(Field<T> field)
T
- the type of the field elementsfield
- field the complex components belong topublic static <T extends CalculusFieldElement<T>> FieldComplex<T> getMinusOne(Field<T> field)
T
- the type of the field elementsfield
- field the complex components belong topublic static <T extends CalculusFieldElement<T>> FieldComplex<T> getZero(Field<T> field)
T
- the type of the field elementsfield
- field the complex components belong topublic static <T extends CalculusFieldElement<T>> FieldComplex<T> getPi(Field<T> field)
T
- the type of the field elementsfield
- field the complex components belong topublic FieldComplex<T> 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<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> add(FieldComplex<T> 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, getNaN(Field)
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<FieldComplex<T extends CalculusFieldElement<T>>>
addend
- Value to be added to this Complex
.this + addend
.NullArgumentException
- if addend
is null
.public FieldComplex<T> add(T addend)
Complex
whose value is (this + addend)
,
with addend
interpreted as a real number.addend
- Value to be added to this Complex
.this + addend
.add(FieldComplex)
public FieldComplex<T> add(double addend)
Complex
whose value is (this + addend)
,
with addend
interpreted as a real number.add
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
addend
- Value to be added to this Complex
.this + addend
.add(FieldComplex)
public FieldComplex<T> conjugate()
a + bi
is a - bi
.
getNaN(Field)
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 FieldComplex<T> divide(FieldComplex<T> 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, getNaN(Field)
is returned.
divisor
equals getZero(Field)
, getNaN(Field)
is returned.
this
and divisor
are both infinite,
getNaN(Field)
is returned.
this
is finite (i.e., has no Infinite
or
NaN
parts) and divisor
is infinite (one or both parts
infinite), getZero(Field)
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<FieldComplex<T extends CalculusFieldElement<T>>>
divisor
- Value by which this Complex
is to be divided.this / divisor
.NullArgumentException
- if divisor
is null
.public FieldComplex<T> divide(T divisor)
Complex
whose value is (this / divisor)
,
with divisor
interpreted as a real number.divisor
- Value by which this Complex
is to be divided.this / divisor
.divide(FieldComplex)
public FieldComplex<T> divide(double divisor)
Complex
whose value is (this / divisor)
,
with divisor
interpreted as a real number.divide
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
divisor
- Value by which this Complex
is to be divided.this / divisor
.divide(FieldComplex)
public FieldComplex<T> reciprocal()
this
element.reciprocal
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
reciprocal
in interface FieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
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 <T extends CalculusFieldElement<T>> boolean equals(FieldComplex<T> x, FieldComplex<T> y, int maxUlps)
true
if both arguments are equal or within the
range of allowed error (inclusive).T
- the type of the field elementsx
- 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 <T extends CalculusFieldElement<T>> boolean equals(FieldComplex<T> x, FieldComplex<T> y)
true
iff the values are equal as defined by
equals(x, y, 1)
.T
- the type of the field elementsx
- First value (cannot be null
).y
- Second value (cannot be null
).true
if the values are equal.public static <T extends CalculusFieldElement<T>> boolean equals(FieldComplex<T> x, FieldComplex<T> y, double eps)
true
if, both for the real part and for the imaginary
part, there is no T 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.T
- the type of the field elementsx
- 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 <T extends CalculusFieldElement<T>> boolean equalsWithRelativeTolerance(FieldComplex<T> x, FieldComplex<T> y, double eps)
true
if, both for the real part and for the imaginary
part, there is no T 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.T
- the type of the field elementsx
- 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<FieldComplex<T extends CalculusFieldElement<T>>>
public T getImaginary()
public T getImaginaryPart()
public double getReal()
getReal
in interface FieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public T getRealPart()
public boolean isNaN()
NaN
.isNaN
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
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<FieldComplex<T extends CalculusFieldElement<T>>>
NaN
.public FieldComplex<T> multiply(FieldComplex<T> 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
getNaN(Field)
if either this
or factor
has one or
more NaN
parts.
Returns getInf(Field)
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<FieldComplex<T extends CalculusFieldElement<T>>>
factor
- value to be multiplied by this Complex
.this * factor
.NullArgumentException
- if factor
is null
.public FieldComplex<T> multiply(int factor)
Complex
whose value is this * factor
, with factor
interpreted as a integer number.multiply
in interface FieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
factor
- value to be multiplied by this Complex
.this * factor
.multiply(FieldComplex)
public FieldComplex<T> multiply(double factor)
Complex
whose value is this * factor
, with factor
interpreted as a real number.multiply
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
factor
- value to be multiplied by this Complex
.this * factor
.multiply(FieldComplex)
public FieldComplex<T> multiply(T factor)
Complex
whose value is this * factor
, with factor
interpreted as a real number.factor
- value to be multiplied by this Complex
.this * factor
.multiply(FieldComplex)
public FieldComplex<T> multiplyPlusI()
public FieldComplex<T> multiplyMinusI()
public FieldComplex<T> 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<FieldComplex<T extends CalculusFieldElement<T>>>
-this
.public FieldComplex<T> subtract(FieldComplex<T> 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,
getNaN(Field)
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<FieldComplex<T extends CalculusFieldElement<T>>>
subtrahend
- value to be subtracted from this Complex
.this - subtrahend
.NullArgumentException
- if subtrahend
is null
.public FieldComplex<T> subtract(double subtrahend)
Complex
whose value is
(this - subtrahend)
.subtract
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
subtrahend
- value to be subtracted from this Complex
.this - subtrahend
.subtract(FieldComplex)
public FieldComplex<T> subtract(T subtrahend)
Complex
whose value is
(this - subtrahend)
.subtrahend
- value to be subtracted from this Complex
.this - subtrahend
.subtract(FieldComplex)
public FieldComplex<T> acos()
acos(z) = -i (log(z + i (sqrt(1 - z<sup>2</sup>))))
getNaN(Field)
if either real or imaginary part of the
input argument is NaN
or infinite.acos
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> asin()
asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz))
Returns getNaN(Field)
if either real or imaginary part of the
input argument is NaN
or infinite.
asin
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> atan()
atan(z) = (i/2) log((1 - iz)/(1 + iz))
Returns getNaN(Field)
if either real or imaginary part of the
input argument is NaN
or infinite.
atan
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> 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 getNaN(Field)
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<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> 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 getNaN(Field)
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<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> 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 getNaN(Field)
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<FieldComplex<T extends CalculusFieldElement<T>>>
ethis
.public FieldComplex<T> expm1()
expm1
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> 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 getNaN(Field)
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<FieldComplex<T extends CalculusFieldElement<T>>>
ln this
, the natural logarithm
of this
.public FieldComplex<T> log1p()
log1p
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> log10()
log10
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> pow(FieldComplex<T> 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<FieldComplex<T extends CalculusFieldElement<T>>>
x
- exponent to which this Complex
is to be raised. thisx
.NullArgumentException
- if x is null
.public FieldComplex<T> pow(T 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)).
x
- exponent to which this Complex
is to be raised. thisx
.public FieldComplex<T> 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<FieldComplex<T extends CalculusFieldElement<T>>>
x
- exponent to which this Complex
is to be raised. thisx
.public FieldComplex<T> pow(int n)
pow
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
n
- power to applypublic FieldComplex<T> 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 getNaN(Field)
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<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldSinCos<FieldComplex<T>> sinCos()
sinCos
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> atan2(FieldComplex<T> 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<FieldComplex<T extends CalculusFieldElement<T>>>
x
- second argument of the arc tangentpublic FieldComplex<T> acosh()
Branch cuts are on the real axis, below +1.
acosh
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> asinh()
Branch cuts are on the imaginary axis, above +i and below -i.
asinh
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> atanh()
Branch cuts are on the real axis, above +1 and below -1.
atanh
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> 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 getNaN(Field)
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<FieldComplex<T extends CalculusFieldElement<T>>>
this
.public FieldSinhCosh<FieldComplex<T>> sinhCosh()
sinhCosh
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> sqrt()
sqrt(a + bi)
:
t = sqrt((|a| + |a + bi|) / 2)
ifa ≥ 0
returnt + (b/2t)i
else 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<FieldComplex<T extends CalculusFieldElement<T>>>
this
with nonnegative real part.public FieldComplex<T> sqrt1z()
1 - this2
for this complex
number.
Computes the result directly as
sqrt(ONE.subtract(z.multiply(z)))
.
Returns getNaN(Field)
if either real or imaginary part of the
input argument is NaN
.
1 - this2
.public FieldComplex<T> cbrt()
This implementation compute the principal cube root by using a branch cut along real negative axis.
cbrt
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> rootN(int n)
This implementation compute the principal nth root by using a branch cut along real negative axis.
rootN
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
n
- order of the rootpublic FieldComplex<T> 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 getNaN(Field)
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<FieldComplex<T extends CalculusFieldElement<T>>>
this
.public FieldComplex<T> 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 getNaN(Field)
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<FieldComplex<T extends CalculusFieldElement<T>>>
this
.public T 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<FieldComplex<T>> 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, getNaN(Field)
is returned.
if neither part is NaN, but at least one part is infinite, the result
is a one-element list containing getInf(Field)
.
n
- Degree of root.n
-th roots of this
.MathIllegalArgumentException
- if n <= 0
.protected FieldComplex<T> createComplex(T realPart, T imaginaryPart)
realPart
- Real part.imaginaryPart
- Imaginary part.valueOf(CalculusFieldElement, CalculusFieldElement)
public static <T extends CalculusFieldElement<T>> FieldComplex<T> valueOf(T realPart, T imaginaryPart)
T
- the type of the field elementsrealPart
- Real part.imaginaryPart
- Imaginary part.public static <T extends CalculusFieldElement<T>> FieldComplex<T> valueOf(T realPart)
T
- the type of the field elementsrealPart
- Real part.public FieldComplex<T> newInstance(double realPart)
newInstance
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
realPart
- constant real valuepublic FieldComplexField<T> getField()
Field
to which the instance belongs.getField
in interface FieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
Field
to which the instance belongspublic Field<T> getPartsField()
Field
the real and imaginary parts belong to.Field
the real and imaginary parts belong topublic FieldComplex<T> scalb(int n)
scalb
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
n
- power of 2public FieldComplex<T> ulp()
ulp
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> hypot(FieldComplex<T> y)
this
and y
- sqrt(this2 +y2)
avoiding intermediate overflow or underflow.
hypot
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
y
- a valuepublic FieldComplex<T> linearCombination(FieldComplex<T>[] a, FieldComplex<T>[] b) throws MathIllegalArgumentException
linearCombination
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
a
- Factors.b
- Factors.Σi ai bi
.MathIllegalArgumentException
- if arrays dimensions don't matchpublic FieldComplex<T> linearCombination(double[] a, FieldComplex<T>[] b) throws MathIllegalArgumentException
linearCombination
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
a
- Factors.b
- Factors.Σi ai bi
.MathIllegalArgumentException
- if arrays dimensions don't matchpublic FieldComplex<T> linearCombination(FieldComplex<T> a1, FieldComplex<T> b1, FieldComplex<T> a2, FieldComplex<T> b2)
linearCombination
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
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 FieldComplex<T> linearCombination(double a1, FieldComplex<T> b1, double a2, FieldComplex<T> b2)
linearCombination
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
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 FieldComplex<T> linearCombination(FieldComplex<T> a1, FieldComplex<T> b1, FieldComplex<T> a2, FieldComplex<T> b2, FieldComplex<T> a3, FieldComplex<T> b3)
linearCombination
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
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 FieldComplex<T> linearCombination(double a1, FieldComplex<T> b1, double a2, FieldComplex<T> b2, double a3, FieldComplex<T> b3)
linearCombination
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
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 FieldComplex<T> linearCombination(FieldComplex<T> a1, FieldComplex<T> b1, FieldComplex<T> a2, FieldComplex<T> b2, FieldComplex<T> a3, FieldComplex<T> b3, FieldComplex<T> a4, FieldComplex<T> b4)
linearCombination
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
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 FieldComplex<T> linearCombination(double a1, FieldComplex<T> b1, double a2, FieldComplex<T> b2, double a3, FieldComplex<T> b3, double a4, FieldComplex<T> b4)
linearCombination
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
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 FieldComplex<T> ceil()
ceil
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> floor()
floor
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> rint()
rint
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> 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<FieldComplex<T extends CalculusFieldElement<T>>>
a
- right hand side parameter of the operatorpublic FieldComplex<T> remainder(FieldComplex<T> a)
for complex numbers, the integer n corresponding to this.subtract(remainder(a)).divide(a)
is a Wikipedia - Gaussian integer.
remainder
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
a
- right hand side parameter of the operatorpublic FieldComplex<T> sign()
sign
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> copySign(FieldComplex<T> z)
sign
argument is treated as positive.
The signs of real and imaginary parts are copied independently.
copySign
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
z
- the sign for the returned valuesign
argumentpublic FieldComplex<T> copySign(double r)
sign
argument is treated as positive.copySign
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
r
- the sign for the returned valuesign
argumentpublic FieldComplex<T> toDegrees()
toDegrees
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> toRadians()
toRadians
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
public FieldComplex<T> getPi()
Archimedes constant is the ratio of a circle's circumference to its diameter.
getPi
in interface CalculusFieldElement<FieldComplex<T extends CalculusFieldElement<T>>>
Copyright © 2016-2021 CS GROUP. All rights reserved.