All Implemented Interfaces:
FieldI, IntegerConvertor, Serializable

public class ModulusField extends GenericField<Integer>
A field to work with small modulus values < 46341.
See Also:
  • Constructor Details

    • ModulusField

      public ModulusField(int modulus)
  • Method Details

    • cast

      public Integer cast(Object l)
      Convert input to an integer in the range [0,modulus)
      Specified by:
      cast in class GenericField<Integer>
      Parameters:
      l - input
      Returns:
      value in range or null if it cannot be converted
    • addG

      public Integer addG(Integer l, Integer r)
      Description copied from class: GenericField
      Adds two elements of type E.
      Specified by:
      addG in class GenericField<Integer>
      Parameters:
      l - lhs argument
      r - rhs argument
      Returns:
      the sum
    • subG

      public Integer subG(Integer l, Integer r)
      Description copied from class: GenericField
      Subtracts two elements of type E.
      Specified by:
      subG in class GenericField<Integer>
      Parameters:
      l - lhs argument
      r - rhs argument
      Returns:
      the difference
    • negG

      public Integer negG(Integer l)
      Description copied from class: GenericField
      Negates an elements of type E.
      Specified by:
      negG in class GenericField<Integer>
      Parameters:
      l - the argument
      Returns:
      the negation
    • mulG

      public Integer mulG(Integer l, Integer r)
      Description copied from class: GenericField
      Multiplies two elements of type E.
      Specified by:
      mulG in class GenericField<Integer>
      Parameters:
      l - lhs argument
      r - rhs argument
      Returns:
      the product
    • divG

      public Integer divG(Integer l, Integer r)
      Not implemented for this field.
      Specified by:
      divG in class GenericField<Integer>
      Parameters:
      l - numerator
      r - denominator
      Returns:
      the division
    • modG

      public Integer modG(Integer l, Integer r)
      Description copied from class: GenericField
      Modulus of two elements of type E.
      Specified by:
      modG in class GenericField<Integer>
      Parameters:
      l - lhs argument
      r - rhs argument
      Returns:
      the modulus
    • powG

      public Integer powG(Integer l, Integer r)
      Description copied from class: GenericField
      Raises l to the power of r
      Specified by:
      powG in class GenericField<Integer>
      Parameters:
      l - lhs argument
      r - rhs argument
      Returns:
      the power
    • cmpG

      public Integer cmpG(Integer l, Integer r)
      Not implemented for this field.
      Specified by:
      cmpG in class GenericField<Integer>
      Parameters:
      l - left argument
      r - right argument
      Returns:
      -1, 0, 1 or null
    • eq

      public Boolean eq(Object lo, Object ro)
      Description copied from interface: FieldI
      Equals
      Specified by:
      eq in interface FieldI
      Overrides:
      eq in class AbstractComparativeField
      Parameters:
      lo - left-hand argument
      ro - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
    • ne

      public Boolean ne(Object lo, Object ro)
      Description copied from interface: FieldI
      Not Equals
      Specified by:
      ne in interface FieldI
      Overrides:
      ne in class AbstractComparativeField
      Parameters:
      lo - left-hand argument
      ro - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
    • gt

      public Boolean gt(Object l, Object r)
      Not implemented for this field.
      Specified by:
      gt in interface FieldI
      Overrides:
      gt in class AbstractComparativeField
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
    • ge

      public Boolean ge(Object l, Object r)
      Not implemented for this field.
      Specified by:
      ge in interface FieldI
      Overrides:
      ge in class AbstractComparativeField
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
    • lt

      public Boolean lt(Object l, Object r)
      Not implemented for this field.
      Specified by:
      lt in interface FieldI
      Overrides:
      lt in class AbstractComparativeField
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
    • le

      public Boolean le(Object l, Object r)
      Not implemented for this field.
      Specified by:
      le in interface FieldI
      Overrides:
      le in class AbstractComparativeField
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
    • getOne

      public Integer getOne()
      Description copied from interface: FieldI
      Get the multiplicative identity for this field.
      Specified by:
      getOne in interface FieldI
      Specified by:
      getOne in class GenericField<Integer>
      Returns:
      object representing one or null if undefined for this field
    • getZero

      public Integer getZero()
      Description copied from interface: FieldI
      Get the additive identity for this field
      Specified by:
      getZero in interface FieldI
      Specified by:
      getZero in class GenericField<Integer>
      Returns:
      object representing zero or null if undefined for this field
    • convertToIntE

      public Integer convertToIntE(Integer l)
      Description copied from class: GenericField
      If possible convert the argument to an Integer to enable integral powers. If the argument cannot be converted null should be returned and the powG(E,E) method will be called.
      Specified by:
      convertToIntE in class GenericField<Integer>
      Parameters:
      l - argument to convert.
      Returns:
      an integer or null if argument cannot be converted
    • convertFromInt

      public Integer convertFromInt(Integer l)
      Description copied from interface: IntegerConvertor
      Attempt to convert argument from an integer
      Specified by:
      convertFromInt in interface IntegerConvertor
      Specified by:
      convertFromInt in class GenericField<Integer>
      Parameters:
      l - value to convert
      Returns:
      corresponding value in this field or null if it cannot be converted