Package org.hipparchus.util
Class FieldTuple<T extends CalculusFieldElement<T>>
java.lang.Object
org.hipparchus.util.FieldTuple<T>
- Type Parameters:
T
- the type of the field elements
- All Implemented Interfaces:
CalculusFieldElement<FieldTuple<T>>
,FieldElement<FieldTuple<T>>
public class FieldTuple<T extends CalculusFieldElement<T>>
extends Object
implements CalculusFieldElement<FieldTuple<T>>
This class allows to perform the same computation of all components of a Tuple at once.
- Since:
- 1.2
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabs()
absolute value.acos()
Arc cosine operation.acosh()
Inverse hyperbolic cosine operation.add
(double a) '+' operator.add
(FieldTuple<T> a) Compute this + a.asin()
Arc sine operation.asinh()
Inverse hyperbolic sine operation.atan()
Arc tangent operation.atan2
(FieldTuple<T> x) Two arguments arc tangent operation.atanh()
Inverse hyperbolic tangent operation.cbrt()
Cubic root.ceil()
Get the smallest whole number larger than instance.copySign
(double sign) Returns the instance with the sign of the argument.copySign
(FieldTuple<T> sign) Returns the instance with the sign of the argument.cos()
Cosine operation.cosh()
Hyperbolic cosine operation.divide
(double a) '÷' operator.divide
(FieldTuple<T> a) Compute this ÷ a.boolean
exp()
Exponential.expm1()
Exponential minus 1.floor()
Get the largest whole number smaller than instance.getComponent
(int index) Get one component of the tuple.T[]
Get all components of the tuple.int
Get the dimension of the tuple.Field<FieldTuple<T>>
getField()
Get theField
to which the instance belongs.getPi()
Get the Archimedes constant π.double
getReal()
Get the real value of the number.int
hashCode()
hypot
(FieldTuple<T> y) Returns the hypotenuse of a triangle with sidesthis
andy
- sqrt(this2 +y2) avoiding intermediate overflow or underflow.linearCombination
(double[] a, FieldTuple<T>[] b) Compute a linear combination.linearCombination
(double a1, FieldTuple<T> b1, double a2, FieldTuple<T> b2) Compute a linear combination.linearCombination
(double a1, FieldTuple<T> b1, double a2, FieldTuple<T> b2, double a3, FieldTuple<T> b3) Compute a linear combination.linearCombination
(double a1, FieldTuple<T> b1, double a2, FieldTuple<T> b2, double a3, FieldTuple<T> b3, double a4, FieldTuple<T> b4) Compute a linear combination.linearCombination
(FieldTuple<T>[] a, FieldTuple<T>[] b) Compute a linear combination.linearCombination
(FieldTuple<T> a1, FieldTuple<T> b1, FieldTuple<T> a2, FieldTuple<T> b2) Compute a linear combination.linearCombination
(FieldTuple<T> a1, FieldTuple<T> b1, FieldTuple<T> a2, FieldTuple<T> b2, FieldTuple<T> a3, FieldTuple<T> b3) Compute a linear combination.linearCombination
(FieldTuple<T> a1, FieldTuple<T> b1, FieldTuple<T> a2, FieldTuple<T> b2, FieldTuple<T> a3, FieldTuple<T> b3, FieldTuple<T> a4, FieldTuple<T> b4) Compute a linear combination.log()
Natural logarithm.log10()
Base 10 logarithm.log1p()
Shifted natural logarithm.multiply
(double a) '×' operator.multiply
(int n) Compute n × this.multiply
(FieldTuple<T> a) Compute this × a.negate()
Returns the additive inverse ofthis
element.newInstance
(double value) Create an instance corresponding to a constant real value.pow
(double p) Power operation.pow
(int n) Integer power operation.pow
(FieldTuple<T> e) Power operation.Returns the multiplicative inverse ofthis
element.remainder
(double a) IEEE remainder operator.remainder
(FieldTuple<T> a) IEEE remainder operator.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.rootN
(int n) Nth root.scalb
(int n) Multiply the instance by a power of 2.sign()
Compute the sign of the instance.sin()
Sine operation.sinCos()
Combined Sine and Cosine operation.sinh()
Hyperbolic sine operation.sinhCosh()
Combined hyperbolic sine and cosine operation.sqrt()
Square root.square()
Compute this × this.subtract
(double a) '-' operator.subtract
(FieldTuple<T> a) Compute this - a.tan()
Tangent operation.tanh()
Hyperbolic tangent operation.Convert radians to degrees, with error of less than 0.5 ULPConvert degrees to radians, with error of less than 0.5 ULPulp()
Compute least significant bit (Unit in Last Position) for a number.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.hipparchus.CalculusFieldElement
getExponent, isFinite, isInfinite, isNaN, norm, round
Methods inherited from interface org.hipparchus.FieldElement
isZero
-
Constructor Details
-
FieldTuple
Creates a new instance from its components.- Parameters:
x
- components of the tuple
-
-
Method Details
-
newInstance
Create an instance corresponding to a constant real value.- Specified by:
newInstance
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
value
- constant real value- Returns:
- instance corresponding to a constant real value
-
getDimension
public int getDimension()Get the dimension of the tuple.- Returns:
- dimension of the tuple
-
getComponent
Get one component of the tuple.- Parameters:
index
- index of the component, between 0 andgetDimension()
- 1- Returns:
- value of the component
-
getComponents
Get all components of the tuple.- Returns:
- all components
-
getField
Get theField
to which the instance belongs.- Specified by:
getField
in interfaceFieldElement<T extends CalculusFieldElement<T>>
- Returns:
Field
to which the instance belongs
-
add
Compute this + a.- Specified by:
add
in interfaceFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
a
- element to add- Returns:
- a new element representing this + a
-
subtract
Compute this - a.- Specified by:
subtract
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Specified by:
subtract
in interfaceFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
a
- element to subtract- Returns:
- a new element representing this - a
-
negate
Returns the additive inverse ofthis
element.- Specified by:
negate
in interfaceFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- the opposite of
this
.
-
multiply
Compute this × a.- Specified by:
multiply
in interfaceFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
a
- element to multiply- Returns:
- a new element representing this × a
-
multiply
Compute n × this. Multiplication by an integer number is defined as the following sum \[ n \times \mathrm{this} = \sum_{i=1}^n \mathrm{this} \]- Specified by:
multiply
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Specified by:
multiply
in interfaceFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
n
- Number of timesthis
must be added to itself.- Returns:
- A new element representing n × this.
-
divide
Compute this ÷ a.- Specified by:
divide
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Specified by:
divide
in interfaceFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
a
- element to divide by- Returns:
- a new element representing this ÷ a
-
reciprocal
Returns the multiplicative inverse ofthis
element.- Specified by:
reciprocal
in interfaceFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- the inverse of
this
.
-
equals
-
hashCode
public int hashCode() -
getReal
public double getReal()Get the real value of the number.- Specified by:
getReal
in interfaceFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- real value
-
add
'+' operator.- Specified by:
add
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
a
- right hand side parameter of the operator- Returns:
- this+a
-
subtract
'-' operator.- Specified by:
subtract
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
a
- right hand side parameter of the operator- Returns:
- this-a
-
multiply
'×' operator.- Specified by:
multiply
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
a
- right hand side parameter of the operator- Returns:
- this×a
-
square
Compute this × this.- Specified by:
square
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- a new element representing this × this
-
divide
'÷' operator.- Specified by:
divide
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
a
- right hand side parameter of the operator- Returns:
- this÷a
-
remainder
IEEE remainder operator.- Specified by:
remainder
in 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
IEEE remainder operator.- Specified by:
remainder
in 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
-
abs
absolute value.- Specified by:
abs
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- abs(this)
-
ceil
Get the smallest whole number larger than instance.- Specified by:
ceil
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- ceil(this)
-
floor
Get the largest whole number smaller than instance.- Specified by:
floor
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- floor(this)
-
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:
rint
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- a double number r such that r is an integer r - 0.5 ≤ this ≤ r + 0.5
-
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:
sign
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- -1.0, -0.0, +0.0, +1.0 or NaN depending on sign of a
-
copySign
Returns the instance with the sign of the argument. A NaNsign
argument is treated as positive.- Specified by:
copySign
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
sign
- the sign for the returned value- Returns:
- the instance with the same sign as the
sign
argument
-
copySign
Returns the instance with the sign of the argument. A NaNsign
argument is treated as positive.- Specified by:
copySign
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
sign
- the sign for the returned value- Returns:
- the instance with the same sign as the
sign
argument
-
scalb
Multiply the instance by a power of 2.- Specified by:
scalb
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
n
- power of 2- Returns:
- this × 2n
-
ulp
Compute least significant bit (Unit in Last Position) for a number.- Specified by:
ulp
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- ulp(this)
-
hypot
Returns the hypotenuse of a triangle with sidesthis
andy
- 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:
hypot
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
y
- a value- Returns:
- sqrt(this2 +y2)
-
sqrt
Square root.- Specified by:
sqrt
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- square root of the instance
-
cbrt
Cubic root.- Specified by:
cbrt
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- cubic root of the instance
-
rootN
Nth root.- Specified by:
rootN
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
n
- order of the root- Returns:
- nth root of the instance
-
pow
Power operation.- Specified by:
pow
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
p
- power to apply- Returns:
- thisp
-
pow
Integer power operation.- Specified by:
pow
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
n
- power to apply- Returns:
- thisn
-
pow
Power operation.- Specified by:
pow
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
e
- exponent- Returns:
- thise
-
exp
Exponential.- Specified by:
exp
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- exponential of the instance
-
expm1
Exponential minus 1.- Specified by:
expm1
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- exponential minus one of the instance
-
log
Natural logarithm.- Specified by:
log
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- logarithm of the instance
-
log1p
Shifted natural logarithm.- Specified by:
log1p
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- logarithm of one plus the instance
-
log10
Base 10 logarithm.- Specified by:
log10
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- base 10 logarithm of the instance
-
cos
Cosine operation.- Specified by:
cos
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- cos(this)
-
sin
Sine operation.- Specified by:
sin
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- sin(this)
-
sinCos
Combined Sine and Cosine operation.- Specified by:
sinCos
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- [sin(this), cos(this)]
-
tan
Tangent operation.- Specified by:
tan
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- tan(this)
-
acos
Arc cosine operation.- Specified by:
acos
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- acos(this)
-
asin
Arc sine operation.- Specified by:
asin
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- asin(this)
-
atan
Arc tangent operation.- Specified by:
atan
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- atan(this)
-
atan2
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 they
argument and thex
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 languagesatan2
two-arguments arc tangent and putsx
as its first argument.- Specified by:
atan2
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
x
- second argument of the arc tangent- Returns:
- atan2(this, x)
-
cosh
Hyperbolic cosine operation.- Specified by:
cosh
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- cosh(this)
-
sinh
Hyperbolic sine operation.- Specified by:
sinh
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- sinh(this)
-
sinhCosh
Combined hyperbolic sine and cosine operation.- Specified by:
sinhCosh
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- [sinh(this), cosh(this)]
-
tanh
Hyperbolic tangent operation.- Specified by:
tanh
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- tanh(this)
-
acosh
Inverse hyperbolic cosine operation.- Specified by:
acosh
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- acosh(this)
-
asinh
Inverse hyperbolic sine operation.- Specified by:
asinh
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- asin(this)
-
atanh
Inverse hyperbolic tangent operation.- Specified by:
atanh
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- atanh(this)
-
toDegrees
Convert radians to degrees, with error of less than 0.5 ULP- Specified by:
toDegrees
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- instance converted into degrees
-
toRadians
Convert degrees to radians, with error of less than 0.5 ULP- Specified by:
toRadians
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- instance converted into radians
-
linearCombination
public FieldTuple<T> linearCombination(FieldTuple<T>[] a, FieldTuple<T>[] b) throws MathIllegalArgumentException Compute a linear combination.- Specified by:
linearCombination
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
a
- Factors.b
- Factors.- Returns:
Σi ai bi
.- Throws:
MathIllegalArgumentException
- if arrays dimensions don't match
-
linearCombination
public FieldTuple<T> linearCombination(double[] a, FieldTuple<T>[] b) throws MathIllegalArgumentException Compute a linear combination.- Specified by:
linearCombination
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Parameters:
a
- Factors.b
- Factors.- Returns:
Σi ai bi
.- Throws:
MathIllegalArgumentException
- if arrays dimensions don't match
-
linearCombination
public FieldTuple<T> linearCombination(FieldTuple<T> a1, FieldTuple<T> b1, FieldTuple<T> a2, FieldTuple<T> b2) Compute a linear combination.- Specified by:
linearCombination
in 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:
-
linearCombination
Compute a linear combination.- Specified by:
linearCombination
in 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:
-
linearCombination
public FieldTuple<T> linearCombination(FieldTuple<T> a1, FieldTuple<T> b1, FieldTuple<T> a2, FieldTuple<T> b2, FieldTuple<T> a3, FieldTuple<T> b3) Compute a linear combination.- Specified by:
linearCombination
in 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:
-
linearCombination
public FieldTuple<T> linearCombination(double a1, FieldTuple<T> b1, double a2, FieldTuple<T> b2, double a3, FieldTuple<T> b3) Compute a linear combination.- Specified by:
linearCombination
in 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:
-
linearCombination
public FieldTuple<T> linearCombination(FieldTuple<T> a1, FieldTuple<T> b1, FieldTuple<T> a2, FieldTuple<T> b2, FieldTuple<T> a3, FieldTuple<T> b3, FieldTuple<T> a4, FieldTuple<T> b4) Compute a linear combination.- Specified by:
linearCombination
in 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:
-
linearCombination
public FieldTuple<T> linearCombination(double a1, FieldTuple<T> b1, double a2, FieldTuple<T> b2, double a3, FieldTuple<T> b3, double a4, FieldTuple<T> b4) Compute a linear combination.- Specified by:
linearCombination
in 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:
-
getPi
Get the Archimedes constant π.Archimedes constant is the ratio of a circle's circumference to its diameter.
- Specified by:
getPi
in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>
- Returns:
- Archimedes constant π
-