Class Binary64
- All Implemented Interfaces:
Serializable,Comparable<Binary64>,CalculusFieldElement<Binary64>,FieldElement<Binary64>
double value in an object. It is similar to the
standard class Double, while also implementing the
CalculusFieldElement interface.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Binary64The constant value ofDouble.NaNas aBinary64.static final Binary64The constant value ofDouble.NEGATIVE_INFINITYas aBinary64.static final Binary64The constant value of1das aBinary64.static final Binary64The constant value of π as aBinary64.static final Binary64The constant value ofDouble.POSITIVE_INFINITYas aBinary64.static final Binary64The constant value of0das aBinary64. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabs()absolute value.acos()Arc cosine operation.acosh()Inverse hyperbolic cosine operation.add(double a) '+' operator.Compute this + a.asin()Arc sine operation.asinh()Inverse hyperbolic sine operation.atan()Arc tangent operation.Two arguments arc tangent operation.atanh()Inverse hyperbolic tangent operation.byteThe current implementation performs casting to abyte.cbrt()Cubic root.ceil()Get the smallest whole number larger than instance.intThe current implementation returns the same value asnew Double(this.doubleValue()).compareTo(new Double(o.doubleValue()))copySign(double sign) Returns the instance with the sign of the argument.Returns the instance with the sign of the argument.cos()Cosine operation.cosh()Hyperbolic cosine operation.divide(double a) '÷' operator.Compute this ÷ a.doublebooleanexp()Exponential.expm1()Exponential minus 1.floatThe current implementation performs casting to afloat.floor()Get the largest whole number smaller than instance.Get the addendum to the real value of the number.getField()Get theFieldto which the instance belongs.getPi()Get the Archimedes constant π.doublegetReal()Get the real value of the number.inthashCode()The current implementation returns the same value asnew Double(this.doubleValue()).hashCode()Returns the hypotenuse of a triangle with sidesthisandy- sqrt(this2 +y2) avoiding intermediate overflow or underflow.intintValue()The current implementation performs casting to aint.booleanReturnstrueifthisdouble precision number is infinite (Double.POSITIVE_INFINITYorDouble.NEGATIVE_INFINITY).booleanisNaN()Returnstrueifthisdouble precision number is Not-a-Number (NaN), false otherwise.booleanisZero()Check if an element is semantically equal to zero.linearCombination(double[] a, Binary64[] b) Compute a linear combination.linearCombination(double a1, Binary64 b1, double a2, Binary64 b2) Compute a linear combination.linearCombination(double a1, Binary64 b1, double a2, Binary64 b2, double a3, Binary64 b3) Compute a linear combination.linearCombination(double a1, Binary64 b1, double a2, Binary64 b2, double a3, Binary64 b3, double a4, Binary64 b4) Compute a linear combination.linearCombination(Binary64[] a, Binary64[] b) Compute a linear combination.linearCombination(Binary64 a1, Binary64 b1, Binary64 a2, Binary64 b2) Compute a linear combination.Compute a linear combination.linearCombination(Binary64 a1, Binary64 b1, Binary64 a2, Binary64 b2, Binary64 a3, Binary64 b3, Binary64 a4, Binary64 b4) Compute a linear combination.log()Natural logarithm.log10()Base 10 logarithm.log1p()Shifted natural logarithm.longThe current implementation performs casting to along.multiply(double a) '×' operator.multiply(int n) Compute n × this.Compute this × a.negate()Returns the additive inverse ofthiselement.newInstance(double v) Create an instance corresponding to a constant real value.pow(double p) Power operation.pow(int n) Integer power operation.Power operation.Returns the multiplicative inverse ofthiselement.remainder(double a) IEEE remainder operator.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.shortThe current implementation performs casting to ashort.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.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 ULPtoString()The returnedStringis equal toDouble.toString(this.doubleValue())ulp()Compute least significant bit (Unit in Last Position) for a number.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.hipparchus.CalculusFieldElement
getExponent, isFinite, norm, round
-
Field Details
-
ZERO
The constant value of0das aBinary64. -
ONE
The constant value of1das aBinary64. -
PI
The constant value of π as aBinary64. -
NEGATIVE_INFINITY
The constant value ofDouble.NEGATIVE_INFINITYas aBinary64. -
POSITIVE_INFINITY
The constant value ofDouble.POSITIVE_INFINITYas aBinary64. -
NAN
The constant value ofDouble.NaNas aBinary64.
-
-
Constructor Details
-
Binary64
public Binary64(double x) Creates a new instance of this class.- Parameters:
x- the primitivedoublevalue of the object to be created
-
-
Method Details
-
newInstance
Create an instance corresponding to a constant real value.- Specified by:
newInstancein interfaceCalculusFieldElement<Binary64>- Parameters:
v- constant real value- Returns:
- instance corresponding to a constant real value
-
getField
Get theFieldto which the instance belongs.- Specified by:
getFieldin interfaceFieldElement<Binary64>- Returns:
Fieldto which the instance belongs
-
add
Compute this + a. The current implementation strictly enforcesthis.add(a).equals(new Binary64(this.doubleValue() + a.doubleValue())).- Specified by:
addin interfaceFieldElement<Binary64>- Parameters:
a- element to add- Returns:
- a new element representing this + a
-
subtract
Compute this - a. The current implementation strictly enforcesthis.subtract(a).equals(new Binary64(this.doubleValue() - a.doubleValue())).- Specified by:
subtractin interfaceCalculusFieldElement<Binary64>- Specified by:
subtractin interfaceFieldElement<Binary64>- Parameters:
a- element to subtract- Returns:
- a new element representing this - a
-
negate
Returns the additive inverse ofthiselement. The current implementation strictly enforcesthis.negate().equals(new Binary64(-this.doubleValue())).- Specified by:
negatein interfaceFieldElement<Binary64>- Returns:
- the opposite of
this.
-
square
Description copied from interface:CalculusFieldElementCompute this × this.- Specified by:
squarein interfaceCalculusFieldElement<Binary64>- Returns:
- a new element representing this × this
-
multiply
Compute this × a. The current implementation strictly enforcesthis.multiply(a).equals(new Binary64(this.doubleValue() * a.doubleValue())).- Specified by:
multiplyin interfaceFieldElement<Binary64>- 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} \] The current implementation strictly enforcesthis.multiply(n).equals(new Binary64(n * this.doubleValue())).- Specified by:
multiplyin interfaceCalculusFieldElement<Binary64>- Specified by:
multiplyin interfaceFieldElement<Binary64>- Parameters:
n- Number of timesthismust be added to itself.- Returns:
- A new element representing n × this.
-
divide
Compute this ÷ a. The current implementation strictly enforcesthis.divide(a).equals(new Binary64(this.doubleValue() / a.doubleValue())).- Specified by:
dividein interfaceCalculusFieldElement<Binary64>- Specified by:
dividein interfaceFieldElement<Binary64>- Parameters:
a- element to divide by- Returns:
- a new element representing this ÷ a
-
reciprocal
Returns the multiplicative inverse ofthiselement. The current implementation strictly enforcesthis.reciprocal().equals(new Binary64(1.0 / this.doubleValue())).- Specified by:
reciprocalin interfaceFieldElement<Binary64>- Returns:
- the inverse of
this.
-
byteValue
public byte byteValue()The current implementation performs casting to abyte. -
shortValue
public short shortValue()The current implementation performs casting to ashort.- Overrides:
shortValuein classNumber
-
intValue
public int intValue()The current implementation performs casting to aint. -
longValue
public long longValue()The current implementation performs casting to along. -
floatValue
public float floatValue()The current implementation performs casting to afloat.- Specified by:
floatValuein classNumber
-
doubleValue
public double doubleValue()- Specified by:
doubleValuein classNumber
-
compareTo
The current implementation returns the same value asnew Double(this.doubleValue()).compareTo(new Double(o.doubleValue()))- Specified by:
compareToin interfaceComparable<Binary64>- See Also:
-
equals
-
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.
- Specified by:
isZeroin interfaceFieldElement<Binary64>- Returns:
- true if the element is semantically equal to zero
- Since:
- 1.8
-
hashCode
public int hashCode()The current implementation returns the same value asnew Double(this.doubleValue()).hashCode() -
toString
The returnedStringis equal toDouble.toString(this.doubleValue()) -
isInfinite
public boolean isInfinite()Returnstrueifthisdouble precision number is infinite (Double.POSITIVE_INFINITYorDouble.NEGATIVE_INFINITY).- Specified by:
isInfinitein interfaceCalculusFieldElement<Binary64>- Returns:
trueifthisnumber is infinite
-
isNaN
public boolean isNaN()Returnstrueifthisdouble precision number is Not-a-Number (NaN), false otherwise.- Specified by:
isNaNin interfaceCalculusFieldElement<Binary64>- Returns:
trueifthisisNaN
-
getReal
public double getReal()Get the real value of the number.- Specified by:
getRealin interfaceFieldElement<Binary64>- Returns:
- real value
-
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<Binary64>- Returns:
- real value
-
add
'+' operator.- Specified by:
addin interfaceCalculusFieldElement<Binary64>- Parameters:
a- right hand side parameter of the operator- Returns:
- this+a
-
subtract
'-' operator.- Specified by:
subtractin interfaceCalculusFieldElement<Binary64>- Parameters:
a- right hand side parameter of the operator- Returns:
- this-a
-
multiply
'×' operator.- Specified by:
multiplyin interfaceCalculusFieldElement<Binary64>- Parameters:
a- right hand side parameter of the operator- Returns:
- this×a
-
divide
'÷' operator.- Specified by:
dividein interfaceCalculusFieldElement<Binary64>- Parameters:
a- right hand side parameter of the operator- Returns:
- this÷a
-
remainder
IEEE remainder operator.- Specified by:
remainderin interfaceCalculusFieldElement<Binary64>- 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:
remainderin interfaceCalculusFieldElement<Binary64>- 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:
absin interfaceCalculusFieldElement<Binary64>- Returns:
- abs(this)
-
ceil
Get the smallest whole number larger than instance.- Specified by:
ceilin interfaceCalculusFieldElement<Binary64>- Returns:
- ceil(this)
-
floor
Get the largest whole number smaller than instance.- Specified by:
floorin interfaceCalculusFieldElement<Binary64>- 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:
rintin interfaceCalculusFieldElement<Binary64>- 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:
signin interfaceCalculusFieldElement<Binary64>- 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 NaNsignargument is treated as positive.- Specified by:
copySignin interfaceCalculusFieldElement<Binary64>- Parameters:
sign- the sign for the returned value- Returns:
- the instance with the same sign as the
signargument
-
copySign
Returns the instance with the sign of the argument. A NaNsignargument is treated as positive.- Specified by:
copySignin interfaceCalculusFieldElement<Binary64>- Parameters:
sign- the sign for the returned value- Returns:
- the instance with the same sign as the
signargument
-
scalb
Multiply the instance by a power of 2.- Specified by:
scalbin interfaceCalculusFieldElement<Binary64>- Parameters:
n- power of 2- Returns:
- this × 2n
-
ulp
Compute least significant bit (Unit in Last Position) for a number.- Specified by:
ulpin interfaceCalculusFieldElement<Binary64>- Returns:
- ulp(this)
-
hypot
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<Binary64>- Parameters:
y- a value- Returns:
- sqrt(this2 +y2)
-
sqrt
Square root.- Specified by:
sqrtin interfaceCalculusFieldElement<Binary64>- Returns:
- square root of the instance
-
cbrt
Cubic root.- Specified by:
cbrtin interfaceCalculusFieldElement<Binary64>- Returns:
- cubic root of the instance
-
rootN
Nth root.- Specified by:
rootNin interfaceCalculusFieldElement<Binary64>- Parameters:
n- order of the root- Returns:
- nth root of the instance
-
pow
Power operation.- Specified by:
powin interfaceCalculusFieldElement<Binary64>- Parameters:
p- power to apply- Returns:
- thisp
-
pow
Integer power operation.- Specified by:
powin interfaceCalculusFieldElement<Binary64>- Parameters:
n- power to apply- Returns:
- thisn
-
pow
Power operation.- Specified by:
powin interfaceCalculusFieldElement<Binary64>- Parameters:
e- exponent- Returns:
- thise
-
exp
Exponential.- Specified by:
expin interfaceCalculusFieldElement<Binary64>- Returns:
- exponential of the instance
-
expm1
Exponential minus 1.- Specified by:
expm1in interfaceCalculusFieldElement<Binary64>- Returns:
- exponential minus one of the instance
-
log
Natural logarithm.- Specified by:
login interfaceCalculusFieldElement<Binary64>- Returns:
- logarithm of the instance
-
log1p
Shifted natural logarithm.- Specified by:
log1pin interfaceCalculusFieldElement<Binary64>- Returns:
- logarithm of one plus the instance
-
log10
Base 10 logarithm.- Specified by:
log10in interfaceCalculusFieldElement<Binary64>- Returns:
- base 10 logarithm of the instance
-
cos
Cosine operation.- Specified by:
cosin interfaceCalculusFieldElement<Binary64>- Returns:
- cos(this)
-
sin
Sine operation.- Specified by:
sinin interfaceCalculusFieldElement<Binary64>- Returns:
- sin(this)
-
sinCos
Combined Sine and Cosine operation.- Specified by:
sinCosin interfaceCalculusFieldElement<Binary64>- Returns:
- [sin(this), cos(this)]
-
tan
Tangent operation.- Specified by:
tanin interfaceCalculusFieldElement<Binary64>- Returns:
- tan(this)
-
acos
Arc cosine operation.- Specified by:
acosin interfaceCalculusFieldElement<Binary64>- Returns:
- acos(this)
-
asin
Arc sine operation.- Specified by:
asinin interfaceCalculusFieldElement<Binary64>- Returns:
- asin(this)
-
atan
Arc tangent operation.- Specified by:
atanin interfaceCalculusFieldElement<Binary64>- 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 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<Binary64>- Parameters:
x- second argument of the arc tangent- Returns:
- atan2(this, x)
-
cosh
Hyperbolic cosine operation.- Specified by:
coshin interfaceCalculusFieldElement<Binary64>- Returns:
- cosh(this)
-
sinh
Hyperbolic sine operation.- Specified by:
sinhin interfaceCalculusFieldElement<Binary64>- Returns:
- sinh(this)
-
sinhCosh
Combined hyperbolic sine and cosine operation.- Specified by:
sinhCoshin interfaceCalculusFieldElement<Binary64>- Returns:
- [sinh(this), cosh(this)]
-
tanh
Hyperbolic tangent operation.- Specified by:
tanhin interfaceCalculusFieldElement<Binary64>- Returns:
- tanh(this)
-
acosh
Inverse hyperbolic cosine operation.- Specified by:
acoshin interfaceCalculusFieldElement<Binary64>- Returns:
- acosh(this)
-
asinh
Inverse hyperbolic sine operation.- Specified by:
asinhin interfaceCalculusFieldElement<Binary64>- Returns:
- asin(this)
-
atanh
Inverse hyperbolic tangent operation.- Specified by:
atanhin interfaceCalculusFieldElement<Binary64>- Returns:
- atanh(this)
-
toDegrees
Convert radians to degrees, with error of less than 0.5 ULP- Specified by:
toDegreesin interfaceCalculusFieldElement<Binary64>- Returns:
- instance converted into degrees
-
toRadians
Convert degrees to radians, with error of less than 0.5 ULP- Specified by:
toRadiansin interfaceCalculusFieldElement<Binary64>- Returns:
- instance converted into radians
-
linearCombination
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Binary64>- Parameters:
a- Factors.b- Factors.- Returns:
Σi ai bi.- Throws:
MathIllegalArgumentException- if arrays dimensions don't match
-
linearCombination
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Binary64>- Parameters:
a- Factors.b- Factors.- Returns:
Σi ai bi.- Throws:
MathIllegalArgumentException- if arrays dimensions don't match
-
linearCombination
Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Binary64>- 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:
linearCombinationin interfaceCalculusFieldElement<Binary64>- 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 Binary64 linearCombination(Binary64 a1, Binary64 b1, Binary64 a2, Binary64 b2, Binary64 a3, Binary64 b3) Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Binary64>- 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 Binary64 linearCombination(double a1, Binary64 b1, double a2, Binary64 b2, double a3, Binary64 b3) Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Binary64>- 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 Binary64 linearCombination(Binary64 a1, Binary64 b1, Binary64 a2, Binary64 b2, Binary64 a3, Binary64 b3, Binary64 a4, Binary64 b4) Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Binary64>- 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 Binary64 linearCombination(double a1, Binary64 b1, double a2, Binary64 b2, double a3, Binary64 b3, double a4, Binary64 b4) Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<Binary64>- 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:
getPiin interfaceCalculusFieldElement<Binary64>- Returns:
- Archimedes constant π
-