Class ComplexFieldWithTotalOrder

java.lang.Object
com.singularsys.extensions.field.AbstractComparativeField
com.singularsys.extensions.field.implementations.ComplexFieldWithTotalOrder
All Implemented Interfaces:
FieldI, IntegerConvertor, Serializable

public class ComplexFieldWithTotalOrder extends AbstractComparativeField implements IntegerConvertor
A Field which operates on Complex objects which imposes a total order on the complex numbers, by first comparing the real part and then the imaginary part. So Complex(2,1) > Complex(2,0) > Complex(2,-1) > Complex(1,1) > Complex(1,0) > Complex(1,-1),

All versions of zero, Complex(0,0), Complex(-0,0), Complex(0,-0), Complex(0,0), are considered equal. Handling of infinities and NaNs are as in Double.compareTo(Double) so Complex(Double.NaN, Double.NaN) is considered greater than all other complex numbers.

This class is intended to be used with the PolynomialCreator to allow it to work with polynomials with complex coefficients.

See Also:
  • Constructor Details

    • ComplexFieldWithTotalOrder

      public ComplexFieldWithTotalOrder()
  • Method Details

    • add

      public Object add(Object l, Object r)
      Description copied from interface: FieldI
      Add two members of the field.
      Specified by:
      add in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
    • neg

      public Object neg(Object l)
      Description copied from interface: FieldI
      The negation -x of an element.
      Specified by:
      neg in interface FieldI
      Parameters:
      l - the argument
      Returns:
      an object representing the result or null if it can not be evaluated.
    • sub

      public Object sub(Object l, Object r)
      Description copied from interface: FieldI
      Subtract two members of the field.
      Specified by:
      sub in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
    • div

      public Object div(Object l, Object r)
      Description copied from interface: FieldI
      Divides two members of the field.
      Specified by:
      div in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
    • mod

      public Object mod(Object l, Object r)
      Not implemented for this field.
      Specified by:
      mod in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      null
    • mul

      public Object mul(Object l, Object r)
      Description copied from interface: FieldI
      Multiplies two members of the field.
      Specified by:
      mul in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
    • pow

      public Object pow(Object l, Object r)
      Description copied from interface: FieldI
      The power operator.
      Specified by:
      pow in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
    • and

      public Boolean and(Object l, Object r)
      Not implemented for this field.
      Specified by:
      and in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      null
    • or

      public Boolean or(Object l, Object r)
      Not implemented for this field.
      Specified by:
      or in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      null
    • not

      public Boolean not(Object l)
      Not implemented for this field.
      Specified by:
      not in interface FieldI
      Parameters:
      l - argument
      Returns:
      null
    • getOne

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

      public Object getZero()
      Description copied from interface: FieldI
      Get the additive identity for this field
      Specified by:
      getZero in interface FieldI
      Returns:
      object representing zero or null if undefined for this field
    • cmp

      public Integer cmp(Object a, Object b) throws EvaluationException
      Description copied from class: AbstractComparativeField
      Compare two elements, return -1,0,1 if the comparison can be carried out, null otherwise.
      Specified by:
      cmp in class AbstractComparativeField
      Parameters:
      a -
      b -
      Returns:
      -1, 0, 1 if l < r, l==r or l > r respectively, or null if comparison cannot be carried out or
      Throws:
      EvaluationException
    • convertToInt

      public Integer convertToInt(Object l) throws EvaluationException
      Description copied from interface: IntegerConvertor
      Attempt to convert argument to an integer
      Specified by:
      convertToInt in interface IntegerConvertor
      Parameters:
      l - value to convert
      Returns:
      corresponding integer or null if it cannot be converted
      Throws:
      EvaluationException - on error
    • convertFromInt

      public Object convertFromInt(Integer l) throws EvaluationException
      Description copied from interface: IntegerConvertor
      Attempt to convert argument from an integer
      Specified by:
      convertFromInt in interface IntegerConvertor
      Parameters:
      l - value to convert
      Returns:
      corresponding value in this field or null if it cannot be converted
      Throws:
      EvaluationException - probably never