Class MultivariatePolynomial<E>

java.lang.Object
cc.redberry.rings.poly.multivar.AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
cc.redberry.rings.poly.multivar.MultivariatePolynomial<E>
All Implemented Interfaces:
Stringifiable<MultivariatePolynomial<E>>, IPolynomial<MultivariatePolynomial<E>>, Serializable, Comparable<MultivariatePolynomial<E>>, Iterable<Monomial<E>>

public final class MultivariatePolynomial<E>
extends AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
Since:
1.0
See Also:
Serialized Form
  • Field Details

    • ring

      public final Ring<E> ring
      The coefficient ring
  • Method Details

    • create

      public static <E> MultivariatePolynomial<E> create​(int nVariables, Ring<E> ring, Comparator<DegreeVector> ordering, Iterable<Monomial<E>> terms)
      Creates multivariate polynomial from a list of monomial terms
      Parameters:
      ring - the ring
      ordering - term ordering
      terms - the monomial terms
      Returns:
      multivariate polynomial
    • create

      public static <E> MultivariatePolynomial<E> create​(int nVariables, Ring<E> ring, Comparator<DegreeVector> ordering, Monomial<E>... terms)
      Creates multivariate polynomial from a list of monomial terms
      Parameters:
      ring - the ring
      ordering - term ordering
      terms - the monomial terms
      Returns:
      multivariate polynomial
    • zero

      public static <E> MultivariatePolynomial<E> zero​(int nVariables, Ring<E> ring, Comparator<DegreeVector> ordering)
      Creates zero polynomial.
      Parameters:
      nVariables - number of variables
      ring - the ring
      ordering - the ordering
      Returns:
      zero polynomial
    • one

      public static <E> MultivariatePolynomial<E> one​(int nVariables, Ring<E> ring, Comparator<DegreeVector> ordering)
      Creates unit polynomial.
      Parameters:
      nVariables - number of variables
      ring - the ring
      ordering - the ordering
      Returns:
      unit polynomial
    • parse

      public static MultivariatePolynomial<BigInteger> parse​(String string, String... variables)
      Parse multivariate Z[X] polynomial from string.
      Parameters:
      string - the string
      variables - string variables that should be taken into account. For examples: parse("a", LEX) and parse("a", LEX, "a", "b") although give the same mathematical expressions are differ, since the first one is considered as Z[x], while the second as Z[x1,x2]
      Returns:
      multivariate Z[X] polynomial
    • parse

      @Deprecated public static MultivariatePolynomial<BigInteger> parse​(String string)
      Deprecated.
      use #parse(string, ring, ordering, variables)
      Parse multivariate Z[X] polynomial from string.
      Parameters:
      string - the string
      Returns:
      multivariate Z[X] polynomial
    • parse

      public static <E> MultivariatePolynomial<E> parse​(String string, Ring<E> ring, String... variables)
      Parse multivariate polynomial from string.
      Parameters:
      string - the string
      ring - the ring
      variables - string variables that should be taken into account. For examples: parse("a", LEX) and parse("a", LEX, "a", "b") although give the same mathematical expressions are differ, since the first one is considered as Z[x], while the second as Z[x1,x2]
      Returns:
      multivariate polynomial
    • parse

      @Deprecated public static <E> MultivariatePolynomial<E> parse​(String string, Ring<E> ring)
      Deprecated.
      use #parse(string, ring, ordering, variables)
      Parse multivariate polynomial from string.
      Parameters:
      string - the string
      ring - the ring
      Returns:
      multivariate polynomial
    • parse

      public static MultivariatePolynomial<BigInteger> parse​(String string, Comparator<DegreeVector> ordering, String... variables)
      Parse multivariate Z[X] polynomial from string.
      Parameters:
      string - the string
      ordering - monomial order
      variables - string variables that should be taken into account. For examples: parse("a", LEX) and parse("a", LEX, "a", "b") although give the same mathematical expressions are differ, since the first one is considered as Z[x], while the second as Z[x1,x2]
      Returns:
      Z[X] multivariate polynomial
    • parse

      @Deprecated public static MultivariatePolynomial<BigInteger> parse​(String string, Comparator<DegreeVector> ordering)
      Deprecated.
      use #parse(string, ring, ordering, variables)
      Parse multivariate Z[X] polynomial from string.
      Parameters:
      string - the string
      ordering - monomial order
      Returns:
      Z[X] multivariate polynomial
    • parse

      public static <E> MultivariatePolynomial<E> parse​(String string, Ring<E> ring, Comparator<DegreeVector> ordering, String... variables)
      Parse multivariate polynomial from string.
      Parameters:
      string - the string
      ring - the ring
      ordering - monomial order
      variables - string variables that should be taken into account. For examples: parse("a", LEX) and parse("a", LEX, "a", "b") although give the same mathematical expressions are different, since the first one is considered as Z[a], while the second as Z[a,b]
      Returns:
      multivariate polynomial
    • parse

      @Deprecated public static <E> MultivariatePolynomial<E> parse​(String string, Ring<E> ring, Comparator<DegreeVector> ordering)
      Deprecated.
      use #parse(string, ring, ordering, variables)
      Parse multivariate polynomial from string.
      Parameters:
      string - the string
      ring - the ring
      ordering - monomial order
    • asOverZp64

      public static MultivariatePolynomialZp64 asOverZp64​(MultivariatePolynomial<BigInteger> poly)
      Converts multivariate polynomial over BigIntegers to multivariate polynomial over machine modular integers
      Parameters:
      poly - the polynomial
      Returns:
      multivariate polynomial over machine sized modular integers
      Throws:
      IllegalArgumentException - if poly.ring is not Zp
      ArithmeticException - if some of coefficients will not exactly fit in a long.
    • asOverZp64

      public static MultivariatePolynomialZp64 asOverZp64​(MultivariatePolynomial<BigInteger> poly, IntegersZp64 ring)
      Converts multivariate polynomial over BigIntegers to multivariate polynomial over machine modular integers
      Parameters:
      poly - the polynomial
      ring - Zp64 ring
      Returns:
      multivariate polynomial over machine sized modular integers
      Throws:
      IllegalArgumentException - if poly.ring is not Zp
      ArithmeticException - if some of coefficients will not exactly fit in a long.
    • asMultivariate

      public static <E> MultivariatePolynomial<E> asMultivariate​(UnivariatePolynomial<E> poly, int nVariables, int variable, Comparator<DegreeVector> ordering)
      Converts univariate polynomial to multivariate.
      Parameters:
      poly - univariate polynomial
      nVariables - number of variables in the result
      variable - variable that will be used as a primary variable
      ordering - monomial order
      Returns:
      multivariate polynomial
    • asUnivariate

      public UnivariatePolynomial<E> asUnivariate()
      Description copied from class: AMultivariatePolynomial
      Converts this to univariate polynomial or throws exception if conversion is impossible (more than one variable have non zero exponents)
      Specified by:
      asUnivariate in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
      Returns:
      univariate polynomial
    • asOverUnivariate

      public MultivariatePolynomial<UnivariatePolynomial<E>> asOverUnivariate​(int variable)
      Description copied from class: AMultivariatePolynomial
      Converts this to a multivariate polynomial with coefficients being univariate polynomials over variable
      Specified by:
      asOverUnivariate in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
      Parameters:
      variable - variable
      Returns:
      multivariate polynomial with coefficients being univariate polynomials over variable
    • asOverUnivariateEliminate

      public MultivariatePolynomial<UnivariatePolynomial<E>> asOverUnivariateEliminate​(int variable)
      Description copied from class: AMultivariatePolynomial
      Converts this to a multivariate polynomial with coefficients being univariate polynomials over variable, the resulting polynomial have (nVariable - 1) multivariate variables (specified variable is eliminated)
      Specified by:
      asOverUnivariateEliminate in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
      Parameters:
      variable - the variable
      Returns:
      multivariate polynomial with coefficients being univariate polynomials over variable, the resulting polynomial have (nVariable - 1) multivariate variables
    • asOverMultivariate

      public MultivariatePolynomial<MultivariatePolynomial<E>> asOverMultivariate​(int... variables)
      Description copied from class: AMultivariatePolynomial
      Converts this to a multivariate polynomial with coefficients being multivariate polynomials polynomials over variables that is polynomial in R[variables][other_variables]
      Specified by:
      asOverMultivariate in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
      Parameters:
      variables - the variables to separate
      Returns:
      multivariate polynomial with coefficients being multivariate polynomials polynomials over variables that is polynomial in R[variables][other_variables]
    • asOverMultivariateEliminate

      public MultivariatePolynomial<MultivariatePolynomial<E>> asOverMultivariateEliminate​(int[] variables, Comparator<DegreeVector> ordering)
      Description copied from class: AMultivariatePolynomial
      Converts this to a multivariate polynomial with coefficients being multivariate polynomials polynomials over variables that is polynomial in R[variables][other_variables]
      Specified by:
      asOverMultivariateEliminate in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
      Parameters:
      variables - the variables to separate
      ordering - monomial order to use for result
      Returns:
      multivariate polynomial with coefficients being multivariate polynomials polynomials over variables that is polynomial in R[variables][other_variables]
    • asNormalMultivariate

      public static <E> MultivariatePolynomial<E> asNormalMultivariate​(MultivariatePolynomial<UnivariatePolynomial<E>> poly, int variable)
      Converts multivariate polynomial over univariate polynomial ring (R[variable][other_variables]) to a multivariate polynomial over coefficient ring (R[variables])
      Parameters:
      poly - the polynomial
      variable - the variable to insert
      Returns:
      multivariate polynomial over normal coefficient ring
    • asNormalMultivariate

      public static <E> MultivariatePolynomial<E> asNormalMultivariate​(MultivariatePolynomial<MultivariatePolynomial<E>> poly)
      Converts multivariate polynomial over multivariate polynomial ring to a multivariate polynomial over coefficient ring
      Parameters:
      poly - the polynomial
      Returns:
      multivariate polynomial over normal coefficient ring
    • asNormalMultivariate

      public static <E> MultivariatePolynomial<E> asNormalMultivariate​(MultivariatePolynomial<MultivariatePolynomial<E>> poly, int[] coefficientVariables, int[] mainVariables)
      Converts multivariate polynomial over multivariate polynomial ring to a multivariate polynomial over coefficient ring
      Parameters:
      poly - the polynomial
      Returns:
      multivariate polynomial over normal coefficient ring
    • asPolyZ

      public static MultivariatePolynomial<BigInteger> asPolyZ​(MultivariatePolynomial<BigInteger> poly, boolean copy)
      Returns Z[X] polynomial formed from the coefficients of the poly.
      Parameters:
      poly - the polynomial
      copy - whether to copy the internal data
      Returns:
      Z[X] version of the poly
    • asPolyZSymmetric

      public static MultivariatePolynomial<BigInteger> asPolyZSymmetric​(MultivariatePolynomial<BigInteger> poly)
      Converts Zp[x] polynomial to Z[x] polynomial formed from the coefficients of this represented in symmetric modular form (-modulus/2 <= cfx <= modulus/2).
      Parameters:
      poly - Zp polynomial
      Returns:
      Z[x] version of the poly with coefficients represented in symmetric modular form (-modulus/2 <= cfx <= modulus/2).
      Throws:
      IllegalArgumentException - is poly.ring is not a IntegersZp
    • contentAsPoly

      public MultivariatePolynomial<E> contentAsPoly()
      Description copied from interface: IPolynomial
      Returns the content of this (gcd of coefficients) as a constant poly
    • lcAsPoly

      public MultivariatePolynomial<E> lcAsPoly()
      Description copied from interface: IPolynomial
      Returns the leading coefficient as a constant poly
    • lcAsPoly

      public MultivariatePolynomial<E> lcAsPoly​(Comparator<DegreeVector> ordering)
      Description copied from class: AMultivariatePolynomial
      Returns the leading coefficient with respect to specified ordering as a constant poly
      Specified by:
      lcAsPoly in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
    • ccAsPoly

      public MultivariatePolynomial<E> ccAsPoly()
      Description copied from interface: IPolynomial
      Returns the constant coefficient as a constant poly
    • isOverField

      public boolean isOverField()
      Description copied from interface: IPolynomial
      Returns whether the coefficient ring of this polynomial is a field
      Returns:
      whether the coefficient ring of this polynomial is a field
    • isOverFiniteField

      public boolean isOverFiniteField()
      Description copied from interface: IPolynomial
      Returns whether the coefficient ring of this polynomial is a finite field
      Returns:
      whether the coefficient ring of this polynomial is a finite field
    • isOverZ

      public boolean isOverZ()
      Description copied from interface: IPolynomial
      Returns whether the coefficient ring of this polynomial is Z
      Returns:
      whether the coefficient ring of this polynomial is Z
    • coefficientRingCardinality

      public BigInteger coefficientRingCardinality()
      Description copied from interface: IPolynomial
      Returns cardinality of the coefficient ring of this poly
      Returns:
      cardinality of the coefficient ring
    • coefficientRingCharacteristic

      public BigInteger coefficientRingCharacteristic()
      Description copied from interface: IPolynomial
      Returns characteristic of the coefficient ring of this poly
      Returns:
      characteristic of the coefficient ring
    • isOverPerfectPower

      public boolean isOverPerfectPower()
      Description copied from interface: IPolynomial
      Returns whether the coefficientRingCardinality() is a perfect power
      Returns:
      whether the coefficientRingCardinality() is a perfect power
    • coefficientRingPerfectPowerBase

      public BigInteger coefficientRingPerfectPowerBase()
      Description copied from interface: IPolynomial
      Returns base so that coefficientRingCardinality() == base^exponent or null if cardinality is not finite
      Returns:
      base so that coefficientRingCardinality() == base^exponent or null if cardinality is not finite
    • coefficientRingPerfectPowerExponent

      public BigInteger coefficientRingPerfectPowerExponent()
      Description copied from interface: IPolynomial
      Returns exponent so that coefficientRingCardinality() == base^exponent or null if cardinality is not finite
      Returns:
      exponent so that coefficientRingCardinality() == base^exponent or null if cardinality is not finite
    • createArray

      public MultivariatePolynomial<E>[] createArray​(int length)
      Description copied from interface: IPolynomial
      overcome Java generics...
    • createArray2d

      public MultivariatePolynomial<E>[][] createArray2d​(int length)
      Description copied from interface: IPolynomial
      overcome Java generics...
    • createArray2d

      public MultivariatePolynomial<E>[][] createArray2d​(int length1, int length2)
      Description copied from interface: IPolynomial
      overcome Java generics...
    • sameCoefficientRingWith

      public boolean sameCoefficientRingWith​(MultivariatePolynomial<E> oth)
      Description copied from interface: IPolynomial
      Returns whether oth and this have the same coefficient ring
      Parameters:
      oth - other polynomial
      Returns:
      whether this and oth are over the same coefficient ring
    • setCoefficientRingFrom

      public MultivariatePolynomial<E> setCoefficientRingFrom​(MultivariatePolynomial<E> poly)
      Description copied from interface: IPolynomial
      Set the coefficient ring from specified poly
      Parameters:
      poly - the polynomial
      Returns:
      a copy of this with the coefficient ring taken from poly
    • release

      protected void release()
      release caches
      Overrides:
      release in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
    • setRing

      public MultivariatePolynomial<E> setRing​(Ring<E> newRing)
      Returns a copy of this with coefficient reduced to a newRing
      Parameters:
      newRing - the new ring
      Returns:
      a copy of this reduced to the ring specified by newRing
    • setRingUnsafe

      public MultivariatePolynomial<E> setRingUnsafe​(Ring<E> newRing)
      internal API
    • createConstant

      public MultivariatePolynomial<E> createConstant​(E val)
      Creates constant polynomial with specified value
      Parameters:
      val - value
      Returns:
      constant polynomial with specified value
    • createConstantFromTerm

      public MultivariatePolynomial<E> createConstantFromTerm​(Monomial<E> monomial)
      Description copied from class: AMultivariatePolynomial
      Creates multivariate polynomial over the same ring as this with the single constant element taken from given monomial
      Specified by:
      createConstantFromTerm in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
      Parameters:
      monomial - the monomial
      Returns:
      multivariate polynomial
    • createZero

      public MultivariatePolynomial<E> createZero()
      Description copied from interface: IPolynomial
      Returns the new instance of zero polynomial (with the same coefficient ring)
      Returns:
      new instance of 0
    • createOne

      public MultivariatePolynomial<E> createOne()
      Description copied from interface: IPolynomial
      Returns the new instance of unit polynomial (with the same coefficient ring)
      Returns:
      new instance of 1
    • createLinear

      public final MultivariatePolynomial<E> createLinear​(int variable, E cc, E lc)
      Creates linear polynomial of the form cc + lc * variable
      Parameters:
      variable - the variable
      cc - the constant coefficient
      lc - the leading coefficient
      Returns:
      linear polynomial cc + lc * variable
    • isMonic

      public boolean isMonic()
      Description copied from interface: IPolynomial
      Returns true if this polynomial is monic
      Returns:
      whether this is monic
    • signumOfLC

      public int signumOfLC()
      Description copied from interface: IPolynomial
      Gives signum of the leading coefficient
      Returns:
      signum of the leading coefficient
    • isOne

      public boolean isOne()
      Description copied from interface: IPolynomial
      Returns true if this is one
      Returns:
      whether this is one
    • isUnitCC

      public boolean isUnitCC()
      Description copied from interface: IPolynomial
      Returns true if constant term is equal to one
      Returns:
      whether constant term is 1
    • isConstant

      public boolean isConstant()
      Description copied from interface: IPolynomial
      Returns true if this polynomial has only constant term
      Returns:
      whether this is constant
    • maxAbsCoefficient

      public E maxAbsCoefficient()
      Returns max absolute coefficient
    • lc

      public E lc()
      Returns the leading coefficient of this polynomial that is coefficient of the largest term according to the ordering.
      Returns:
      leading coefficient of this polynomial
    • lc

      public E lc​(Comparator<DegreeVector> ordering)
      Returns the leading coefficient of this polynomial with respect to specified ordering
      Returns:
      leading coefficient of this polynomial with respect to specified ordering
    • setLC

      public MultivariatePolynomial<E> setLC​(E val)
      Sets the leading coefficient to the specified value
      Parameters:
      val - new value for the lc
      Returns:
      the leading coefficient to the specified value
    • cc

      public E cc()
      Returns the constant coefficient of this polynomial.
      Returns:
      constant coefficient of this polynomial
    • content

      public E content()
      Returns the content of this polynomial.
      Returns:
      content of this polynomial
    • coefficients

      public Iterable<E> coefficients()
      Returns iterable over polynomial coefficients
      Returns:
      iterable over polynomial coefficients
    • coefficientsArray

      public E[] coefficientsArray()
      Returns array of polynomial coefficients
      Returns:
      array of polynomial coefficients
    • primitivePart

      public MultivariatePolynomial<E> primitivePart​(int variable)
      Description copied from class: AMultivariatePolynomial
      Gives primitive part of this considered as R[variable][other_variables]
      Specified by:
      primitivePart in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
      Parameters:
      variable - the variable
      Returns:
      primitive part of this considered as R[variable][other_variables]
    • contentUnivariate

      public UnivariatePolynomial<E> contentUnivariate​(int variable)
      Description copied from class: AMultivariatePolynomial
      Gives the content of this considered as R[variable][other_variables]
      Specified by:
      contentUnivariate in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
      Parameters:
      variable - the variable
      Returns:
      the content of this considered as R[variable][other_variables]
    • primitivePart

      public MultivariatePolynomial<E> primitivePart()
      Description copied from interface: IPolynomial
      Reduces poly to its primitive part (primitive part will always have positive l.c.)
      Returns:
      primitive part (poly will be modified)
    • primitivePartSameSign

      public MultivariatePolynomial<E> primitivePartSameSign()
      Description copied from interface: IPolynomial
      Reduces poly to its primitive part, so that primitive part will have the same signum as the initial poly
      Returns:
      primitive part (poly will be modified)
    • divideByLC

      public MultivariatePolynomial<E> divideByLC​(MultivariatePolynomial<E> other)
      Description copied from interface: IPolynomial
      Divides this polynomial by the leading coefficient of other or returns null (causing loss of internal data) if some of the elements can't be exactly divided by the other.lc(). NOTE: if null is returned, the content of this is destroyed.
      Parameters:
      other - the polynomial
      Returns:
      this divided by the other.lc() or null if exact division is not possible
    • divideOrNull

      public MultivariatePolynomial<E> divideOrNull​(E factor)
      Divides this polynomial by a factor or returns null (causing loss of internal data) if some of the elements can't be exactly divided by the factor. NOTE: if null is returned, the content of this is destroyed.
      Parameters:
      factor - the factor
      Returns:
      this divided by the factor or null
    • divideExact

      public MultivariatePolynomial<E> divideExact​(E factor)
      Divides this polynomial by a factor or throws exception if exact division is not possible
      Parameters:
      factor - the factor
      Returns:
      this divided by the factor
      Throws:
      ArithmeticException - if exact division is not possible
    • divideOrNull

      public MultivariatePolynomial<E> divideOrNull​(Monomial<E> monomial)
      Description copied from class: AMultivariatePolynomial
      Divides this polynomial by a monomial or returns null (causing loss of internal data) if some of the elements can't be exactly divided by the monomial. NOTE: if null is returned, the content of this is destroyed.
      Specified by:
      divideOrNull in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
      Parameters:
      monomial - monomial degrees
      Returns:
      this divided by the factor * monomial or null
    • monic

      public MultivariatePolynomial<E> monic()
      Makes this polynomial monic if possible, if not -- destroys this and returns null
      Returns:
      monic this or null if the ring does not support exact division by lc
    • monic

      public MultivariatePolynomial<E> monic​(Comparator<DegreeVector> ordering)
      Description copied from class: AMultivariatePolynomial
      Make this poly monic considering leading term with respect to given ordering
      Specified by:
      monic in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
    • monic

      public MultivariatePolynomial<E> monic​(E factor)
      Sets this to its monic part multiplied by the factor modulo modulus (that is monic(modulus).multiply(factor) ).
      Parameters:
      factor - the factor
      Returns:
      this
    • monic

      public MultivariatePolynomial<E> monic​(Comparator<DegreeVector> ordering, E factor)
      Sets this to its monic part (with respect to given ordering) multiplied by the given factor;
    • monicWithLC

      public MultivariatePolynomial<E> monicWithLC​(MultivariatePolynomial<E> other)
      Description copied from interface: IPolynomial
      Sets this to its monic part multiplied by the leading coefficient of other;
      Parameters:
      other - other polynomial
      Returns:
      monic part multiplied by the leading coefficient of other or null if exact division by the reduced leading coefficient is not possible
    • monicWithLC

      public MultivariatePolynomial<E> monicWithLC​(Comparator<DegreeVector> ordering, MultivariatePolynomial<E> other)
      Description copied from class: AMultivariatePolynomial
      Sets this to its monic part multiplied by the leading coefficient of other with respect to given ordering
      Specified by:
      monicWithLC in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
    • toDenseRecursiveForm

      public UnivariatePolynomial toDenseRecursiveForm()
      Gives a recursive univariate representation of this poly.
    • fromDenseRecursiveForm

      public static <E> MultivariatePolynomial<E> fromDenseRecursiveForm​(UnivariatePolynomial recForm, int nVariables, Comparator<DegreeVector> ordering)
      Converts poly from a recursive univariate representation.
      Parameters:
      recForm - recursive univariate representation
      nVariables - number of variables in multivariate polynomial
      ordering - monomial order
    • evaluateDenseRecursiveForm

      public static <E> E evaluateDenseRecursiveForm​(UnivariatePolynomial recForm, int nVariables, E[] values)
      Evaluates polynomial given in a dense recursive form at a given points
    • toSparseRecursiveForm

      public AMultivariatePolynomial toSparseRecursiveForm()
      Gives a recursive sparse univariate representation of this poly.
    • fromSparseRecursiveForm

      public static <E> MultivariatePolynomial<E> fromSparseRecursiveForm​(AMultivariatePolynomial recForm, int nVariables, Comparator<DegreeVector> ordering)
      Converts poly from a recursive univariate representation.
      Parameters:
      recForm - recursive univariate representation
      nVariables - number of variables in multivariate polynomial
      ordering - monomial order
    • evaluateSparseRecursiveForm

      public static <E> E evaluateSparseRecursiveForm​(AMultivariatePolynomial recForm, int nVariables, E[] values)
      Evaluates polynomial given in a sparse recursive form at a given points
    • getHornerForm

      public MultivariatePolynomial.HornerForm getHornerForm​(int[] evaluationVariables)
      Gives data structure for fast Horner-like sparse evaluation of this multivariate polynomial
      Parameters:
      evaluationVariables - variables which will be substituted
    • evaluate

      public MultivariatePolynomial<E> evaluate​(int variable, E value)
      Returns a copy of this with value substituted for variable.
      Parameters:
      variable - the variable
      value - the value
      Returns:
      a new multivariate polynomial with value substituted for variable but still with the same AMultivariatePolynomial.nVariables (though the effective number of variables is nVariables - 1, compare to eliminate(int, Object))
      See Also:
      eliminate(int, Object)
    • evaluate

      public E evaluate​(E... values)
      Evaluates this polynomial at specified points
    • evaluate

      public MultivariatePolynomial<E> evaluate​(int[] variables, E[] values)
      Returns a copy of this with values substituted for variables.
      Parameters:
      variables - the variables
      values - the values
      Returns:
      a new multivariate polynomial with value substituted for variable but still with the same AMultivariatePolynomial.nVariables (though the effective number of variables is nVariables - 1, compare to eliminate(int, Object))
      See Also:
      eliminate(int, Object)
    • evaluate

      public MultivariatePolynomial<E>[] evaluate​(int variable, E... values)
      Evaluates this polynomial at specified points
    • evaluate

      public MultivariatePolynomial<E> evaluate​(int variable, long value)
      Returns a copy of this with value substituted for variable.
      Parameters:
      variable - the variable
      value - the value
      Returns:
      a new multivariate polynomial with value substituted for variable but still with the same AMultivariatePolynomial.nVariables (though the effective number of variables is nVariables - 1, compare to eliminate(int, long))
      See Also:
      eliminate(int, long)
    • eliminate

      public MultivariatePolynomial<E> eliminate​(int variable, E value)
      Substitutes value for variable and eliminates variable from the list of variables so that the resulting polynomial has result.nVariables = this.nVariables - 1.
      Parameters:
      variable - the variable
      value - the value
      Returns:
      a new multivariate polynomial with value substituted for variable and nVariables = nVariables - 1)
      See Also:
      evaluate(int, Object)
    • eliminate

      public MultivariatePolynomial<E> eliminate​(int variable, long value)
      Substitutes value for variable and eliminates variable from the list of variables so that the resulting polynomial has result.nVariables = this.nVariables - 1.
      Parameters:
      variable - the variable
      value - the value
      Returns:
      a new multivariate polynomial with value substituted for variable and nVariables = nVariables - 1)
      See Also:
      evaluate(int, long)
    • eliminate

      public MultivariatePolynomial<E> eliminate​(int[] variables, E[] values)
      Returns a copy of this with values substituted for variables
      Parameters:
      variables - the variables
      values - the values
      Returns:
      a new multivariate polynomial with value substituted for variable but still with the same AMultivariatePolynomial.nVariables (though the effective number of variables is nVariables - 1, compare to eliminate(int, long))
    • mkPrecomputedPowers

      public MultivariatePolynomial.PrecomputedPowersHolder<E> mkPrecomputedPowers​(int variable, E value)
    • mkPrecomputedPowers

      public MultivariatePolynomial.PrecomputedPowersHolder<E> mkPrecomputedPowers​(int[] variables, E[] values)
    • mkPrecomputedPowers

      public static <E> MultivariatePolynomial.PrecomputedPowersHolder<E> mkPrecomputedPowers​(int nVariables, Ring<E> ring, int[] variables, E[] values)
    • mkPrecomputedPowers

      public MultivariatePolynomial.PrecomputedPowersHolder<E> mkPrecomputedPowers​(E[] values)
    • substitute

      public MultivariatePolynomial<E> substitute​(int variable, MultivariatePolynomial<E> poly)
      Returns a copy of this with poly substituted for variable.
      Parameters:
      variable - the variable
      poly - the replacement for the variable
      Returns:
      a copy of this with variable -> poly
    • shift

      public MultivariatePolynomial<E> shift​(int variable, long shift)
      Returns a copy of this with variable -> variable + shift
      Parameters:
      variable - the variable
      shift - shift amount
      Returns:
      a copy of this with variable -> variable + shift
    • shift

      public MultivariatePolynomial<E> shift​(int variable, E shift)
      Returns a copy of this with variable -> variable + shift
      Parameters:
      variable - the variable
      shift - shift amount
      Returns:
      a copy of this with variable -> variable + shift
    • shift

      public MultivariatePolynomial<E> shift​(int[] variables, E[] shifts)
      Returns a copy of this with variables -> variables + shifts
      Parameters:
      variables - the variables
      shifts - the corresponding shifts
      Returns:
      a copy of this with variables -> variables + shifts
    • add

      public MultivariatePolynomial<E> add​(E oth)
      Adds oth to this polynomial
      Parameters:
      oth - other polynomial
      Returns:
      this + oth
    • subtract

      public MultivariatePolynomial<E> subtract​(E oth)
      Subtracts oth from this polynomial
      Parameters:
      oth - other polynomial
      Returns:
      this - oth
    • increment

      public MultivariatePolynomial<E> increment()
      Description copied from interface: IPolynomial
      Adds 1 to this
      Returns:
      this + 1
    • decrement

      public MultivariatePolynomial<E> decrement()
      Description copied from interface: IPolynomial
      Subtracts 1 from this
      Returns:
      this - 1
    • multiply

      public MultivariatePolynomial<E> multiply​(E factor)
      Multiplies this by the factor
      Parameters:
      factor - the factor
      Returns:
      this multiplied by the factor
    • multiplyByLC

      public MultivariatePolynomial<E> multiplyByLC​(MultivariatePolynomial<E> other)
      Description copied from interface: IPolynomial
      Multiply this by the leading coefficient of other
      Parameters:
      other - polynomial
      Returns:
      this * lc(other)
    • multiply

      public MultivariatePolynomial<E> multiply​(Monomial<E> monomial)
      Description copied from class: AMultivariatePolynomial
      Multiplies this by the monomial
      Specified by:
      multiply in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
      Parameters:
      monomial - the monomial
      Returns:
      this multiplied by the monomial
    • multiply

      public MultivariatePolynomial<E> multiply​(long factor)
      Description copied from interface: IPolynomial
      Multiplies this by factor
      Parameters:
      factor - the factor
      Returns:
      this * factor
    • multiplyByBigInteger

      public MultivariatePolynomial<E> multiplyByBigInteger​(BigInteger factor)
      Description copied from interface: IPolynomial
      Multiplies this by factor
      Parameters:
      factor - the factor
      Returns:
      this * factor
    • multiply

      public MultivariatePolynomial<E> multiply​(MultivariatePolynomial<E> oth)
      Description copied from interface: IPolynomial
      Multiplies this by oth
      Parameters:
      oth - the polynomial
      Returns:
      this * oth
    • square

      public MultivariatePolynomial<E> square()
      Description copied from interface: IPolynomial
      Squares this
      Returns:
      this * this
    • evaluateAtRandom

      public MultivariatePolynomial<E> evaluateAtRandom​(int variable, org.apache.commons.math3.random.RandomGenerator rnd)
      Description copied from class: AMultivariatePolynomial
      Evaluates poly at random point
      Specified by:
      evaluateAtRandom in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
    • evaluateAtRandomPreservingSkeleton

      public MultivariatePolynomial<E> evaluateAtRandomPreservingSkeleton​(int variable, org.apache.commons.math3.random.RandomGenerator rnd)
      Description copied from class: AMultivariatePolynomial
      Evaluates poly at random point chosen in such way that the skeleton of evaluated version is the same as of the original poly with respect to all except variable variables
      Specified by:
      evaluateAtRandomPreservingSkeleton in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
    • derivative

      public MultivariatePolynomial<E> derivative​(int variable, int order)
      Description copied from class: AMultivariatePolynomial
      Gives partial derivative of specified order with respect to specified variable (new instance created)
      Specified by:
      derivative in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
      Parameters:
      variable - the variable
      order - derivative order
      Returns:
      partial derivative of specified order with respect to specified variable
    • seriesCoefficient

      public MultivariatePolynomial<E> seriesCoefficient​(int variable, int order)
      Description copied from class: AMultivariatePolynomial
      Gives (unevaluated) coefficient of Taylor series expansion for specified variable that is derivative(poly, variable, order) / order! , where the derivative is formal derivative and calculated with arithmetic performed in Z ring (to overcome possible zeros in Zp).
      Specified by:
      seriesCoefficient in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
      Parameters:
      variable - the variable
      order - derivative order
      Returns:
      derivative(poly, variable, order) / order! , where the derivative is formal derivative and calculated with arithmetic performed in Z ring (to overcome possible zeros in Zp)
    • stream

      public Stream<E> stream()
      Returns a stream of coefficients of this
      Returns:
      stream of coefficients
    • mapTerms

      public <T> MultivariatePolynomial<T> mapTerms​(Ring<T> newRing, Function<Monomial<E>,​Monomial<T>> mapper)
      Maps terms of this using specified mapping function
      Type Parameters:
      T - new element type
      Parameters:
      newRing - the new ring
      mapper - mapping
      Returns:
      a new polynomial with terms obtained by applying mapper to this terms
    • mapCoefficients

      public <T> MultivariatePolynomial<T> mapCoefficients​(Ring<T> newRing, Function<E,​T> mapper)
      Maps coefficients of this using specified mapping function
      Type Parameters:
      T - new element type
      Parameters:
      newRing - the new ring
      mapper - mapping
      Returns:
      a new polynomial with terms obtained by applying mapper to this terms (only coefficients are changed)
    • mapCoefficientsZp64

      public MultivariatePolynomialZp64 mapCoefficientsZp64​(IntegersZp64 newDomain, ToLongFunction<E> mapper)
      Maps coefficients of this using specified mapping function
      Parameters:
      newDomain - the new ring
      mapper - mapping
      Returns:
      a new polynomial with terms obtained by applying mapper to this terms (only coefficients are changed)
    • mapCoefficientsAsPolys

      public <T> MultivariatePolynomial<T> mapCoefficientsAsPolys​(Ring<T> ring, Function<MultivariatePolynomial<E>,​T> mapper)
      Specified by:
      mapCoefficientsAsPolys in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
    • compareTo

      public int compareTo​(MultivariatePolynomial<E> oth)
    • clone

      public MultivariatePolynomial<E> clone()
      Description copied from interface: IPolynomial
      Deep copy of this
      Specified by:
      clone in interface IPolynomial<E>
      Specified by:
      clone in class AMultivariatePolynomial<Monomial<E>,​MultivariatePolynomial<E>>
      Returns:
      deep copy of this
    • parsePoly

      @Deprecated public MultivariatePolynomial<E> parsePoly​(String string)
      Deprecated.
    • toString

      public String toString​(IStringifier<MultivariatePolynomial<E>> stringifier)
      Description copied from interface: Stringifiable
      convert this to string with the use of stringifier
    • coefficientRingToString

      public String coefficientRingToString​(IStringifier<MultivariatePolynomial<E>> stringifier)
      Description copied from interface: IPolynomial
      String representation of the coefficient ring of this