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 a double value in order to be used as a field element.
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • ZERO

      private static final FP64 ZERO
      Additive neutral.
    • ONE

      private static final FP64 ONE
      Multiplicative neutral.
    • value

      private final double value
      Value.
  • Constructor Details

    • FP64

      private FP64(double value)
      Parameters:
      value - Value.
  • Method Details

    • of

      public static FP64 of(double value)
      Factory.
      Parameters:
      value - Value.
      Returns:
      a new instance.
    • add

      public FP64 add(FP64 a)
      Binary addition.
      Specified by:
      add in interface Addition<FP64>
      Parameters:
      a - Element.
      Returns:
      this + a.
    • negate

      public FP64 negate()
      Additive inverse.
      Specified by:
      negate in interface Addition<FP64>
      Returns:
      -this.
    • multiply

      public FP64 multiply(FP64 a)
      Binary multiplication.
      Specified by:
      multiply in interface Multiplication<FP64>
      Parameters:
      a - Element.
      Returns:
      this * a.
    • reciprocal

      public FP64 reciprocal()
      Multiplicative inverse.
      Specified by:
      reciprocal in interface Multiplication<FP64>
      Returns:
      this-1.
    • subtract

      public FP64 subtract(FP64 a)
      Binary subtraction.
      Specified by:
      subtract in interface NativeOperators<FP64>
      Parameters:
      a - Element.
      Returns:
      this - a.
    • divide

      public FP64 divide(FP64 a)
      Binary division.
      Specified by:
      divide in interface NativeOperators<FP64>
      Parameters:
      a - Element.
      Returns:
      this / a.
    • multiply

      public FP64 multiply(int n)
      Repeated addition.
      Specified by:
      multiply in interface NativeOperators<FP64>
      Parameters:
      n - Number of times to add this to itself.
      Returns:
      n * this.
    • pow

      public FP64 pow(int n)
      Repeated multiplication.
      Specified by:
      pow in interface NativeOperators<FP64>
      Parameters:
      n - Number of times to multiply this with itself.
      Returns:
      this^n.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • doubleValue

      public double doubleValue()
      Specified by:
      doubleValue in class Number
    • floatValue

      public float floatValue()
      Specified by:
      floatValue in class Number
    • intValue

      public int intValue()
      Specified by:
      intValue in class Number
    • longValue

      public long longValue()
      Specified by:
      longValue in class Number
    • byteValue

      public byte byteValue()
      Overrides:
      byteValue in class Number
    • compareTo

      public int compareTo(FP64 other)
      Specified by:
      compareTo in interface Comparable<FP64>
    • zero

      public FP64 zero()
      Identity element.
      Specified by:
      zero in interface Addition<FP64>
      Returns:
      the field element such that for all a, zero().add(a).equals(a) is true.
    • isZero

      public boolean isZero()
      Check if this is a neutral element of addition, i.e. this.add(a) returns a or an element representing the same value as a.

      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 of zero and its equals method differentiates between them.

      Specified by:
      isZero in interface Addition<FP64>
      Returns:
      true if this is a neutral element of addition.
      See Also:
    • one

      public FP64 one()
      Identity element.
      Specified by:
      one in interface Multiplication<FP64>
      Returns:
      the field element such that for all a, one().multiply(a).equals(a) is true.
    • isOne

      public boolean isOne()
      Check if this is a neutral element of multiplication, i.e. this.multiply(a) returns a or an element representing the same value as a.

      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 of one and its equals method differentiates between them.

      Specified by:
      isOne in interface Multiplication<FP64>
      Returns:
      true if this is a neutral element of multiplication.
      See Also: