Package org.apache.commons.numbers.field
Class FP64
java.lang.Object
java.lang.Number
org.apache.commons.numbers.field.FP64
- All Implemented Interfaces:
Serializable,Comparable<FP64>,Addition<FP64>,Multiplication<FP64>,NativeOperators<FP64>
Wraps a
double value in order to be used as a field
element.- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBinary addition.byteintBinary division.doublebooleanfloatinthashCode()intintValue()booleanisOne()Check if this is a neutral element of multiplication, i.e.booleanisZero()Check if this is a neutral element of addition, i.e.longmultiply(int n) Repeated addition.Binary multiplication.negate()Additive inverse.static FP64of(double value) Factory.one()Identity element.pow(int n) Repeated multiplication.Multiplicative inverse.Binary subtraction.toString()zero()Identity element.Methods inherited from class java.lang.Number
shortValue
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
ZERO
Additive neutral. -
ONE
Multiplicative neutral. -
value
private final double valueValue.
-
-
Constructor Details
-
FP64
private FP64(double value) - Parameters:
value- Value.
-
-
Method Details
-
of
Factory.- Parameters:
value- Value.- Returns:
- a new instance.
-
add
Binary addition. -
negate
Additive inverse. -
multiply
Binary multiplication.- Specified by:
multiplyin interfaceMultiplication<FP64>- Parameters:
a- Element.- Returns:
this * a.
-
reciprocal
Multiplicative inverse.- Specified by:
reciprocalin interfaceMultiplication<FP64>- Returns:
this-1.
-
subtract
Binary subtraction.- Specified by:
subtractin interfaceNativeOperators<FP64>- Parameters:
a- Element.- Returns:
this - a.
-
divide
Binary division.- Specified by:
dividein interfaceNativeOperators<FP64>- Parameters:
a- Element.- Returns:
this / a.
-
multiply
Repeated addition.- Specified by:
multiplyin interfaceNativeOperators<FP64>- Parameters:
n- Number of times to addthisto itself.- Returns:
n * this.
-
pow
Repeated multiplication.- Specified by:
powin interfaceNativeOperators<FP64>- Parameters:
n- Number of times to multiplythiswith itself.- Returns:
this^n.
-
equals
-
hashCode
public int hashCode() -
toString
-
doubleValue
public double doubleValue()- Specified by:
doubleValuein classNumber
-
floatValue
public float floatValue()- Specified by:
floatValuein classNumber
-
intValue
public int intValue() -
longValue
public long longValue() -
byteValue
public byte byteValue() -
compareTo
- Specified by:
compareToin interfaceComparable<FP64>
-
zero
Identity element. -
isZero
public boolean isZero()Check if this is a neutral element of addition, i.e.this.add(a)returnsaor an element representing the same value asa.The default implementation calls
equals(zero()). Implementations may want to employ more a efficient method. This may even be required if an implementation has multiple representations ofzeroand itsequalsmethod differentiates between them. -
one
Identity element.- Specified by:
onein interfaceMultiplication<FP64>- Returns:
- the field element such that for all
a,one().multiply(a).equals(a)istrue.
-
isOne
public boolean isOne()Check if this is a neutral element of multiplication, i.e.this.multiply(a)returnsaor an element representing the same value asa.The default implementation calls
equals(one()). Implementations may want to employ more a efficient method. This may even be required if an implementation has multiple representations ofoneand itsequalsmethod differentiates between them.- Specified by:
isOnein interfaceMultiplication<FP64>- Returns:
trueifthisis a neutral element of multiplication.- See Also:
-