Interface FieldElement<T extends FieldElement<T>>

Type Parameters:
T - the type of the field elements
All Known Subinterfaces:
CalculusFieldElement<T>, Derivative<T>, Derivative1<T>, FieldDerivative<S,T>, FieldDerivative1<S,T>
All Known Implementing Classes:
BigFraction, BigReal, Binary64, Complex, DerivativeStructure, Dfp, DfpDec, FieldComplex, FieldDerivativeStructure, FieldGradient, FieldTuple, FieldUnivariateDerivative, FieldUnivariateDerivative1, FieldUnivariateDerivative2, Fraction, Gradient, SparseGradient, Tuple, UnivariateDerivative, UnivariateDerivative1, UnivariateDerivative2

public interface FieldElement<T extends FieldElement<T>>
Interface representing field elements.
See Also:
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    add(T a)
    Compute this + a.
    divide(T a)
    Compute this ÷ a.
    Get the Field to which the instance belongs.
    double
    Get the real value of the number.
    default boolean
    Check if an element is semantically equal to zero.
    multiply(int n)
    Compute n × this.
    Compute this × a.
    Returns the additive inverse of this element.
    Returns the multiplicative inverse of this element.
    Compute this - a.
  • Method Details Link icon

    • getReal Link icon

      double getReal()
      Get the real value of the number.
      Returns:
      real value
    • add Link icon

      T add(T a) throws NullArgumentException
      Compute this + a.
      Parameters:
      a - element to add
      Returns:
      a new element representing this + a
      Throws:
      NullArgumentException - if a is null.
    • subtract Link icon

      T subtract(T a) throws NullArgumentException
      Compute this - a.
      Parameters:
      a - element to subtract
      Returns:
      a new element representing this - a
      Throws:
      NullArgumentException - if a is null.
    • negate Link icon

      T negate()
      Returns the additive inverse of this element.
      Returns:
      the opposite of this.
    • multiply Link icon

      T multiply(int n)
      Compute n × this. Multiplication by an integer number is defined as the following sum n×this=i=1nthis
      Parameters:
      n - Number of times this must be added to itself.
      Returns:
      A new element representing n × this.
    • multiply Link icon

      T multiply(T a) throws NullArgumentException
      Compute this × a.
      Parameters:
      a - element to multiply
      Returns:
      a new element representing this × a
      Throws:
      NullArgumentException - if a is null.
    • divide Link icon

      Compute this ÷ a.
      Parameters:
      a - element to divide by
      Returns:
      a new element representing this ÷ a
      Throws:
      NullArgumentException - if a is null.
      MathRuntimeException - if a is zero
    • reciprocal Link icon

      T reciprocal() throws MathRuntimeException
      Returns the multiplicative inverse of this element.
      Returns:
      the inverse of this.
      Throws:
      MathRuntimeException - if this is zero
    • getField Link icon

      Field<T> getField()
      Get the Field to which the instance belongs.
      Returns:
      Field to which the instance belongs
    • isZero Link icon

      default 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 with hashCode() some classes implements equals(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.

      Returns:
      true if the element is semantically equal to zero
      Since:
      1.8