Package edu.jas.poly

Class GenExteriorPolynomial<C extends RingElem<C>>

java.lang.Object
edu.jas.poly.GenExteriorPolynomial<C>
Type Parameters:
C - coefficient type
All Implemented Interfaces:
AbelianGroupElem<GenExteriorPolynomial<C>>, Element<GenExteriorPolynomial<C>>, MonoidElem<GenExteriorPolynomial<C>>, RingElem<GenExteriorPolynomial<C>>, Serializable, Comparable<GenExteriorPolynomial<C>>, Iterable<IndexListMonomial<C>>

public final class GenExteriorPolynomial<C extends RingElem<C>> extends Object implements RingElem<GenExteriorPolynomial<C>>, Iterable<IndexListMonomial<C>>
GenExteriorPolynomial generic polynomials implementing RingElem. Antisymmetric polynomials (in fact vectors) over C. Objects of this class are intended to be immutable. The implementation is based on TreeMap respectively SortedMap from index lists to coefficients. Only the coefficients are modeled with generic types, the "exponents" are fixed to IndexList. C can also be a non integral domain, e.g. a ModInteger, i.e. it may contain zero divisors, since multiply() does check for zero coefficients and index lists.
See Also:
  • Field Details

    • ring

      public final GenExteriorPolynomialRing<C extends RingElem<C>> ring
      The factory for the polynomial ring.
    • val

      final SortedMap<IndexList,C extends RingElem<C>> val
      The data structure for polynomials.
    • logger

      private static final org.apache.logging.log4j.Logger logger
    • debug

      private static final boolean debug
  • Constructor Details

    • GenExteriorPolynomial

      private GenExteriorPolynomial(GenExteriorPolynomialRing<C> r, TreeMap<IndexList,C> t)
      Private constructor for GenExteriorPolynomial.
      Parameters:
      r - polynomial ring factory.
      t - TreeMap with correct ordering.
    • GenExteriorPolynomial

      public GenExteriorPolynomial(GenExteriorPolynomialRing<C> r)
      Constructor for zero GenExteriorPolynomial.
      Parameters:
      r - polynomial ring factory.
    • GenExteriorPolynomial

      public GenExteriorPolynomial(GenExteriorPolynomialRing<C> r, C c, IndexList e)
      Constructor for GenExteriorPolynomial c * xe.
      Parameters:
      r - polynomial ring factory.
      c - coefficient.
      e - word.
    • GenExteriorPolynomial

      public GenExteriorPolynomial(GenExteriorPolynomialRing<C> r, C c)
      Constructor for GenExteriorPolynomial c * x0.
      Parameters:
      r - polynomial ring factory.
      c - coefficient.
    • GenExteriorPolynomial

      public GenExteriorPolynomial(GenExteriorPolynomialRing<C> r, IndexList e)
      Constructor for GenExteriorPolynomial xe.
      Parameters:
      r - polynomial ring factory.
      e - index list.
    • GenExteriorPolynomial

      public GenExteriorPolynomial(GenExteriorPolynomialRing<C> r, ExpVector e)
      Constructor for GenExteriorPolynomial xe.
      Parameters:
      r - polynomial ring factory.
      e - exponent vector.
    • GenExteriorPolynomial

      public GenExteriorPolynomial(GenExteriorPolynomialRing<C> r, C c, ExpVector e)
      Constructor for GenExteriorPolynomial c * xe.
      Parameters:
      r - polynomial ring factory.
      c - coefficient.
      e - exponent vector.
    • GenExteriorPolynomial

      protected GenExteriorPolynomial(GenExteriorPolynomialRing<C> r, SortedMap<IndexList,C> v)
      Constructor for GenExteriorPolynomial.
      Parameters:
      r - polynomial ring factory.
      v - the SortedMap of some other polynomial.
  • Method Details

    • factory

      public GenExteriorPolynomialRing<C> factory()
      Get the corresponding element factory.
      Specified by:
      factory in interface Element<C extends RingElem<C>>
      Returns:
      factory for this Element.
      See Also:
    • copy

      public GenExteriorPolynomial<C> copy()
      Copy this GenExteriorPolynomial.
      Specified by:
      copy in interface Element<C extends RingElem<C>>
      Returns:
      copy of this.
    • length

      public int length()
      Length of GenExteriorPolynomial.
      Returns:
      number of coefficients of this GenExteriorPolynomial.
    • getMap

      public SortedMap<IndexList,C> getMap()
      IndexList to coefficient map of GenExteriorPolynomial.
      Returns:
      val as unmodifiable SortedMap.
    • doPutToMap

      public void doPutToMap(IndexList e, C c)
      Put a IndexList to coefficient entry into the internal map of this GenExteriorPolynomial. Note: Do not use this method unless you are constructing a new polynomial. this is modified and breaks the immutability promise of this class.
      Parameters:
      e - index list.
      c - coefficient.
    • doRemoveFromMap

      public void doRemoveFromMap(IndexList e, C c)
      Remove a IndexList to coefficient entry from the internal map of this GenExteriorPolynomial. Note: Do not use this method unless you are constructing a new polynomial. this is modified and breaks the immutability promise of this class.
      Parameters:
      e - IndexList.
      c - expected coefficient, null for ignore.
    • doPutToMap

      public void doPutToMap(SortedMap<IndexList,C> vals)
      Put an a sorted map of index list to coefficients into the internal map of this GenExteriorPolynomial. Note: Do not use this method unless you are constructing a new polynomial. this is modified and breaks the immutability promise of this class.
      Parameters:
      vals - sorted map of index list and coefficients.
    • toString

      public String toString()
      String representation of GenExteriorPolynomial.
      Overrides:
      toString in class Object
      See Also:
    • toScript

      public String toScript()
      Get a scripting compatible string representation.
      Specified by:
      toScript in interface Element<C extends RingElem<C>>
      Returns:
      script compatible representation for this Element.
      See Also:
    • toScriptFactory

      public String toScriptFactory()
      Get a scripting compatible string representation of the factory.
      Specified by:
      toScriptFactory in interface Element<C extends RingElem<C>>
      Returns:
      script compatible representation for this ElemFactory.
      See Also:
    • isZERO

      public boolean isZERO()
      Is GenExteriorPolynomial<C> zero.
      Specified by:
      isZERO in interface AbelianGroupElem<C extends RingElem<C>>
      Returns:
      If this is 0 then true is returned, else false.
      See Also:
    • isONE

      public boolean isONE()
      Is GenExteriorPolynomial<C> one.
      Specified by:
      isONE in interface MonoidElem<C extends RingElem<C>>
      Returns:
      If this is 1 then true is returned, else false.
      See Also:
    • isUnit

      public boolean isUnit()
      Is GenExteriorPolynomial<C> a unit.
      Specified by:
      isUnit in interface MonoidElem<C extends RingElem<C>>
      Returns:
      If this is a unit then true is returned, else false.
      See Also:
    • isConstant

      public boolean isConstant()
      Is GenExteriorPolynomial<C> a constant.
      Returns:
      If this is a constant polynomial then true is returned, else false.
    • isHomogeneous

      public boolean isHomogeneous()
      Is GenExteriorPolynomial<C> homogeneous.
      Returns:
      true, if this is homogeneous, else false.
    • form

      public GenExteriorPolynomial<C> form(long k)
      k-form part.
      Parameters:
      k - requested k-form part.
      Returns:
      k-form part of given degree of this.
    • homogeneousPart

      public GenExteriorPolynomial<C> homogeneousPart(long tdeg)
      Homogeneous part.
      Parameters:
      tdeg - requested degree of part.
      Returns:
      polynomial part of given degree.
    • equals

      public boolean equals(Object B)
      Comparison with any other object.
      Specified by:
      equals in interface Element<C extends RingElem<C>>
      Overrides:
      equals in class Object
      Parameters:
      B -
      Returns:
      true if this is equal to b, else false.
      See Also:
    • hashCode

      public int hashCode()
      Hash code for this polynomial.
      Specified by:
      hashCode in interface Element<C extends RingElem<C>>
      Overrides:
      hashCode in class Object
      Returns:
      the hashCode.
      See Also:
    • compareTo

      public int compareTo(GenExteriorPolynomial<C> b)
      GenExteriorPolynomial comparison.
      Specified by:
      compareTo in interface Comparable<C extends RingElem<C>>
      Specified by:
      compareTo in interface Element<C extends RingElem<C>>
      Parameters:
      b - GenExteriorPolynomial.
      Returns:
      sign(this-b).
    • signum

      public int signum()
      GenExteriorPolynomial signum.
      Specified by:
      signum in interface AbelianGroupElem<C extends RingElem<C>>
      Returns:
      sign(ldcf(this)).
    • numberOfVariables

      public int numberOfVariables()
      Number of variables.
      Returns:
      ring.ixfac.length().
    • leadingMonomial

      public Map.Entry<IndexList,C> leadingMonomial()
      Leading monomial.
      Returns:
      first map entry.
    • leadingIndexList

      public IndexList leadingIndexList()
      Leading index list.
      Returns:
      first highest index list.
    • trailingIndexList

      public IndexList trailingIndexList()
      Trailing index list.
      Returns:
      last lowest index list.
    • leadingBaseCoefficient

      public C leadingBaseCoefficient()
      Leading base coefficient.
      Returns:
      first coefficient.
    • trailingBaseCoefficient

      public C trailingBaseCoefficient()
      Trailing base coefficient.
      Returns:
      coefficient of constant term.
    • coefficient

      public C coefficient(IndexList e)
      Coefficient.
      Parameters:
      e - index list.
      Returns:
      coefficient for given index list.
    • reductum

      public GenExteriorPolynomial<C> reductum()
      Reductum.
      Returns:
      this - leading monomial.
    • degree

      public long degree()
      Index degree.
      Returns:
      maximal length of indexes.
    • maxDegree

      public long maxDegree()
      Index maximal degree.
      Returns:
      maximal degree of indexes.
    • maxNorm

      public C maxNorm()
      GenExteriorPolynomial maximum norm.
      Returns:
      ||this||.
    • sumNorm

      public C sumNorm()
      GenExteriorPolynomial sum norm.
      Returns:
      sum of all absolute values of coefficients.
    • sum

      GenExteriorPolynomial summation.
      Specified by:
      sum in interface AbelianGroupElem<C extends RingElem<C>>
      Parameters:
      S - GenExteriorPolynomial.
      Returns:
      this+S.
    • sum

      public GenExteriorPolynomial<C> sum(C a, IndexList e)
      GenExteriorPolynomial addition. This method is not very efficient, since this is copied.
      Parameters:
      a - coefficient.
      e - index list.
      Returns:
      this + a e.
    • sum

      public GenExteriorPolynomial<C> sum(C a)
      GenExteriorPolynomial addition. This method is not very efficient, since this is copied.
      Parameters:
      a - coefficient.
      Returns:
      this + a x0.
    • subtract

      GenExteriorPolynomial subtraction.
      Specified by:
      subtract in interface AbelianGroupElem<C extends RingElem<C>>
      Parameters:
      S - GenExteriorPolynomial.
      Returns:
      this-S.
    • subtract

      public GenExteriorPolynomial<C> subtract(C a, IndexList e)
      GenExteriorPolynomial subtraction. This method is not very efficient, since this is copied.
      Parameters:
      a - coefficient.
      e - index list.
      Returns:
      this - a e.
    • subtract

      public GenExteriorPolynomial<C> subtract(C a)
      GenExteriorPolynomial subtract. This method is not very efficient, since this is copied.
      Parameters:
      a - coefficient.
      Returns:
      this + a x0.
    • negate

      public GenExteriorPolynomial<C> negate()
      GenExteriorPolynomial negation.
      Specified by:
      negate in interface AbelianGroupElem<C extends RingElem<C>>
      Returns:
      -this.
    • abs

      public GenExteriorPolynomial<C> abs()
      GenExteriorPolynomial absolute value, i.e. leadingCoefficient > 0.
      Specified by:
      abs in interface AbelianGroupElem<C extends RingElem<C>>
      Returns:
      abs(this).
    • multiply

      GenExteriorPolynomial multiplication.
      Specified by:
      multiply in interface MonoidElem<C extends RingElem<C>>
      Parameters:
      S - GenExteriorPolynomial.
      Returns:
      this /\\ S.
    • interiorLeftProduct

      public GenExteriorPolynomial<C> interiorLeftProduct(GenExteriorPolynomial<C> S)
      GenExteriorPolynomial interior left multiplication.
      Parameters:
      S - GenExteriorPolynomial.
      Returns:
      this _| S.
    • interiorRightProduct

      public GenExteriorPolynomial<C> interiorRightProduct(GenExteriorPolynomial<C> S)
      GenExteriorPolynomial interior right multiplication.
      Parameters:
      S - GenExteriorPolynomial.
      Returns:
      this |_ S.
    • multiply

      GenExteriorPolynomial left and right multiplication. Product with two polynomials.
      Parameters:
      S - GenExteriorPolynomial.
      T - GenExteriorPolynomial.
      Returns:
      S*this*T.
    • multiply

      public GenExteriorPolynomial<C> multiply(C s)
      GenExteriorPolynomial multiplication. Product with coefficient ring element.
      Parameters:
      s - coefficient.
      Returns:
      this*s.
    • multiply

      public GenExteriorPolynomial<C> multiply(C s, C t)
      GenExteriorPolynomial multiplication. Product with coefficient ring element.
      Parameters:
      s - coefficient.
      t - coefficient.
      Returns:
      s*this*t.
    • monic

      public GenExteriorPolynomial<C> monic()
      GenExteriorPolynomial monic, i.e. leadingCoefficient == 1. If leadingCoefficient is not invertible returns this unmodified.
      Returns:
      monic(this).
    • multiply

      public GenExteriorPolynomial<C> multiply(C s, IndexList e)
      GenExteriorPolynomial multiplication. Product with ring element and index list.
      Parameters:
      s - coefficient.
      e - left index list.
      Returns:
      this * s e.
    • multiply

      public GenExteriorPolynomial<C> multiply(IndexList e, IndexList f)
      GenExteriorPolynomial left and right multiplication. Product with ring element and two index lists.
      Parameters:
      e - left index list.
      f - right index list.
      Returns:
      e * this * f.
    • multiply

      public GenExteriorPolynomial<C> multiply(C s, IndexList e, IndexList f)
      GenExteriorPolynomial left and right multiplication. Product with ring element and two index lists.
      Parameters:
      s - coefficient.
      e - left index list.
      f - right index list.
      Returns:
      e * this * s * f.
    • multiply

      public GenExteriorPolynomial<C> multiply(C s, IndexList e, C t, IndexList f)
      GenExteriorPolynomial left and right multiplication. Product with ring element and two index lists.
      Parameters:
      s - coefficient.
      e - left index list.
      t - coefficient.
      f - right index list.
      Returns:
      s * e * this * t * f.
    • multiply

      public GenExteriorPolynomial<C> multiply(IndexList e)
      GenExteriorPolynomial multiplication. Product with index list.
      Parameters:
      e - index list (!= null).
      Returns:
      this * e.
    • multiply

      public GenExteriorPolynomial<C> multiply(Map.Entry<IndexList,C> m)
      GenExteriorPolynomial multiplication. Product with 'monomial'.
      Parameters:
      m - 'monomial'.
      Returns:
      this * m.
    • divide

      public GenExteriorPolynomial<C> divide(C s)
      GenExteriorPolynomial division. Division by coefficient ring element. Fails, if exact division is not possible.
      Parameters:
      s - coefficient.
      Returns:
      this/s.
    • coeffPrimitivePart

      public GenExteriorPolynomial<C> coeffPrimitivePart()
      GenExteriorPolynomial coefficient primitive part. Division by gcd of coefficients.
      Returns:
      this/gcd(coeff(this)).
    • quotientRemainder

      public GenExteriorPolynomial<C>[] quotientRemainder(GenExteriorPolynomial<C> S)
      GenExteriorPolynomial division with remainder. Fails, if exact division by leading base coefficient is not possible. Meaningful only for univariate polynomials over fields, but works in any case.
      Specified by:
      quotientRemainder in interface MonoidElem<C extends RingElem<C>>
      Parameters:
      S - nonzero GenExteriorPolynomial with invertible leading coefficient.
      Returns:
      [ quotient , remainder ] with this = quotient * S + remainder and deg(remainder) < deg(S) or remainder = 0.
      See Also:
    • divide

      GenExteriorPolynomial division. Fails, if exact division by leading base coefficient is not possible. Meaningful only for univariate polynomials over fields, but works in any case.
      Specified by:
      divide in interface MonoidElem<C extends RingElem<C>>
      Parameters:
      S - nonzero GenExteriorPolynomial with invertible leading coefficient.
      Returns:
      quotient with this = quotient * S + remainder.
      See Also:
    • remainder

      GenExteriorPolynomial remainder. Fails, if exact division by leading base coefficient is not possible. Meaningful only for univariate polynomials over fields, but works in any case.
      Specified by:
      remainder in interface MonoidElem<C extends RingElem<C>>
      Parameters:
      S - nonzero GenExteriorPolynomial with invertible leading coefficient.
      Returns:
      remainder with this = quotient * S + remainder.
      See Also:
    • gcd

      GenExteriorPolynomial greatest common divisor. Note: not implemented.
      Specified by:
      gcd in interface RingElem<C extends RingElem<C>>
      Parameters:
      S - GenExteriorPolynomial.
      Returns:
      gcd(this,S).
    • egcd

      GenExteriorPolynomial extended greatest common divisor. Note: not implemented.
      Specified by:
      egcd in interface RingElem<C extends RingElem<C>>
      Parameters:
      S - GenExteriorPolynomial.
      Returns:
      [ gcd(this,S), a, b ] with a*this + b*S = gcd(this,S).
    • inverse

      public GenExteriorPolynomial<C> inverse()
      GenExteriorPolynomial inverse. Required by RingElem. Throws not invertible exception.
      Specified by:
      inverse in interface MonoidElem<C extends RingElem<C>>
      Returns:
      x with this * x = 1, if it exists.
    • shiftIndex

      public GenExteriorPolynomial<C> shiftIndex(int s)
      GenExteriorPolynomial shift index. Add number to each index.
      Parameters:
      s - shift index by this number.
      Returns:
      this.shift(s).
    • coefficientIterator

      public Iterator<C> coefficientIterator()
      Iterator over coefficients.
      Returns:
      val.values().iterator().
    • indexListIterator

      public Iterator<IndexList> indexListIterator()
      Iterator over index lists.
      Returns:
      val.keySet().iterator().
    • iterator

      public Iterator<IndexListMonomial<C>> iterator()
      Iterator over monomials.
      Specified by:
      iterator in interface Iterable<C extends RingElem<C>>
      Returns:
      a PolyIterator.
    • map

      public GenExteriorPolynomial<C> map(UnaryFunctor<? super C,C> f)
      Map a unary function to the coefficients.
      Parameters:
      f - evaluation functor.
      Returns:
      new polynomial with coefficients f(this(e)).