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>
public final class FP64 extends Number implements NativeOperators<FP64>, Comparable<FP64>
Wraps adoublevalue in order to be used as a field element.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FP64add(FP64 a)Binary addition.bytebyteValue()intcompareTo(FP64 other)FP64divide(FP64 a)Binary division.doubledoubleValue()booleanequals(Object other)floatfloatValue()inthashCode()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.longlongValue()FP64multiply(int n)Repeated addition.FP64multiply(FP64 a)Binary multiplication.FP64negate()Additive inverse.static FP64of(double value)Factory.FP64one()Identity element.FP64pow(int n)Repeated multiplication.FP64reciprocal()Multiplicative inverse.FP64subtract(FP64 a)Binary subtraction.StringtoString()FP64zero()Identity element.-
Methods inherited from class java.lang.Number
shortValue
-
-
-
-
Method Detail
-
of
public static FP64 of(double value)
Factory.- Parameters:
value- Value.- Returns:
- a new instance.
-
multiply
public FP64 multiply(FP64 a)
Binary multiplication.- Specified by:
multiplyin interfaceMultiplication<FP64>- Parameters:
a- Element.- Returns:
this * a.
-
reciprocal
public FP64 reciprocal()
Multiplicative inverse.- Specified by:
reciprocalin interfaceMultiplication<FP64>- Returns:
this-1.
-
subtract
public FP64 subtract(FP64 a)
Binary subtraction.- Specified by:
subtractin interfaceNativeOperators<FP64>- Parameters:
a- Element.- Returns:
this - a.
-
divide
public FP64 divide(FP64 a)
Binary division.- Specified by:
dividein interfaceNativeOperators<FP64>- Parameters:
a- Element.- Returns:
this / a.
-
multiply
public FP64 multiply(int n)
Repeated addition.- Specified by:
multiplyin interfaceNativeOperators<FP64>- Parameters:
n- Number of times to addthisto itself.- Returns:
n * this.
-
pow
public FP64 pow(int n)
Repeated multiplication.- Specified by:
powin interfaceNativeOperators<FP64>- Parameters:
n- Number of times to multiplythiswith itself.- Returns:
this^n.
-
doubleValue
public double doubleValue()
- Specified by:
doubleValuein classNumber
-
floatValue
public float floatValue()
- Specified by:
floatValuein classNumber
-
compareTo
public int compareTo(FP64 other)
- Specified by:
compareToin interfaceComparable<FP64>
-
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.- Specified by:
isZeroin interfaceAddition<FP64>- Returns:
trueifthisis a neutral element of addition.- See Also:
Addition.zero()
-
one
public FP64 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:
Multiplication.one()
-
-