Class FieldComplex<T extends CalculusFieldElement<T>>
- java.lang.Object
-
- org.hipparchus.complex.FieldComplex<T>
-
- Type Parameters:
T- the type of the field elements
- All Implemented Interfaces:
CalculusFieldElement<FieldComplex<T>>,FieldElement<FieldComplex<T>>
public class FieldComplex<T extends CalculusFieldElement<T>> extends Object implements CalculusFieldElement<FieldComplex<T>>
Representation of a Complex number, i.e. a number which has both a real and imaginary part.Implementations of arithmetic operations handle
NaNand infinite values according to the rules forDouble, i.e.equals(java.lang.Object)is an equivalence relation for all instances that have aNaNin 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 == xmust fail ifxisNaN). The methodequals for primitive doubleinPrecisionconforms with IEEE-754 while this class conforms with the standard behavior for Java object types.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 aComplexwhose value is(this + addend), withaddendinterpreted as a real number.FieldComplex<T>add(FieldComplex<T> addend)Returns aComplexwhose value is(this + addend).FieldComplex<T>add(T addend)Returns aComplexwhose value is(this + addend), withaddendinterpreted 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 aComplexwhose value is(this / divisor), withdivisorinterpreted as a real number.FieldComplex<T>divide(FieldComplex<T> divisor)Returns aComplexwhose value is(this / divisor).FieldComplex<T>divide(T divisor)Returns aComplexwhose value is(this / divisor), withdivisorinterpreted as a real number.booleanequals(Object other)Test for equality with another object.static <T extends CalculusFieldElement<T>>
booleanequals(FieldComplex<T> x, FieldComplex<T> y)Returnstrueiff the values are equal as defined byequals(x, y, 1).static <T extends CalculusFieldElement<T>>
booleanequals(FieldComplex<T> x, FieldComplex<T> y, double eps)Returnstrueif, 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>>
booleanequals(FieldComplex<T> x, FieldComplex<T> y, int maxUlps)Test for the floating-point equality between Complex objects.static <T extends CalculusFieldElement<T>>
booleanequalsWithRelativeTolerance(FieldComplex<T> x, FieldComplex<T> y, double eps)Returnstrueif, 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.FieldComplex<T>getAddendum()Get the addendum to the real value of the number.TgetArgument()Compute the argument of this complex number.FieldComplexField<T>getField()Get theFieldto which the instance belongs.static <T extends CalculusFieldElement<T>>
FieldComplex<T>getI(Field<T> field)Get the square root of -1.TgetImaginary()Access the imaginary part.TgetImaginaryPart()Access the imaginary part.static <T extends CalculusFieldElement<T>>
FieldComplex<T>getInf(Field<T> field)Get a complex number representing "+INF + INFi".static <T extends CalculusFieldElement<T>>
FieldComplex<T>getMinusI(Field<T> field)Get the square root of -1.static <T extends CalculusFieldElement<T>>
FieldComplex<T>getMinusOne(Field<T> field)Get a complex number representing "-1.0 + 0.0i".static <T extends CalculusFieldElement<T>>
FieldComplex<T>getNaN(Field<T> field)Get a complex number representing "NaN + NaNi".static <T extends CalculusFieldElement<T>>
FieldComplex<T>getOne(Field<T> field)Get a complex number representing "1.0 + 0.0i".Field<T>getPartsField()Get theFieldthe real and imaginary parts belong to.FieldComplex<T>getPi()Get the Archimedes constant π.static <T extends CalculusFieldElement<T>>
FieldComplex<T>getPi(Field<T> field)Get a complex number representing "π + 0.0i".doublegetReal()Access the real part.TgetRealPart()Access the real part.static <T extends CalculusFieldElement<T>>
FieldComplex<T>getZero(Field<T> field)Get a complex number representing "0.0 + 0.0i".inthashCode()Get a hashCode for the complex number.FieldComplex<T>hypot(FieldComplex<T> y)Returns the hypotenuse of a triangle with sidesthisandy- sqrt(this2 +y2) avoiding intermediate overflow or underflow.booleanisInfinite()Checks whether either the real or imaginary part of this complex number takes an infinite value (eitherDouble.POSITIVE_INFINITYorDouble.NEGATIVE_INFINITY) and neither part isNaN.booleanisMathematicalInteger()Check whether the instance is an integer (i.e. imaginary part is zero and real part has no fractional part).booleanisNaN()Checks whether either or both parts of this complex number isNaN.booleanisReal()Check whether the instance is real (i.e. imaginary part is zero).booleanisZero()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 aComplexwhose value isthis * factor, withfactorinterpreted as a real number.FieldComplex<T>multiply(int factor)Returns aComplexwhose value isthis * factor, withfactorinterpreted as a integer number.FieldComplex<T>multiply(FieldComplex<T> factor)Returns aComplexwhose value isthis * factor.FieldComplex<T>multiply(T factor)Returns aComplexwhose value isthis * factor, withfactorinterpreted as a real number.FieldComplex<T>multiplyMinusI()Compute this *- -i.FieldComplex<T>multiplyPlusI()Compute this * i.FieldComplex<T>negate()Returns aComplexwhose 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 ofx.FieldComplex<T>pow(int n)Integer power operation.FieldComplex<T>pow(FieldComplex<T> x)Returns of value of this complex number raised to the power ofx.FieldComplex<T>pow(T x)Returns of value of this complex number raised to the power ofx.FieldComplex<T>reciprocal()Returns the multiplicative inverse ofthiselement.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 cosine operation.FieldComplex<T>sqrt()Compute the square root of this complex number.FieldComplex<T>sqrt1z()Compute the square root of1 - this2for this complex number.FieldComplex<T>square()Compute this × this.FieldComplex<T>subtract(double subtrahend)Returns aComplexwhose value is(this - subtrahend).FieldComplex<T>subtract(FieldComplex<T> subtrahend)Returns aComplexwhose value is(this - subtrahend).FieldComplex<T>subtract(T subtrahend)Returns aComplexwhose 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 ULPFieldComplex<T>toRadians()Convert degrees to radians, with error of less than 0.5 ULPStringtoString()FieldComplex<T>ulp()Compute least significant bit (Unit in Last Position) for a number.static <T extends CalculusFieldElement<T>>
FieldComplex<T>valueOf(T realPart)Create a complex number given only the real part.static <T extends CalculusFieldElement<T>>
FieldComplex<T>valueOf(T realPart, T imaginaryPart)Create a complex number given the real and imaginary parts.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.hipparchus.CalculusFieldElement
getExponent, isFinite, norm, round
-
-
-
-
Constructor Detail
-
FieldComplex
public FieldComplex(T real)
Create a complex number given only the real part.- Parameters:
real- Real part.
-
-
Method Detail
-
getI
public static <T extends CalculusFieldElement<T>> FieldComplex<T> getI(Field<T> field)
Get the square root of -1.- Type Parameters:
T- the type of the field elements- Parameters:
field- field the complex components belong to- Returns:
- number representing "0.0 + 1.0i"
-
getMinusI
public static <T extends CalculusFieldElement<T>> FieldComplex<T> getMinusI(Field<T> field)
Get the square root of -1.- Type Parameters:
T- the type of the field elements- Parameters:
field- field the complex components belong to- Returns:
- number representing "0.0 _ 1.0i"
-
getNaN
public static <T extends CalculusFieldElement<T>> FieldComplex<T> getNaN(Field<T> field)
Get a complex number representing "NaN + NaNi".- Type Parameters:
T- the type of the field elements- Parameters:
field- field the complex components belong to- Returns:
- complex number representing "NaN + NaNi"
-
getInf
public static <T extends CalculusFieldElement<T>> FieldComplex<T> getInf(Field<T> field)
Get a complex number representing "+INF + INFi".- Type Parameters:
T- the type of the field elements- Parameters:
field- field the complex components belong to- Returns:
- complex number representing "+INF + INFi"
-
getOne
public static <T extends CalculusFieldElement<T>> FieldComplex<T> getOne(Field<T> field)
Get a complex number representing "1.0 + 0.0i".- Type Parameters:
T- the type of the field elements- Parameters:
field- field the complex components belong to- Returns:
- complex number representing "1.0 + 0.0i"
-
getMinusOne
public static <T extends CalculusFieldElement<T>> FieldComplex<T> getMinusOne(Field<T> field)
Get a complex number representing "-1.0 + 0.0i".- Type Parameters:
T- the type of the field elements- Parameters:
field- field the complex components belong to- Returns:
- complex number representing "-1.0 + 0.0i"
-
getZero
public static <T extends CalculusFieldElement<T>> FieldComplex<T> getZero(Field<T> field)
Get a complex number representing "0.0 + 0.0i".- Type Parameters:
T- the type of the field elements- Parameters:
field- field the complex components belong to- Returns:
- complex number representing "0.0 + 0.0i
-
getPi
public static <T extends CalculusFieldElement<T>> FieldComplex<T> getPi(Field<T> field)
Get a complex number representing "π + 0.0i".- Type Parameters:
T- the type of the field elements- Parameters:
field- field the complex components belong to- Returns:
- complex number representing "π + 0.0i
-
abs
public FieldComplex<T> abs()
Return the absolute value of this complex number. ReturnsNaNif either real or imaginary part isNaNandDouble.POSITIVE_INFINITYif neither part isNaN, but at least one part is infinite.- Specified by:
absin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the absolute value.
-
add
public FieldComplex<T> add(FieldComplex<T> addend) throws NullArgumentException
Returns aComplexwhose value is(this + addend). Uses the definitional formula
If either(a + bi) + (c + di) = (a+c) + (b+d)ithisoraddendhas aNaNvalue in either part,getNaN(Field)is returned; otherwiseInfiniteandNaNvalues are returned in the parts of the result according to the rules forDoublearithmetic.- Specified by:
addin interfaceFieldElement<T extends CalculusFieldElement<T>>- Parameters:
addend- Value to be added to thisComplex.- Returns:
this + addend.- Throws:
NullArgumentException- ifaddendisnull.
-
add
public FieldComplex<T> add(T addend)
Returns aComplexwhose value is(this + addend), withaddendinterpreted as a real number.- Parameters:
addend- Value to be added to thisComplex.- Returns:
this + addend.- See Also:
add(FieldComplex)
-
add
public FieldComplex<T> add(double addend)
Returns aComplexwhose value is(this + addend), withaddendinterpreted as a real number.- Specified by:
addin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
addend- Value to be added to thisComplex.- Returns:
this + addend.- See Also:
add(FieldComplex)
-
conjugate
public FieldComplex<T> conjugate()
Returns the conjugate of this complex number. The conjugate ofa + biisa - bi.getNaN(Field)is returned if either the real or imaginary part of this Complex number equalsDouble.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 of1 + POSITIVE_INFINITY iis1 - NEGATIVE_INFINITY i.- Returns:
- the conjugate of this Complex object.
-
divide
public FieldComplex<T> divide(FieldComplex<T> divisor) throws NullArgumentException
Returns aComplexwhose value is(this / divisor). Implements the definitional formula
but uses prescaling of operands to limit the effects of overflows and underflows in the computation.a + bi ac + bd + (bc - ad)i ----------- = ------------------------- c + di c2 + d2InfiniteandNaNvalues are handled according to the following rules, applied in the order presented:- If either
thisordivisorhas aNaNvalue in either part,getNaN(Field)is returned. - If
divisorequalsgetZero(Field),getNaN(Field)is returned. - If
thisanddivisorare both infinite,getNaN(Field)is returned. - If
thisis finite (i.e., has noInfiniteorNaNparts) anddivisoris infinite (one or both parts infinite),getZero(Field)is returned. - If
thisis infinite anddivisoris finite,NaNvalues are returned in the parts of the result if theDoublerules applied to the definitional formula forceNaNresults.
- Specified by:
dividein interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Specified by:
dividein interfaceFieldElement<T extends CalculusFieldElement<T>>- Parameters:
divisor- Value by which thisComplexis to be divided.- Returns:
this / divisor.- Throws:
NullArgumentException- ifdivisorisnull.
- If either
-
divide
public FieldComplex<T> divide(T divisor)
Returns aComplexwhose value is(this / divisor), withdivisorinterpreted as a real number.- Parameters:
divisor- Value by which thisComplexis to be divided.- Returns:
this / divisor.- See Also:
divide(FieldComplex)
-
divide
public FieldComplex<T> divide(double divisor)
Returns aComplexwhose value is(this / divisor), withdivisorinterpreted as a real number.- Specified by:
dividein interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
divisor- Value by which thisComplexis to be divided.- Returns:
this / divisor.- See Also:
divide(FieldComplex)
-
reciprocal
public FieldComplex<T> reciprocal()
Returns the multiplicative inverse ofthiselement.- Specified by:
reciprocalin interfaceFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the inverse of
this.
-
equals
public boolean equals(Object other)
Test for equality with another object. If both the real and imaginary parts of two complex numbers are exactly the same, and neither isDouble.NaN, the two Complex objects are considered to be equal. The behavior is the same as for JDK'sDouble:- All
NaNvalues are considered to be equal, i.e, if either (or both) real and imaginary parts of the complex number are equal toDouble.NaN, the complex number is equal toNaN. - Instances constructed with different representations of zero (i.e. either "0" or "-0") are not considered to be equal.
- All
-
equals
public static <T extends CalculusFieldElement<T>> boolean equals(FieldComplex<T> x, FieldComplex<T> y, int maxUlps)
Test for the floating-point equality between Complex objects. It returnstrueif both arguments are equal or within the range of allowed error (inclusive).- Type Parameters:
T- the type of the field elements- Parameters:
x- First value (cannot benull).y- Second value (cannot benull).maxUlps-(maxUlps - 1)is the number of floating point values between the real (resp. imaginary) parts ofxandy.- Returns:
trueif there are fewer thanmaxUlpsfloating point values between the real (resp. imaginary) parts ofxandy.- See Also:
Precision.equals(double,double,int)
-
equals
public static <T extends CalculusFieldElement<T>> boolean equals(FieldComplex<T> x, FieldComplex<T> y)
Returnstrueiff the values are equal as defined byequals(x, y, 1).- Type Parameters:
T- the type of the field elements- Parameters:
x- First value (cannot benull).y- Second value (cannot benull).- Returns:
trueif the values are equal.
-
equals
public static <T extends CalculusFieldElement<T>> boolean equals(FieldComplex<T> x, FieldComplex<T> y, double eps)
Returnstrueif, 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). Returnsfalseif either of the arguments is NaN.- Type Parameters:
T- the type of the field elements- Parameters:
x- First value (cannot benull).y- Second value (cannot benull).eps- Amount of allowed absolute error.- Returns:
trueif the values are two adjacent floating point numbers or they are within range of each other.- See Also:
Precision.equals(double,double,double)
-
equalsWithRelativeTolerance
public static <T extends CalculusFieldElement<T>> boolean equalsWithRelativeTolerance(FieldComplex<T> x, FieldComplex<T> y, double eps)
Returnstrueif, 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. Returnsfalseif either of the arguments is NaN.- Type Parameters:
T- the type of the field elements- Parameters:
x- First value (cannot benull).y- Second value (cannot benull).eps- Amount of allowed relative error.- Returns:
trueif the values are two adjacent floating point numbers or they are within range of each other.- See Also:
Precision.equalsWithRelativeTolerance(double,double,double)
-
hashCode
public int hashCode()
Get a hashCode for the complex number. AnyDouble.NaNvalue in real or imaginary part produces the same hash code7.
-
isZero
public boolean isZero()
Check if an element is semantically equal to zero.The default implementation simply calls
equals(getField().getZero()). However, this may need to be overridden in some cases as due to compatibility withhashCode()some classes implementsequals(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.
- Specified by:
isZeroin interfaceFieldElement<T extends CalculusFieldElement<T>>- Returns:
- true if the element is semantically equal to zero
-
getImaginary
public T getImaginary()
Access the imaginary part.- Returns:
- the imaginary part.
-
getImaginaryPart
public T getImaginaryPart()
Access the imaginary part.- Returns:
- the imaginary part.
-
getReal
public double getReal()
Access the real part.- Specified by:
getRealin interfaceFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the real part.
-
getAddendum
public FieldComplex<T> getAddendum()
Get the addendum to the real value of the number.The addendum is considered to be the part that when added back to the
real partrecovers the instance. This means that whene.getReal()is finite (i.e. neither infinite nor NaN), thene.getAddendum().add(e.getReal())iseande.subtract(e.getReal())ise.getAddendum(). Beware that for non-finite numbers, these two equalities may not hold. The first equality (with the addition), always holds even for infinity and NaNs if the real part is independent of the addendum (this is the case for all derivatives types, as well as for complex and Dfp, but it is not the case for Tuple and FieldTuple). The second equality (with the subtraction), generally doesn't hold for non-finite numbers, because the subtraction generates NaNs.- Specified by:
getAddendumin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- real value
-
getRealPart
public T getRealPart()
Access the real part.- Returns:
- the real part.
-
isNaN
public boolean isNaN()
Checks whether either or both parts of this complex number isNaN.- Specified by:
isNaNin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- true if either or both parts of this complex number is
NaN; false otherwise.
-
isReal
public boolean isReal()
Check whether the instance is real (i.e. imaginary part is zero).- Returns:
- true if imaginary part is zero
-
isMathematicalInteger
public boolean isMathematicalInteger()
Check whether the instance is an integer (i.e. imaginary part is zero and real part has no fractional part).- Returns:
- true if imaginary part is zero and real part has no fractional part
-
isInfinite
public boolean isInfinite()
Checks whether either the real or imaginary part of this complex number takes an infinite value (eitherDouble.POSITIVE_INFINITYorDouble.NEGATIVE_INFINITY) and neither part isNaN.- Specified by:
isInfinitein interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- true if one or both parts of this complex number are infinite
and neither part is
NaN.
-
multiply
public FieldComplex<T> multiply(FieldComplex<T> factor) throws NullArgumentException
Returns aComplexwhose value isthis * factor. Implements preliminary checks forNaNand infinity followed by the definitional formula:
Returns(a + bi)(c + di) = (ac - bd) + (ad + bc)igetNaN(Field)if eitherthisorfactorhas one or moreNaNparts.Returns
getInf(Field)if neitherthisnorfactorhas one or moreNaNparts and if eitherthisorfactorhas 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.
- Specified by:
multiplyin interfaceFieldElement<T extends CalculusFieldElement<T>>- Parameters:
factor- value to be multiplied by thisComplex.- Returns:
this * factor.- Throws:
NullArgumentException- iffactorisnull.
-
multiply
public FieldComplex<T> multiply(int factor)
Returns aComplexwhose value isthis * factor, withfactorinterpreted as a integer number.- Specified by:
multiplyin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Specified by:
multiplyin interfaceFieldElement<T extends CalculusFieldElement<T>>- Parameters:
factor- value to be multiplied by thisComplex.- Returns:
this * factor.- See Also:
multiply(FieldComplex)
-
multiply
public FieldComplex<T> multiply(double factor)
Returns aComplexwhose value isthis * factor, withfactorinterpreted as a real number.- Specified by:
multiplyin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
factor- value to be multiplied by thisComplex.- Returns:
this * factor.- See Also:
multiply(FieldComplex)
-
multiply
public FieldComplex<T> multiply(T factor)
Returns aComplexwhose value isthis * factor, withfactorinterpreted as a real number.- Parameters:
factor- value to be multiplied by thisComplex.- Returns:
this * factor.- See Also:
multiply(FieldComplex)
-
multiplyPlusI
public FieldComplex<T> multiplyPlusI()
Compute this * i.- Returns:
- this * i
- Since:
- 2.0
-
multiplyMinusI
public FieldComplex<T> multiplyMinusI()
Compute this *- -i.- Returns:
- this * i
- Since:
- 2.0
-
square
public FieldComplex<T> square()
Description copied from interface:CalculusFieldElementCompute this × this.- Specified by:
squarein interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- a new element representing this × this
-
negate
public FieldComplex<T> negate()
Returns aComplexwhose value is(-this). ReturnsNaNif either real or imaginary part of this Complex number isDouble.NaN.- Specified by:
negatein interfaceFieldElement<T extends CalculusFieldElement<T>>- Returns:
-this.
-
subtract
public FieldComplex<T> subtract(FieldComplex<T> subtrahend) throws NullArgumentException
Returns aComplexwhose value is(this - subtrahend). Uses the definitional formula
If either(a + bi) - (c + di) = (a-c) + (b-d)ithisorsubtrahendhas aNaN]value in either part,getNaN(Field)is returned; otherwise infinite andNaNvalues are returned in the parts of the result according to the rules forDoublearithmetic.- Specified by:
subtractin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Specified by:
subtractin interfaceFieldElement<T extends CalculusFieldElement<T>>- Parameters:
subtrahend- value to be subtracted from thisComplex.- Returns:
this - subtrahend.- Throws:
NullArgumentException- ifsubtrahendisnull.
-
subtract
public FieldComplex<T> subtract(double subtrahend)
Returns aComplexwhose value is(this - subtrahend).- Specified by:
subtractin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
subtrahend- value to be subtracted from thisComplex.- Returns:
this - subtrahend.- See Also:
subtract(FieldComplex)
-
subtract
public FieldComplex<T> subtract(T subtrahend)
Returns aComplexwhose value is(this - subtrahend).- Parameters:
subtrahend- value to be subtracted from thisComplex.- Returns:
this - subtrahend.- See Also:
subtract(FieldComplex)
-
acos
public FieldComplex<T> acos()
Compute the inverse cosine of this complex number. Implements the formula:
Returnsacos(z) = -i (log(z + i (sqrt(1 - z<sup>2</sup>))))getNaN(Field)if either real or imaginary part of the input argument isNaNor infinite.- Specified by:
acosin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the inverse cosine of this complex number.
-
asin
public FieldComplex<T> asin()
Compute the inverse sine of this complex number. Implements the formula:asin(z) = -i (log(sqrt(1 - z<sup>2</sup>) + iz))Returns
getNaN(Field)if either real or imaginary part of the input argument isNaNor infinite.- Specified by:
asinin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the inverse sine of this complex number.
-
atan
public FieldComplex<T> atan()
Compute the inverse tangent of this complex number. Implements the formula:atan(z) = (i/2) log((1 - iz)/(1 + iz))Returns
getNaN(Field)if either real or imaginary part of the input argument isNaNor infinite.- Specified by:
atanin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the inverse tangent of this complex number
-
cos
public FieldComplex<T> cos()
Compute the cosine of this complex number. Implements the formula:cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)iwhere the (real) functions on the right-hand side are
FastMath.sin(double),FastMath.cos(double),FastMath.cosh(double)andFastMath.sinh(double).Returns
getNaN(Field)if either real or imaginary part of the input argument isNaN.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- Specified by:
cosin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the cosine of this complex number.
-
cosh
public FieldComplex<T> cosh()
Compute the hyperbolic cosine of this complex number. Implements the formula:
where the (real) functions on the right-hand side arecosh(a + bi) = cosh(a)cos(b) + sinh(a)sin(b)iFastMath.sin(double),FastMath.cos(double),FastMath.cosh(double)andFastMath.sinh(double).Returns
Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.getNaN(Field)if either real or imaginary part of the input argument isNaN.Examples:
cosh(1 ± INFINITY i) = NaN + NaN i cosh(±INFINITY + i) = INFINITY ± INFINITY i cosh(±INFINITY ± INFINITY i) = NaN + NaN i- Specified by:
coshin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the hyperbolic cosine of this complex number.
-
exp
public FieldComplex<T> exp()
Compute the exponential function of this complex number. Implements the formula:
where the (real) functions on the right-hand side areexp(a + bi) = exp(a)cos(b) + exp(a)sin(b)iFastMath.exp(CalculusFieldElement)p},FastMath.cos(CalculusFieldElement), andFastMath.sin(CalculusFieldElement).Returns
Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.getNaN(Field)if either real or imaginary part of the input argument isNaN.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- Specified by:
expin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
ethis.
-
expm1
public FieldComplex<T> expm1()
Exponential minus 1.- Specified by:
expm1in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- exponential minus one of the instance
-
log
public FieldComplex<T> log()
Compute the natural logarithm of this complex number. Implements the formula:
where ln on the right hand side islog(a + bi) = ln(|a + bi|) + arg(a + bi)iFastMath.log(CalculusFieldElement),|a + bi|is the modulus,abs(), andarg(a + bi) =FastMath.atan2(double, double)(b, a).Returns
Infinite (or critical) values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.getNaN(Field)if either real or imaginary part of the input argument isNaN.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- Specified by:
login interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the value
ln this, the natural logarithm ofthis.
-
log1p
public FieldComplex<T> log1p()
Shifted natural logarithm.- Specified by:
log1pin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- logarithm of one plus the instance
-
log10
public FieldComplex<T> log10()
Base 10 logarithm.- Specified by:
log10in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- base 10 logarithm of the instance
-
pow
public FieldComplex<T> pow(FieldComplex<T> x) throws NullArgumentException
Returns of value of this complex number raised to the power ofx.If
xis a real number whose real part has an integer value, returnspow(int), if boththisandxare real andFastMath.pow(double, double)with the corresponding real arguments would return a finite number (neither NaN nor infinite), then returns the same value converted toComplex, with the same special cases. In all other cases real cases, implements yx = exp(x·log(y)).- Specified by:
powin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
x- exponent to which thisComplexis to be raised.- Returns:
thisx.- Throws:
NullArgumentException- if x isnull.
-
pow
public FieldComplex<T> pow(T x)
Returns of value of this complex number raised to the power ofx.If
xhas an integer value, returnspow(int), ifthisis real andFastMath.pow(double, double)with the corresponding real arguments would return a finite number (neither NaN nor infinite), then returns the same value converted toComplex, with the same special cases. In all other cases real cases, implements yx = exp(x·log(y)).- Parameters:
x- exponent to which thisComplexis to be raised.- Returns:
thisx.
-
pow
public FieldComplex<T> pow(double x)
Returns of value of this complex number raised to the power ofx.If
xhas an integer value, returnspow(int), ifthisis real andFastMath.pow(double, double)with the corresponding real arguments would return a finite number (neither NaN nor infinite), then returns the same value converted toComplex, with the same special cases. In all other cases real cases, implements yx = exp(x·log(y)).- Specified by:
powin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
x- exponent to which thisComplexis to be raised.- Returns:
thisx.
-
pow
public FieldComplex<T> pow(int n)
Integer power operation.- Specified by:
powin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
n- power to apply- Returns:
- thisn
-
sin
public FieldComplex<T> sin()
Compute the sine of this complex number. Implements the formula:
where the (real) functions on the right-hand side aresin(a + bi) = sin(a)cosh(b) + cos(a)sinh(b)iFastMath.sin(double),FastMath.cos(double),FastMath.cosh(double)andFastMath.sinh(double).Returns
getNaN(Field)if either real or imaginary part of the input argument isNaN.Infinite values in real or imaginary parts of the input may result in infinite or
NaNvalues 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- Specified by:
sinin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the sine of this complex number.
-
sinCos
public FieldSinCos<FieldComplex<T>> sinCos()
Combined Sine and Cosine operation.- Specified by:
sinCosin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- [sin(this), cos(this)]
-
atan2
public FieldComplex<T> atan2(FieldComplex<T> x)
Two arguments arc tangent operation.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 computesatan2(this, x), i.e. the instance represents theyargument and thexargument 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 languagesatan2two-arguments arc tangent and putsxas its first argument.- Specified by:
atan2in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
x- second argument of the arc tangent- Returns:
- atan2(this, x)
-
acosh
public FieldComplex<T> acosh()
Inverse hyperbolic cosine operation.Branch cuts are on the real axis, below +1.
- Specified by:
acoshin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- acosh(this)
-
asinh
public FieldComplex<T> asinh()
Inverse hyperbolic sine operation.Branch cuts are on the imaginary axis, above +i and below -i.
- Specified by:
asinhin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- asin(this)
-
atanh
public FieldComplex<T> atanh()
Inverse hyperbolic tangent operation.Branch cuts are on the real axis, above +1 and below -1.
- Specified by:
atanhin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- atanh(this)
-
sinh
public FieldComplex<T> sinh()
Compute the hyperbolic sine of this complex number. Implements the formula:
where the (real) functions on the right-hand side aresinh(a + bi) = sinh(a)cos(b)) + cosh(a)sin(b)iFastMath.sin(double),FastMath.cos(double),FastMath.cosh(double)andFastMath.sinh(double).Returns
getNaN(Field)if either real or imaginary part of the input argument isNaN.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- Specified by:
sinhin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the hyperbolic sine of
this.
-
sinhCosh
public FieldSinhCosh<FieldComplex<T>> sinhCosh()
Combined hyperbolic sine and cosine operation.- Specified by:
sinhCoshin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- [sinh(this), cosh(this)]
-
sqrt
public FieldComplex<T> sqrt()
Compute the square root of this complex number. Implements the following algorithm to computesqrt(a + bi):- Let
t = sqrt((|a| + |a + bi|) / 2) if
a ≥ 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
NaNif either real or imaginary part of the input argument isNaN.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- Specified by:
sqrtin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the square root of
thiswith nonnegative real part.
- Let
-
sqrt1z
public FieldComplex<T> sqrt1z()
Compute the square root of1 - this2for this complex number. Computes the result directly assqrt(ONE.subtract(z.square())).Returns
Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.getNaN(Field)if either real or imaginary part of the input argument isNaN.- Returns:
- the square root of
1 - this2.
-
cbrt
public FieldComplex<T> cbrt()
Cubic root.This implementation compute the principal cube root by using a branch cut along real negative axis.
- Specified by:
cbrtin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- cubic root of the instance
-
rootN
public FieldComplex<T> rootN(int n)
Nth root.This implementation compute the principal nth root by using a branch cut along real negative axis.
- Specified by:
rootNin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
n- order of the root- Returns:
- nth root of the instance
-
tan
public FieldComplex<T> tan()
Compute the tangent of this complex number. Implements the formula:
where the (real) functions on the right-hand side aretan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]iFastMath.sin(double),FastMath.cos(double),FastMath.cosh(double)andFastMath.sinh(double).Returns
Infinite (or critical) values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.getNaN(Field)if either real or imaginary part of the input argument isNaN.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- Specified by:
tanin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the tangent of
this.
-
tanh
public FieldComplex<T> tanh()
Compute the hyperbolic tangent of this complex number. Implements the formula:
where the (real) functions on the right-hand side aretan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]iFastMath.sin(double),FastMath.cos(double),FastMath.cosh(double)andFastMath.sinh(double).Returns
Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.getNaN(Field)if either real or imaginary part of the input argument isNaN.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- Specified by:
tanhin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the hyperbolic tangent of
this.
-
getArgument
public T getArgument()
Compute the argument of this complex number. The argument is the angle phi between the positive real axis and the point representing this number in the complex plane. The value returned is between -PI (not inclusive) and PI (inclusive), with negative values returned for numbers with negative imaginary parts.If either real or imaginary part (or both) is NaN, NaN is returned. Infinite parts are handled as
Math.atan2handles 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 forMath.atan2for full details.- Returns:
- the argument of
this.
-
nthRoot
public List<FieldComplex<T>> nthRoot(int n) throws MathIllegalArgumentException
Computes the n-th roots of this complex number. The nth roots are defined by the formula:
forzk = abs1/n (cos(phi + 2πk/n) + i (sin(phi + 2πk/n))k=0, 1, ..., n-1, whereabsandphiare respectively themodulusandargumentof 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 containinggetInf(Field).- Parameters:
n- Degree of root.- Returns:
- a List of all
n-th roots ofthis. - Throws:
MathIllegalArgumentException- ifn <= 0.
-
createComplex
protected FieldComplex<T> createComplex(T realPart, T imaginaryPart)
Create a complex number given the real and imaginary parts.- Parameters:
realPart- Real part.imaginaryPart- Imaginary part.- Returns:
- a new complex number instance.
- See Also:
valueOf(CalculusFieldElement, CalculusFieldElement)
-
valueOf
public static <T extends CalculusFieldElement<T>> FieldComplex<T> valueOf(T realPart, T imaginaryPart)
Create a complex number given the real and imaginary parts.- Type Parameters:
T- the type of the field elements- Parameters:
realPart- Real part.imaginaryPart- Imaginary part.- Returns:
- a Complex instance.
-
valueOf
public static <T extends CalculusFieldElement<T>> FieldComplex<T> valueOf(T realPart)
Create a complex number given only the real part.- Type Parameters:
T- the type of the field elements- Parameters:
realPart- Real part.- Returns:
- a Complex instance.
-
newInstance
public FieldComplex<T> newInstance(double realPart)
Create an instance corresponding to a constant real value.- Specified by:
newInstancein interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
realPart- constant real value- Returns:
- instance corresponding to a constant real value
-
getField
public FieldComplexField<T> getField()
Get theFieldto which the instance belongs.- Specified by:
getFieldin interfaceFieldElement<T extends CalculusFieldElement<T>>- Returns:
Fieldto which the instance belongs
-
getPartsField
public Field<T> getPartsField()
Get theFieldthe real and imaginary parts belong to.- Returns:
Fieldthe real and imaginary parts belong to
-
scalb
public FieldComplex<T> scalb(int n)
Multiply the instance by a power of 2.- Specified by:
scalbin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
n- power of 2- Returns:
- this × 2n
-
ulp
public FieldComplex<T> ulp()
Compute least significant bit (Unit in Last Position) for a number.- Specified by:
ulpin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- ulp(this)
-
hypot
public FieldComplex<T> hypot(FieldComplex<T> y)
Returns the hypotenuse of a triangle with sidesthisandy- sqrt(this2 +y2) avoiding intermediate overflow or underflow.- If either argument is infinite, then the result is positive infinity.
- else, if either argument is NaN then the result is NaN.
- Specified by:
hypotin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
y- a value- Returns:
- sqrt(this2 +y2)
-
linearCombination
public FieldComplex<T> linearCombination(FieldComplex<T>[] a, FieldComplex<T>[] b) throws MathIllegalArgumentException
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a- Factors.b- Factors.- Returns:
Σi ai bi.- Throws:
MathIllegalArgumentException- if arrays dimensions don't match
-
linearCombination
public FieldComplex<T> linearCombination(double[] a, FieldComplex<T>[] b) throws MathIllegalArgumentException
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a- Factors.b- Factors.- Returns:
Σi ai bi.- Throws:
MathIllegalArgumentException- if arrays dimensions don't match
-
linearCombination
public FieldComplex<T> linearCombination(FieldComplex<T> a1, FieldComplex<T> b1, FieldComplex<T> a2, FieldComplex<T> b2)
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second term- Returns:
- a1×b1 + a2×b2
- See Also:
CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement),CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement)
-
linearCombination
public FieldComplex<T> linearCombination(double a1, FieldComplex<T> b1, double a2, FieldComplex<T> b2)
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a1- first factor of the first termb1- second factor of the first terma2- first factor of the second termb2- second factor of the second term- Returns:
- a1×b1 + a2×b2
- See Also:
CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement, double, FieldElement),CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement, double, FieldElement, double, FieldElement)
-
linearCombination
public 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.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
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 term- Returns:
- a1×b1 + a2×b2 + a3×b3
- See Also:
CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement),CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement)
-
linearCombination
public FieldComplex<T> linearCombination(double a1, FieldComplex<T> b1, double a2, FieldComplex<T> b2, double a3, FieldComplex<T> b3)
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
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 term- Returns:
- a1×b1 + a2×b2 + a3×b3
- See Also:
CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement),CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement, double, FieldElement, double, FieldElement)
-
linearCombination
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)
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
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 term- Returns:
- a1×b1 + a2×b2 + a3×b3 + a4×b4
- See Also:
CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement),CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement)
-
linearCombination
public 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.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
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 term- Returns:
- a1×b1 + a2×b2 + a3×b3 + a4×b4
- See Also:
CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement),CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement, double, FieldElement)
-
ceil
public FieldComplex<T> ceil()
Get the smallest whole number larger than instance.- Specified by:
ceilin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- ceil(this)
-
floor
public FieldComplex<T> floor()
Get the largest whole number smaller than instance.- Specified by:
floorin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- floor(this)
-
rint
public 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.- Specified by:
rintin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- a double number r such that r is an integer r - 0.5 ≤ this ≤ r + 0.5
-
remainder
public FieldComplex<T> remainder(double a)
IEEE remainder operator.for complex numbers, the integer n corresponding to
this.subtract(remainder(a)).divide(a)is a Wikipedia - Gaussian integer.- Specified by:
remainderin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a- right hand side parameter of the operator- Returns:
- this - n × a where n is the closest integer to this/a
-
remainder
public FieldComplex<T> remainder(FieldComplex<T> a)
IEEE remainder operator.for complex numbers, the integer n corresponding to
this.subtract(remainder(a)).divide(a)is a Wikipedia - Gaussian integer.- Specified by:
remainderin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a- right hand side parameter of the operator- Returns:
- this - n × a where n is the closest integer to this/a
-
sign
public FieldComplex<T> sign()
Compute the sign of the instance. The sign is -1 for negative numbers, +1 for positive numbers and 0 otherwise, for Complex number, it is extended on the unit circle (equivalent to z/|z|, with special handling for 0 and NaN)- Specified by:
signin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- -1.0, -0.0, +0.0, +1.0 or NaN depending on sign of a
-
copySign
public FieldComplex<T> copySign(FieldComplex<T> z)
Returns the instance with the sign of the argument. A NaNsignargument is treated as positive.The signs of real and imaginary parts are copied independently.
- Specified by:
copySignin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
z- the sign for the returned value- Returns:
- the instance with the same sign as the
signargument
-
copySign
public FieldComplex<T> copySign(double r)
Returns the instance with the sign of the argument. A NaNsignargument is treated as positive.- Specified by:
copySignin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
r- the sign for the returned value- Returns:
- the instance with the same sign as the
signargument
-
toDegrees
public FieldComplex<T> toDegrees()
Convert radians to degrees, with error of less than 0.5 ULP- Specified by:
toDegreesin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- instance converted into degrees
-
toRadians
public FieldComplex<T> toRadians()
Convert degrees to radians, with error of less than 0.5 ULP- Specified by:
toRadiansin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- instance converted into radians
-
getPi
public FieldComplex<T> getPi()
Get the Archimedes constant π.Archimedes constant is the ratio of a circle's circumference to its diameter.
- Specified by:
getPiin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- Archimedes constant π
-
-