Class Tuple
- java.lang.Object
-
- org.hipparchus.util.Tuple
-
- All Implemented Interfaces:
CalculusFieldElement<Tuple>,FieldElement<Tuple>
public class Tuple extends Object implements CalculusFieldElement<Tuple>
This class allows to perform the same computation of all components of a Tuple at once.- Since:
- 1.2
-
-
Constructor Summary
Constructors Constructor Description Tuple(double... x)Creates a new instance from its components.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tupleabs()absolute value.Tupleacos()Arc cosine operation.Tupleacosh()Inverse hyperbolic cosine operation.Tupleadd(double a)'+' operator.Tupleadd(Tuple a)Compute this + a.Tupleasin()Arc sine operation.Tupleasinh()Inverse hyperbolic sine operation.Tupleatan()Arc tangent operation.Tupleatan2(Tuple x)Two arguments arc tangent operation.Tupleatanh()Inverse hyperbolic tangent operation.Tuplecbrt()Cubic root.Tupleceil()Get the smallest whole number larger than instance.TuplecopySign(double sign)Returns the instance with the sign of the argument.TuplecopySign(Tuple sign)Returns the instance with the sign of the argument.Tuplecos()Cosine operation.Tuplecosh()Hyperbolic cosine operation.Tupledivide(double a)'÷' operator.Tupledivide(Tuple a)Compute this ÷ a.booleanequals(Object obj)Tupleexp()Exponential.Tupleexpm1()Exponential minus 1.Tuplefloor()Get the largest whole number smaller than instance.TuplegetAddendum()Get the addendum to the real value of the number.doublegetComponent(int index)Get one component of the tuple.double[]getComponents()Get all components of the tuple.intgetDimension()Get the dimension of the tuple.Field<Tuple>getField()Get theFieldto which the instance belongs.TuplegetPi()Get the Archimedes constant π.doublegetReal()Get the real value of the number.inthashCode()Tuplehypot(Tuple y)Returns the hypotenuse of a triangle with sidesthisandy- sqrt(this2 +y2) avoiding intermediate overflow or underflow.TuplelinearCombination(double[] a, Tuple[] b)Compute a linear combination.TuplelinearCombination(double a1, Tuple b1, double a2, Tuple b2)Compute a linear combination.TuplelinearCombination(double a1, Tuple b1, double a2, Tuple b2, double a3, Tuple b3)Compute a linear combination.TuplelinearCombination(double a1, Tuple b1, double a2, Tuple b2, double a3, Tuple b3, double a4, Tuple b4)Compute a linear combination.TuplelinearCombination(Tuple[] a, Tuple[] b)Compute a linear combination.TuplelinearCombination(Tuple a1, Tuple b1, Tuple a2, Tuple b2)Compute a linear combination.TuplelinearCombination(Tuple a1, Tuple b1, Tuple a2, Tuple b2, Tuple a3, Tuple b3)Compute a linear combination.TuplelinearCombination(Tuple a1, Tuple b1, Tuple a2, Tuple b2, Tuple a3, Tuple b3, Tuple a4, Tuple b4)Compute a linear combination.Tuplelog()Natural logarithm.Tuplelog10()Base 10 logarithm.Tuplelog1p()Shifted natural logarithm.Tuplemultiply(double a)'×' operator.Tuplemultiply(int n)Compute n × this.Tuplemultiply(Tuple a)Compute this × a.Tuplenegate()Returns the additive inverse ofthiselement.TuplenewInstance(double value)Create an instance corresponding to a constant real value.Tuplepow(double p)Power operation.Tuplepow(int n)Integer power operation.Tuplepow(Tuple e)Power operation.Tuplereciprocal()Returns the multiplicative inverse ofthiselement.Tupleremainder(double a)IEEE remainder operator.Tupleremainder(Tuple a)IEEE remainder operator.Tuplerint()Get the whole number that is the nearest to the instance, or the even one if x is exactly half way between two integers.TuplerootN(int n)Nth root.Tuplescalb(int n)Multiply the instance by a power of 2.Tuplesign()Compute the sign of the instance.Tuplesin()Sine operation.FieldSinCos<Tuple>sinCos()Combined Sine and Cosine operation.Tuplesinh()Hyperbolic sine operation.FieldSinhCosh<Tuple>sinhCosh()Combined hyperbolic sine and cosine operation.Tuplesqrt()Square root.Tuplesquare()Compute this × this.Tuplesubtract(double a)'-' operator.Tuplesubtract(Tuple a)Compute this - a.Tupletan()Tangent operation.Tupletanh()Hyperbolic tangent operation.TupletoDegrees()Convert radians to degrees, with error of less than 0.5 ULPTupletoRadians()Convert degrees to radians, with error of less than 0.5 ULPTupleulp()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
-
-
-
-
Method Detail
-
newInstance
public Tuple newInstance(double value)
Create an instance corresponding to a constant real value.- Specified by:
newInstancein interfaceCalculusFieldElement<Tuple>- 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
public double getComponent(int index)
Get one component of the tuple.- Parameters:
index- index of the component, between 0 andgetDimension()- 1- Returns:
- value of the component
-
getComponents
public double[] getComponents()
Get all components of the tuple.- Returns:
- all components
-
getField
public Field<Tuple> getField()
Get theFieldto which the instance belongs.- Specified by:
getFieldin interfaceFieldElement<Tuple>- Returns:
Fieldto which the instance belongs
-
add
public Tuple add(Tuple a)
Compute this + a.- Specified by:
addin interfaceFieldElement<Tuple>- Parameters:
a- element to add- Returns:
- a new element representing this + a
-
subtract
public Tuple subtract(Tuple a)
Compute this - a.- Specified by:
subtractin interfaceCalculusFieldElement<Tuple>- Specified by:
subtractin interfaceFieldElement<Tuple>- Parameters:
a- element to subtract- Returns:
- a new element representing this - a
-
negate
public Tuple negate()
Returns the additive inverse ofthiselement.- Specified by:
negatein interfaceFieldElement<Tuple>- Returns:
- the opposite of
this.
-
multiply
public Tuple multiply(Tuple a)
Compute this × a.- Specified by:
multiplyin interfaceFieldElement<Tuple>- Parameters:
a- element to multiply- Returns:
- a new element representing this × a
-
multiply
public Tuple multiply(int n)
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:
multiplyin interfaceCalculusFieldElement<Tuple>- Specified by:
multiplyin interfaceFieldElement<Tuple>- Parameters:
n- Number of timesthismust be added to itself.- Returns:
- A new element representing n × this.
-
square
public Tuple square()
Compute this × this.- Specified by:
squarein interfaceCalculusFieldElement<Tuple>- Returns:
- a new element representing this × this
-
divide
public Tuple divide(Tuple a)
Compute this ÷ a.- Specified by:
dividein interfaceCalculusFieldElement<Tuple>- Specified by:
dividein interfaceFieldElement<Tuple>- Parameters:
a- element to divide by- Returns:
- a new element representing this ÷ a
-
reciprocal
public Tuple reciprocal()
Returns the multiplicative inverse ofthiselement.- Specified by:
reciprocalin interfaceFieldElement<Tuple>- Returns:
- the inverse of
this.
-
getReal
public double getReal()
Get the real value of the number.- Specified by:
getRealin interfaceFieldElement<Tuple>- Returns:
- real value
-
getAddendum
public Tuple 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<Tuple>- Returns:
- real value
-
add
public Tuple add(double a)
'+' operator.- Specified by:
addin interfaceCalculusFieldElement<Tuple>- Parameters:
a- right hand side parameter of the operator- Returns:
- this+a
-
subtract
public Tuple subtract(double a)
'-' operator.- Specified by:
subtractin interfaceCalculusFieldElement<Tuple>- Parameters:
a- right hand side parameter of the operator- Returns:
- this-a
-
multiply
public Tuple multiply(double a)
'×' operator.- Specified by:
multiplyin interfaceCalculusFieldElement<Tuple>- Parameters:
a- right hand side parameter of the operator- Returns:
- this×a
-
divide
public Tuple divide(double a)
'÷' operator.- Specified by:
dividein interfaceCalculusFieldElement<Tuple>- Parameters:
a- right hand side parameter of the operator- Returns:
- this÷a
-
remainder
public Tuple remainder(double a)
IEEE remainder operator.- Specified by:
remainderin interfaceCalculusFieldElement<Tuple>- Parameters:
a- right hand side parameter of the operator- Returns:
- this - n × a where n is the closest integer to this/a
-
remainder
public Tuple remainder(Tuple a)
IEEE remainder operator.- Specified by:
remainderin interfaceCalculusFieldElement<Tuple>- Parameters:
a- right hand side parameter of the operator- Returns:
- this - n × a where n is the closest integer to this/a
-
abs
public Tuple abs()
absolute value.- Specified by:
absin interfaceCalculusFieldElement<Tuple>- Returns:
- abs(this)
-
ceil
public Tuple ceil()
Get the smallest whole number larger than instance.- Specified by:
ceilin interfaceCalculusFieldElement<Tuple>- Returns:
- ceil(this)
-
floor
public Tuple floor()
Get the largest whole number smaller than instance.- Specified by:
floorin interfaceCalculusFieldElement<Tuple>- Returns:
- floor(this)
-
rint
public Tuple 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<Tuple>- Returns:
- a double number r such that r is an integer r - 0.5 ≤ this ≤ r + 0.5
-
sign
public Tuple 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<Tuple>- Returns:
- -1.0, -0.0, +0.0, +1.0 or NaN depending on sign of a
-
copySign
public Tuple copySign(Tuple sign)
Returns the instance with the sign of the argument. A NaNsignargument is treated as positive.- Specified by:
copySignin interfaceCalculusFieldElement<Tuple>- Parameters:
sign- the sign for the returned value- Returns:
- the instance with the same sign as the
signargument
-
copySign
public Tuple copySign(double sign)
Returns the instance with the sign of the argument. A NaNsignargument is treated as positive.- Specified by:
copySignin interfaceCalculusFieldElement<Tuple>- Parameters:
sign- the sign for the returned value- Returns:
- the instance with the same sign as the
signargument
-
scalb
public Tuple scalb(int n)
Multiply the instance by a power of 2.- Specified by:
scalbin interfaceCalculusFieldElement<Tuple>- Parameters:
n- power of 2- Returns:
- this × 2n
-
ulp
public Tuple ulp()
Compute least significant bit (Unit in Last Position) for a number.- Specified by:
ulpin interfaceCalculusFieldElement<Tuple>- Returns:
- ulp(this)
-
hypot
public Tuple hypot(Tuple 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<Tuple>- Parameters:
y- a value- Returns:
- sqrt(this2 +y2)
-
sqrt
public Tuple sqrt()
Square root.- Specified by:
sqrtin interfaceCalculusFieldElement<Tuple>- Returns:
- square root of the instance
-
cbrt
public Tuple cbrt()
Cubic root.- Specified by:
cbrtin interfaceCalculusFieldElement<Tuple>- Returns:
- cubic root of the instance
-
rootN
public Tuple rootN(int n)
Nth root.- Specified by:
rootNin interfaceCalculusFieldElement<Tuple>- Parameters:
n- order of the root- Returns:
- nth root of the instance
-
pow
public Tuple pow(double p)
Power operation.- Specified by:
powin interfaceCalculusFieldElement<Tuple>- Parameters:
p- power to apply- Returns:
- thisp
-
pow
public Tuple pow(int n)
Integer power operation.- Specified by:
powin interfaceCalculusFieldElement<Tuple>- Parameters:
n- power to apply- Returns:
- thisn
-
pow
public Tuple pow(Tuple e)
Power operation.- Specified by:
powin interfaceCalculusFieldElement<Tuple>- Parameters:
e- exponent- Returns:
- thise
-
exp
public Tuple exp()
Exponential.- Specified by:
expin interfaceCalculusFieldElement<Tuple>- Returns:
- exponential of the instance
-
expm1
public Tuple expm1()
Exponential minus 1.- Specified by:
expm1in interfaceCalculusFieldElement<Tuple>- Returns:
- exponential minus one of the instance
-
log
public Tuple log()
Natural logarithm.- Specified by:
login interfaceCalculusFieldElement<Tuple>- Returns:
- logarithm of the instance
-
log1p
public Tuple log1p()
Shifted natural logarithm.- Specified by:
log1pin interfaceCalculusFieldElement<Tuple>- Returns:
- logarithm of one plus the instance
-
log10
public Tuple log10()
Base 10 logarithm.- Specified by:
log10in interfaceCalculusFieldElement<Tuple>- Returns:
- base 10 logarithm of the instance
-
cos
public Tuple cos()
Cosine operation.- Specified by:
cosin interfaceCalculusFieldElement<Tuple>- Returns:
- cos(this)
-
sin
public Tuple sin()
Sine operation.- Specified by:
sinin interfaceCalculusFieldElement<Tuple>- Returns:
- sin(this)
-
sinCos
public FieldSinCos<Tuple> sinCos()
Combined Sine and Cosine operation.- Specified by:
sinCosin interfaceCalculusFieldElement<Tuple>- Returns:
- [sin(this), cos(this)]
-
tan
public Tuple tan()
Tangent operation.- Specified by:
tanin interfaceCalculusFieldElement<Tuple>- Returns:
- tan(this)
-
acos
public Tuple acos()
Arc cosine operation.- Specified by:
acosin interfaceCalculusFieldElement<Tuple>- Returns:
- acos(this)
-
asin
public Tuple asin()
Arc sine operation.- Specified by:
asinin interfaceCalculusFieldElement<Tuple>- Returns:
- asin(this)
-
atan
public Tuple atan()
Arc tangent operation.- Specified by:
atanin interfaceCalculusFieldElement<Tuple>- Returns:
- atan(this)
-
atan2
public Tuple atan2(Tuple 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<Tuple>- Parameters:
x- second argument of the arc tangent- Returns:
- atan2(this, x)
-
cosh
public Tuple cosh()
Hyperbolic cosine operation.- Specified by:
coshin interfaceCalculusFieldElement<Tuple>- Returns:
- cosh(this)
-
sinh
public Tuple sinh()
Hyperbolic sine operation.- Specified by:
sinhin interfaceCalculusFieldElement<Tuple>- Returns:
- sinh(this)
-
sinhCosh
public FieldSinhCosh<Tuple> sinhCosh()
Combined hyperbolic sine and cosine operation.- Specified by:
sinhCoshin interfaceCalculusFieldElement<Tuple>- Returns:
- [sinh(this), cosh(this)]
-
tanh
public Tuple tanh()
Hyperbolic tangent operation.- Specified by:
tanhin interfaceCalculusFieldElement<Tuple>- Returns:
- tanh(this)
-
acosh
public Tuple acosh()
Inverse hyperbolic cosine operation.- Specified by:
acoshin interfaceCalculusFieldElement<Tuple>- Returns:
- acosh(this)
-
asinh
public Tuple asinh()
Inverse hyperbolic sine operation.- Specified by:
asinhin interfaceCalculusFieldElement<Tuple>- Returns:
- asin(this)
-
atanh
public Tuple atanh()
Inverse hyperbolic tangent operation.- Specified by:
atanhin interfaceCalculusFieldElement<Tuple>- Returns:
- atanh(this)
-
toDegrees
public Tuple toDegrees()
Convert radians to degrees, with error of less than 0.5 ULP- Specified by:
toDegreesin interfaceCalculusFieldElement<Tuple>- Returns:
- instance converted into degrees
-
toRadians
public Tuple toRadians()
Convert degrees to radians, with error of less than 0.5 ULP- Specified by:
toRadiansin interfaceCalculusFieldElement<Tuple>- Returns:
- instance converted into radians
-
linearCombination
public Tuple linearCombination(Tuple[] a, Tuple[] b) throws MathIllegalArgumentException
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Tuple>- Parameters:
a- Factors.b- Factors.- Returns:
Σi ai bi.- Throws:
MathIllegalArgumentException- if arrays dimensions don't match
-
linearCombination
public Tuple linearCombination(double[] a, Tuple[] b) throws MathIllegalArgumentException
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Tuple>- Parameters:
a- Factors.b- Factors.- Returns:
Σi ai bi.- Throws:
MathIllegalArgumentException- if arrays dimensions don't match
-
linearCombination
public Tuple linearCombination(Tuple a1, Tuple b1, Tuple a2, Tuple b2)
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Tuple>- 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 Tuple linearCombination(double a1, Tuple b1, double a2, Tuple b2)
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Tuple>- 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 Tuple linearCombination(Tuple a1, Tuple b1, Tuple a2, Tuple b2, Tuple a3, Tuple b3)
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Tuple>- 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 Tuple linearCombination(double a1, Tuple b1, double a2, Tuple b2, double a3, Tuple b3)
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Tuple>- 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 Tuple linearCombination(Tuple a1, Tuple b1, Tuple a2, Tuple b2, Tuple a3, Tuple b3, Tuple a4, Tuple b4)
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Tuple>- 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 Tuple linearCombination(double a1, Tuple b1, double a2, Tuple b2, double a3, Tuple b3, double a4, Tuple b4)
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Tuple>- 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)
-
getPi
public Tuple getPi()
Get the Archimedes constant π.Archimedes constant is the ratio of a circle's circumference to its diameter.
- Specified by:
getPiin interfaceCalculusFieldElement<Tuple>- Returns:
- Archimedes constant π
-
-