Package org.apache.commons.numbers.field
Class FP64
- java.lang.Object
-
- java.lang.Number
-
- org.apache.commons.numbers.field.FP64
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<FP64>
,Addition<FP64>
,Multiplication<FP64>
,NativeOperators<FP64>
public final class FP64 extends java.lang.Number implements NativeOperators<FP64>, java.lang.Comparable<FP64>
Wraps adouble
value in order to be used as a field element.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description private
FP64(double value)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FP64
add(FP64 a)
Binary addition.byte
byteValue()
int
compareTo(FP64 other)
FP64
divide(FP64 a)
Binary division.double
doubleValue()
boolean
equals(java.lang.Object other)
float
floatValue()
int
hashCode()
int
intValue()
boolean
isOne()
Check if this is a neutral element of multiplication, i.e.boolean
isZero()
Check if this is a neutral element of addition, i.e.long
longValue()
FP64
multiply(int n)
Repeated addition.FP64
multiply(FP64 a)
Binary multiplication.FP64
negate()
Additive inverse.static FP64
of(double value)
Factory.FP64
one()
Identity element.FP64
pow(int n)
Repeated multiplication.FP64
reciprocal()
Multiplicative inverse.FP64
subtract(FP64 a)
Binary subtraction.java.lang.String
toString()
FP64
zero()
Identity element.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
ZERO
private static final FP64 ZERO
Additive neutral.
-
ONE
private static final FP64 ONE
Multiplicative neutral.
-
value
private final double value
Value.
-
-
Method Detail
-
of
public static FP64 of(double value)
Factory.- Parameters:
value
- Value.- Returns:
- a new instance.
-
negate
public FP64 negate()
Additive inverse.
-
multiply
public FP64 multiply(FP64 a)
Binary multiplication.- Specified by:
multiply
in interfaceMultiplication<FP64>
- Parameters:
a
- Element.- Returns:
this * a
.
-
reciprocal
public FP64 reciprocal()
Multiplicative inverse.- Specified by:
reciprocal
in interfaceMultiplication<FP64>
- Returns:
this-1
.
-
subtract
public FP64 subtract(FP64 a)
Binary subtraction.- Specified by:
subtract
in interfaceNativeOperators<FP64>
- Parameters:
a
- Element.- Returns:
this - a
.
-
divide
public FP64 divide(FP64 a)
Binary division.- Specified by:
divide
in interfaceNativeOperators<FP64>
- Parameters:
a
- Element.- Returns:
this / a
.
-
multiply
public FP64 multiply(int n)
Repeated addition.- Specified by:
multiply
in interfaceNativeOperators<FP64>
- Parameters:
n
- Number of times to addthis
to itself.- Returns:
n * this
.
-
pow
public FP64 pow(int n)
Repeated multiplication.- Specified by:
pow
in interfaceNativeOperators<FP64>
- Parameters:
n
- Number of times to multiplythis
with itself.- Returns:
this^n
.
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
doubleValue
public double doubleValue()
- Specified by:
doubleValue
in classjava.lang.Number
-
floatValue
public float floatValue()
- Specified by:
floatValue
in classjava.lang.Number
-
intValue
public int intValue()
- Specified by:
intValue
in classjava.lang.Number
-
longValue
public long longValue()
- Specified by:
longValue
in classjava.lang.Number
-
byteValue
public byte byteValue()
- Overrides:
byteValue
in classjava.lang.Number
-
compareTo
public int compareTo(FP64 other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<FP64>
-
zero
public FP64 zero()
Identity element.
-
isZero
public boolean isZero()
Check if this is a neutral element of addition, i.e.this.add(a)
returnsa
or 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 ofzero
and itsequals
method differentiates between them.- Specified by:
isZero
in interfaceAddition<FP64>
- Returns:
true
ifthis
is a neutral element of addition.- See Also:
Addition.zero()
-
one
public FP64 one()
Identity element.- Specified by:
one
in 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)
returnsa
or 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 ofone
and itsequals
method differentiates between them.- Specified by:
isOne
in interfaceMultiplication<FP64>
- Returns:
true
ifthis
is a neutral element of multiplication.- See Also:
Multiplication.one()
-
-