Class AMultivariatePolynomial<Term extends AMonomial<Term>,Poly extends AMultivariatePolynomial<Term,Poly>>
- java.lang.Object
-
- cc.redberry.rings.poly.multivar.AMultivariatePolynomial<Term,Poly>
-
- Type Parameters:
Term- type of monomialsPoly- type of this (self-type)
- All Implemented Interfaces:
Stringifiable<Poly>,IPolynomial<Poly>,Serializable,Comparable<Poly>,Iterable<Term>
- Direct Known Subclasses:
MultivariatePolynomial,MultivariatePolynomialZp64
public abstract class AMultivariatePolynomial<Term extends AMonomial<Term>,Poly extends AMultivariatePolynomial<Term,Poly>> extends Object implements IPolynomial<Poly>, Iterable<Term>
Parent class for multivariate polynomials.Variables:
The number of variables is invariant, which means that binary arithmetic operations on polynomials with different number of variables (see
nVariables) are prohibited. Of course all exponents of particular variable may be zero, so e.g.
will have nVariables == 3 while "z" is actually absent in the poly.MultivariatePolynomial.parse("x^2 + 2*x*y + y^3", "x", "y", "z")Particular string names of variables are not stored in the polynomial data structure, instead the variables are treated as consequent integer numbers (0, 1, 2,...), where 0 states for the first variable, 1 for the second etc. Information about variables is accessible by the integer index of the variable. The mapping between the variable index and its string representation should be stored separately outside this class. For example:
// x is the first variable, y is the second String[] variables = {"x", "y"}; MultivariatePolynomial<BigInteger> poly = MultivariatePolynomial.parse("x^2 + 2*x*y + y^3", variables); // degree in x int xDegree = poly.degree(0); assert xDegree == 2; // degree in y int yDegree = poly.degree(1); assert yDegree == 3; // will use the specified mapping and print x^2 + 2*x*y + y^3 System.out.println(poly.toString(variables)); // will use the default mapping and print a^2 + 2*a*b + b^3 System.out.println(poly.toString());Terms storage and ordering:
Terms of multivariate polynomial are stored in a sorted map
DegreeVector -> Monomial(seeMonomialSet). The order of monomials is defined by theComparator<DegreeVector>which possible values areMonomialOrder.LEX,MonomialOrder.ALEX,MonomialOrder.GREVLEXandMonomialOrder.GRLEX. All operations on the instances of this will preserve the ordering of this. The leading term of the poly is defined with respect to this ordering.- Since:
- 1.0
- See Also:
IPolynomial,MultivariatePolynomialZp64,MultivariatePolynomial, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAMultivariatePolynomial.PolynomialCollector<Term extends AMonomial<Term>,Poly extends AMultivariatePolynomial<Term,Poly>>Collector which collects stream of element to a UnivariatePolynomial
-
Field Summary
Fields Modifier and Type Field Description IMonomialAlgebra<Term>monomialAlgebraMonomial algebraintnVariablesThe number of variablesComparator<DegreeVector>orderingThe ordering
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Polyadd(Iterable<Term> monomials)Adds monomials to this polynomialPolyadd(Poly oth)Addsothtothis.Polyadd(Term monomial)Addsmonomialto this polynomialPolyadd(Term... monomials)Adds monomials to this polynomialIterator<Term>ascendingIterator()static <Term extends AMonomial<Term>,Poly extends AMultivariatePolynomial<Term,Poly>>
PolyasMultivariate(IUnivariatePolynomial poly, int nVariables, int variable, Comparator<DegreeVector> ordering)Converts univariate polynomial to multivariate.static <Term extends AMonomial<Term>,Poly extends AMultivariatePolynomial<Term,Poly>>
PolyasMultivariate(UnivariatePolynomial<Poly> uPoly, int variable)Convert univariate polynomial over multivariate polynomials to a normal multivariate polystatic <Term extends AMonomial<Term>,Poly extends AMultivariatePolynomial<Term,Poly>>
PolyasMultivariate(UnivariatePolynomial<Poly> univariate, int uVariable, boolean join)abstract MultivariatePolynomial<Poly>asOverMultivariate(int... variables)Converts this to a multivariate polynomial with coefficients being multivariate polynomials polynomials overvariablesthat is polynomial in R[variables][other_variables]MultivariatePolynomial<Poly>asOverMultivariateEliminate(int... variables)Converts this to a multivariate polynomial with coefficients being multivariate polynomials polynomials overvariablesthat is polynomial in R[variables][other_variables]abstract MultivariatePolynomial<Poly>asOverMultivariateEliminate(int[] variables, Comparator<DegreeVector> ordering)Converts this to a multivariate polynomial with coefficients being multivariate polynomials polynomials overvariablesthat is polynomial in R[variables][other_variables]MultivariatePolynomial<Poly>asOverPoly(Poly factory)Consider coefficients of this as constant polynomials of the same type as a given factory polynomialabstract MultivariatePolynomial<? extends IUnivariatePolynomial>asOverUnivariate(int variable)Converts this to a multivariate polynomial with coefficients being univariate polynomials overvariableabstract MultivariatePolynomial<? extends IUnivariatePolynomial>asOverUnivariateEliminate(int variable)Converts this to a multivariate polynomial with coefficients being univariate polynomials overvariable, the resulting polynomial have (nVariable - 1) multivariate variables (specifiedvariableis eliminated)abstract IUnivariatePolynomialasUnivariate()Converts this to univariate polynomial or throws exception if conversion is impossible (more than one variable have non zero exponents)UnivariatePolynomial<Poly>asUnivariate(int variable)Converts this polynomial to a univariate polynomial over specified variable with the multivariate coefficient ring.UnivariatePolynomial<Poly>asUnivariateEliminate(int variable)Converts this polynomial to a univariate polynomial over specified variable with the multivariate coefficient ring.abstract Polyclone()Deep copy of thisPolycoefficientOf(int[] variables, int[] exponents)Returns a coefficient beforevariables^exponentsas a multivariate polynomialPolycoefficientOf(int variable, int exponent)Returns a coefficient beforevariable^exponentas a multivariate polynomialCollection<Term>collection()Polycomposition(int[] variables, Poly[] values)Substitutes given polynomial instead of specified variable (that isthis(x_1, ..., value, ..., x_N), where value is on the place of specified variable)Polycomposition(int variable, Poly value)Substitutes given polynomial instead of specified variable (that isthis(x_1, ..., value, ..., x_N), where value is on the place of specified variable)<sPoly extends IUnivariatePolynomial<sPoly>>
sPolycomposition(Ring<sPoly> uRing, sPoly... values)Substitutes given polynomials instead of variables of this (that isthis(values_1, ..., values_N))Polycomposition(List<Poly> values)Substitutes given polynomials instead of variables of this (that isthis(values_1, ..., values_N))Polycomposition(Poly... values)Substitutes given polynomials instead of variables of this (that isthis(values_1, ..., values_N))<sPoly extends IUnivariatePolynomial<sPoly>>
sPolycomposition(sPoly... values)Substitutes given polynomials instead of variables of this (that isthis(values_1, ..., values_N))Polycontent(int variable)Gives the content of this considered as R[variable][other_variables]PolycontentExcept(int variable)Gives the content of this considered as R[other_variables][variable]abstract IUnivariatePolynomialcontentUnivariate(int variable)Gives the content of this considered as R[variable][other_variables]Polycreate(DegreeVector term)Creates multivariate polynomial over the same ring as this with the single monomialPolycreate(Iterable<Term> terms)Creates multivariate polynomial over the same ring as this from the list of monomialsPolycreate(Term term)Creates multivariate polynomial over the same ring as this with the single monomialPolycreate(Term... terms)Creates multivariate polynomial over the same ring as this from the list of monomialsabstract PolycreateConstantFromTerm(Term term)Creates multivariate polynomial over the same ring as this with the single constant element taken from given monomialPolycreateMonomial(int variable, int degree)Creates monomial over the same ring as this of the formvariable ^ degreeintdegree()Returns the total degree of this polynomial, that is the maximal total degree among all termsintdegree(int variable)Returns the degree of this polynomial with respect to specified variableintdegree(int... variables)Gives the degree in specified variablesintdegreeMax()Returns the maximal degree of variables in this polynomialint[]degrees()Returns an array of degrees of all variables, so that is i-th element of the result is the polynomial degree with respect to i-th variableint[]degrees(int variable)Returns the array of exponents in whichvariableoccurs in this polynomialprotected int[]degreesRef()returns reference (content must not be modified)intdegreeSum()Returns the sum ofdegrees()Poly[]derivative()Gives the derivative vectorPolyderivative(int variable)Gives partial derivative with respect to specified variable (new instance created)abstract Polyderivative(int variable, int order)Gives partial derivative of specifiedorderwith respect to specified variable (new instance created)Iterator<Term>descendingIterator()PolydivideDegreeVectorOrNull(DegreeVector monomial)Divides this polynomial by amonomialor returnsnull(causing loss of internal data) if some of the elements can't be exactly divided by themonomial.abstract PolydivideOrNull(Term monomial)Divides this polynomial by amonomialor returnsnull(causing loss of internal data) if some of the elements can't be exactly divided by themonomial.PolydropCoefficientOf(int[] variables, int[] exponents)Returns a coefficient beforevariables^exponentsas a multivariate polynomial and drops all such terms from thisPolydropSelectVariables(int... variables)Makes a copy of this with all variables except specified ones replaced with the unitsPolydropVariable(int variable)Makes a copy of this with the specified variable droppedPolydropVariables(int[] variables)Makes a copy of this with the specified variable replaced with the unitintecart()Returns degreeSum - lt().totalDegreebooleanequals(Object o)abstract PolyevaluateAtRandom(int variable, org.apache.commons.math3.random.RandomGenerator rnd)Evaluatespolyat random pointabstract PolyevaluateAtRandomPreservingSkeleton(int variable, org.apache.commons.math3.random.RandomGenerator rnd)Evaluatespolyat random point chosen in such way that the skeleton of evaluated version is the same as of the originalpolywith respect to all exceptvariablevariablesPolyevaluateAtZero(int variable)Substitutes0forvariable(new instance created).PolyevaluateAtZero(int[] variables)Substitutes0for all specifiedvariables(new instance created).Termfirst()Set<DegreeVector>getSkeleton()Returns skeleton of this polySet<DegreeVector>getSkeleton(int... variables)Returns skeleton of this poly with respect to specifiedvariablesSet<DegreeVector>getSkeletonDrop(int... variables)Returns skeleton of this poly with respect to specifiedvariablesSet<DegreeVector>getSkeletonExcept(int... variables)Returns skeleton of this poly with respect to all except specifiedvariablesinthashCode()Polyhomogenize(int variable)Homogenize poly by adding new (homogenizing) variablePolyinsertVariable(int variable)Makes a copy of this by inserting new variable (the indexes will be shifted)PolyinsertVariable(int variable, int count)Makes a copy of this by inserting new variables (the indexes will be shifted)booleanisEffectiveUnivariate()Returns whether this poly is effectively univariate (not more than one variable is non-unit)booleanisHomogeneous()Returns whether all terms have the same total degreebooleanisLinearExactly()Returns whether this polynomial is linear (i.e.booleanisLinearOrConstant()Returns whether this polynomial is linear (i.e.booleanisMonomial()Returnstrueif this polynomial has only one monomial termbooleanisVariable()Returns whether this is a plain variable (with no coefficient)booleanisZero()Returnstrueif this is zerobooleanisZeroCC()Returns true if constant term is zeroIterator<Term>iterator()PolyjoinNewVariable()Returns a copy of this withnVariables = nVariables + 1PolyjoinNewVariables(int n)Returns a copy of this withnVariables = nVariables + mTermlast()Polylc(int variable)Returns the leading coefficient of this viewed as R[other_variables][variable]abstract PolylcAsPoly(Comparator<DegreeVector> ordering)Returns the leading coefficient with respect to specified ordering as a constant polyTermlt()Returns the leading term in this polynomial according to orderingTermlt(Comparator<DegreeVector> ordering)Returns the leading term in this polynomial according to specified orderingPolyltAsPoly()Returns the leading term in this polynomial according to orderingabstract <E> MultivariatePolynomial<E>mapCoefficientsAsPolys(Ring<E> ring, Function<Poly,E> mapper)PolymapVariables(int[] mapping)Renames old variables to new according to mappingabstract Polymonic(Comparator<DegreeVector> ordering)Make this poly monic considering leading term with respect to given orderingabstract PolymonicWithLC(Comparator<DegreeVector> ordering, Poly oth)Setsthisto its monic part multiplied by the leading coefficient ofotherwith respect to given orderingTermmonomialContent()Returns the monomial content of this polynomialTermmt()Returns the minimal term in this polynomial according to orderingint[]multidegree()Returns the multidegree of this polynomial i.e.abstract Polymultiply(Term monomial)Multipliesthisby themonomialPolymultiplyByDegreeVector(DegreeVector dv)Multipliesthisby the degree vectorPolymultiplyByMonomial(int variable, int exponent)Multiplies this by variable^exponentPolynegate()Negates this and returnsintnUsedVariables()Returns the number of really used variables (those which are not units)abstract PolyprimitivePart(int variable)Gives primitive part of this considered as R[variable][other_variables]Polyput(Term monomial)Putsmonomialto this polynomial replacing the previous entry if wasprotected voidrelease()release cachesstatic <T extends AMonomial<T>,P extends AMultivariatePolynomial<T,P>>
PrenameVariables(P poly, int[] newVariables)Rename variables from [0,1,...N] to [newVariables[0], newVariables[1], ..., newVariables[N]] (new instance created)static <T extends AMonomial<T>,P extends AMultivariatePolynomial<T,P>>
PrenameVariables(P poly, int[] newVariables, Comparator<DegreeVector> newOrdering)Rename variables from [0,1,...N] to [newVariables[0], newVariables[1], ..., newVariables[N]] (new instance created)static <T extends AMonomial<T>>
TrenameVariables(T e, int[] newVariables)Rename variables from [0,1,...N] to [newVariables[0], newVariables[1], ..., newVariables[N]] (new instance created)booleansameSkeletonExceptQ(AMultivariatePolynomial oth, int... variables)Tests whetherthisandothhave the same skeleton with respect all except specifiedvariablesbooleansameSkeletonQ(AMultivariatePolynomial oth)Tests whetherthisandothhave the same skeletonbooleansameSkeletonQ(AMultivariatePolynomial oth, int... variables)Tests whetherthisandothhave the same skeleton with respect to specifiedvariablesabstract PolyseriesCoefficient(int variable, int order)Gives (unevaluated) coefficient of Taylor series expansion for specified variable that isderivative(poly, variable, order) / order!, where the derivative is formal derivative and calculated with arithmetic performed in Z ring (to overcome possible zeros in Zp).Polyset(Poly oth)Sets the content of this toothPolysetAllCoefficientsToUnit()Set all coefficients to unitsPolysetLC(int variable, Poly lc)Set the leading coefficient of specified variable to a specified value (this is considered as R[other_variables][variable])PolysetNVariables(int newNVariables)auxiliary methodPolysetOrdering(Comparator<DegreeVector> newOrdering)Makes a copy of this with the new orderingnewOrderingintsize()Returns the number of terms in this polynomialintskeletonHashCode()doublesparsity()Sparsity level: size / (product of degrees)doublesparsity2()Sparsity level:size / nDenseTermswhere nDenseTerms is a total number of possible distinct terms with total degree not larger than distinct total degrees presented in this.Polysubtract(Poly oth)Subtractsothfromthis.Polysubtract(Term monomial)Subtractsmonomialfrom this polynomialPolysubtract(Term cf, Poly oth)Subtractscf * othfrom this polynomialPolysubtractLt()Removes the leading term from this polynomialstatic <T extends AMonomial<T>,P extends AMultivariatePolynomial<T,P>>
PswapVariables(P poly, int i, int j)Renames variableitojandjtoi(new instance created)Term[]toArray()StringtoString()inttotalDegree()Returns the total degree, that is sum ofdegrees()PolytoZero()Sets this to zerointunivariateVariable()Returns -1 if this poly is not effectively univariate or variable in which it is univariate-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface cc.redberry.rings.poly.IPolynomial
add, assertSameCoefficientRingWith, canonical, ccAsPoly, coefficientRingCardinality, coefficientRingCharacteristic, coefficientRingPerfectPowerBase, coefficientRingPerfectPowerExponent, coefficientRingToString, coefficientRingToString, contentAsPoly, copy, createArray, createArray, createArray, createArray, createArray2d, createArray2d, createConstant, createOne, createZero, decrement, divideByLC, increment, isConstant, isMonic, isOne, isOverField, isOverFiniteField, isOverPerfectPower, isOverZ, isUnitCC, lcAsPoly, monic, monicExact, monicWithLC, multiply, multiply, multiply, multiply, multiplyByBigInteger, multiplyByLC, parsePoly, primitivePart, primitivePartSameSign, sameCoefficientRingWith, setCoefficientRingFrom, setCoefficientRingFromOptional, signumOfLC, square, subtract, toPositiveLC, toString
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface cc.redberry.rings.io.Stringifiable
toString
-
-
-
-
Field Detail
-
nVariables
public final int nVariables
The number of variables
-
ordering
public final Comparator<DegreeVector> ordering
The ordering
-
monomialAlgebra
public final IMonomialAlgebra<Term extends AMonomial<Term>> monomialAlgebra
Monomial algebra
-
-
Method Detail
-
swapVariables
public static <T extends AMonomial<T>,P extends AMultivariatePolynomial<T,P>> P swapVariables(P poly, int i, int j)
Renames variableitojandjtoi(new instance created)- Parameters:
poly- the polynomiali- the first variablej- the second variable- Returns:
- polynomial with variable
irenamed tojandjrenamed toi
-
renameVariables
public static <T extends AMonomial<T>,P extends AMultivariatePolynomial<T,P>> P renameVariables(P poly, int[] newVariables)
Rename variables from [0,1,...N] to [newVariables[0], newVariables[1], ..., newVariables[N]] (new instance created)- Parameters:
poly- the polynomialnewVariables- the new variables- Returns:
- renamed polynomial
-
renameVariables
public static <T extends AMonomial<T>> T renameVariables(T e, int[] newVariables)
Rename variables from [0,1,...N] to [newVariables[0], newVariables[1], ..., newVariables[N]] (new instance created)- Parameters:
e- the termnewVariables- the new variables- Returns:
- renamed term
-
renameVariables
public static <T extends AMonomial<T>,P extends AMultivariatePolynomial<T,P>> P renameVariables(P poly, int[] newVariables, Comparator<DegreeVector> newOrdering)
Rename variables from [0,1,...N] to [newVariables[0], newVariables[1], ..., newVariables[N]] (new instance created)- Parameters:
poly- the polynomialnewVariables- the new variablesnewOrdering- the new ordering- Returns:
- renamed polynomial
-
asMultivariate
public static <Term extends AMonomial<Term>,Poly extends AMultivariatePolynomial<Term,Poly>> Poly asMultivariate(IUnivariatePolynomial poly, int nVariables, int variable, Comparator<DegreeVector> ordering)
Converts univariate polynomial to multivariate. Example://convert (x^2 + 1) in Z[x] to multivariate polynomial (c^2 + 1) in Z[a,b,c] multivarPoly = asMultivariate(univarPoly, 3, 2, MonomialOrder.LEX)- Type Parameters:
Term- desired terms typePoly- desired polynomial type- Parameters:
poly- the univariate polynomialnVariables- the total number of variables in the resultvariable- the univariate variableordering- the term order- Returns:
- the multivariate polynomial
-
asUnivariate
public abstract IUnivariatePolynomial asUnivariate()
Converts this to univariate polynomial or throws exception if conversion is impossible (more than one variable have non zero exponents)- Returns:
- univariate polynomial
- Throws:
IllegalArgumentException- if this is not effectively a univariate polynomial
-
create
public final Poly create(Term... terms)
Creates multivariate polynomial over the same ring as this from the list of monomials- Parameters:
terms- the monomials- Returns:
- multivariate polynomial
-
create
public final Poly create(Iterable<Term> terms)
Creates multivariate polynomial over the same ring as this from the list of monomials- Parameters:
terms- the monomials- Returns:
- multivariate polynomial
-
create
public final Poly create(Term term)
Creates multivariate polynomial over the same ring as this with the single monomial- Parameters:
term- the monomial- Returns:
- multivariate polynomial
-
createConstantFromTerm
public abstract Poly createConstantFromTerm(Term term)
Creates multivariate polynomial over the same ring as this with the single constant element taken from given monomial- Parameters:
term- the monomial- Returns:
- multivariate polynomial
-
create
public final Poly create(DegreeVector term)
Creates multivariate polynomial over the same ring as this with the single monomial- Parameters:
term- the monomial- Returns:
- multivariate polynomial
-
createMonomial
public final Poly createMonomial(int variable, int degree)
Creates monomial over the same ring as this of the formvariable ^ degree- Parameters:
variable- the variabledegree- the monomial degree- Returns:
- monomial
variable ^ degree
-
setOrdering
public final Poly setOrdering(Comparator<DegreeVector> newOrdering)
Makes a copy of this with the new orderingnewOrdering- Parameters:
newOrdering- the new ordering- Returns:
- a copy of this with the new ordering
-
release
protected void release()
release caches
-
size
public final int size()
Returns the number of terms in this polynomial- Specified by:
sizein interfaceIPolynomial<Term extends AMonomial<Term>>- Returns:
- the number of terms
-
isZero
public final boolean isZero()
Description copied from interface:IPolynomialReturnstrueif this is zero- Specified by:
isZeroin interfaceIPolynomial<Term extends AMonomial<Term>>- Returns:
- whether
thisis zero
-
isLinearOrConstant
public boolean isLinearOrConstant()
Description copied from interface:IPolynomialReturns whether this polynomial is linear (i.e. of the forma * X + b)- Specified by:
isLinearOrConstantin interfaceIPolynomial<Term extends AMonomial<Term>>
-
isLinearExactly
public boolean isLinearExactly()
Description copied from interface:IPolynomialReturns whether this polynomial is linear (i.e. of the forma * X + bwith nonzeroa)- Specified by:
isLinearExactlyin interfaceIPolynomial<Term extends AMonomial<Term>>
-
isZeroCC
public boolean isZeroCC()
Description copied from interface:IPolynomialReturns true if constant term is zero- Specified by:
isZeroCCin interfaceIPolynomial<Term extends AMonomial<Term>>- Returns:
- whether constant term is zero
-
first
public Term first()
-
last
public Term last()
-
collection
public final Collection<Term> collection()
-
toArray
public final Term[] toArray()
-
isMonomial
public final boolean isMonomial()
Description copied from interface:IPolynomialReturnstrueif this polynomial has only one monomial term- Specified by:
isMonomialin interfaceIPolynomial<Term extends AMonomial<Term>>- Returns:
- whether
thishas only one monomial term
-
isVariable
public final boolean isVariable()
Returns whether this is a plain variable (with no coefficient)
-
toZero
public final Poly toZero()
Description copied from interface:IPolynomialSets this to zero- Specified by:
toZeroin interfaceIPolynomial<Term extends AMonomial<Term>>- Returns:
- this := zero
-
set
public final Poly set(Poly oth)
Description copied from interface:IPolynomialSets the content of this tooth- Specified by:
setin interfaceIPolynomial<Term extends AMonomial<Term>>- Parameters:
oth- the polynomial- Returns:
- this := oth
-
dropVariable
public final Poly dropVariable(int variable)
Makes a copy of this with the specified variable dropped- Parameters:
variable- the variable
-
dropVariables
public final Poly dropVariables(int[] variables)
Makes a copy of this with the specified variable replaced with the unit- Parameters:
variables- the variables
-
dropSelectVariables
public final Poly dropSelectVariables(int... variables)
Makes a copy of this with all variables except specified ones replaced with the units- Parameters:
variables- the variables
-
insertVariable
public final Poly insertVariable(int variable)
Makes a copy of this by inserting new variable (the indexes will be shifted)- Parameters:
variable- the variable
-
insertVariable
public final Poly insertVariable(int variable, int count)
Makes a copy of this by inserting new variables (the indexes will be shifted)- Parameters:
variable- the variablecount- length of the insertion
-
setNVariables
public final Poly setNVariables(int newNVariables)
auxiliary method
-
mapVariables
public final Poly mapVariables(int[] mapping)
Renames old variables to new according to mapping- Parameters:
mapping- mapping from old variables to new variables
-
joinNewVariable
public final Poly joinNewVariable()
Returns a copy of this withnVariables = nVariables + 1- Returns:
- a copy of this with one additional (last) variable added
- See Also:
insertVariable(int)
-
joinNewVariables
public final Poly joinNewVariables(int n)
Returns a copy of this withnVariables = nVariables + m- Returns:
- a copy of this with n additional (last) variables added
- See Also:
insertVariable(int)
-
nUsedVariables
public final int nUsedVariables()
Returns the number of really used variables (those which are not units)- Returns:
- the number of variables (those which are not units)
-
degree
public int degree()
Returns the total degree of this polynomial, that is the maximal total degree among all terms- Specified by:
degreein interfaceIPolynomial<Term extends AMonomial<Term>>- Returns:
- the total degree of this polynomial, that is the maximal total degree among all terms
-
degree
public int degree(int... variables)
Gives the degree in specified variables
-
degreeMax
public int degreeMax()
Returns the maximal degree of variables in this polynomial- Returns:
- the maximal degree of variables in this polynomial
-
degree
public final int degree(int variable)
Returns the degree of this polynomial with respect to specified variable- Parameters:
variable- the variable- Returns:
- the degree of this polynomial with respect to specified variable
-
degreesRef
protected int[] degreesRef()
returns reference (content must not be modified)
-
degrees
public final int[] degrees()
Returns an array of degrees of all variables, so that is i-th element of the result is the polynomial degree with respect to i-th variable- Returns:
- array of degrees
-
multidegree
public final int[] multidegree()
Returns the multidegree of this polynomial i.e. exponents of the leading term (without copying)- Returns:
- the multidegree of this polynomial i.e. exponents of the leading term (without copying)
-
degrees
public final int[] degrees(int variable)
Returns the array of exponents in whichvariableoccurs in this polynomial- Returns:
- the array of exponents in which
variableoccurs in this polynomial
-
totalDegree
public final int totalDegree()
Returns the total degree, that is sum ofdegrees()
-
sparsity
public double sparsity()
Sparsity level: size / (product of degrees)
-
sparsity2
public double sparsity2()
Sparsity level:size / nDenseTermswhere nDenseTerms is a total number of possible distinct terms with total degree not larger than distinct total degrees presented in this.
-
ecart
public final int ecart()
Returns degreeSum - lt().totalDegree
-
isHomogeneous
public final boolean isHomogeneous()
Returns whether all terms have the same total degree
-
homogenize
public final Poly homogenize(int variable)
Homogenize poly by adding new (homogenizing) variable- Parameters:
variable- variable that will be inserted (homogenization variable)
-
isEffectiveUnivariate
public final boolean isEffectiveUnivariate()
Returns whether this poly is effectively univariate (not more than one variable is non-unit)- Returns:
- whether this poly is effectively univariate
-
univariateVariable
public final int univariateVariable()
Returns -1 if this poly is not effectively univariate or variable in which it is univariate- Returns:
- -1 if this poly is not effectively univariate or variable in which it is univariate
-
coefficientOf
public final Poly coefficientOf(int variable, int exponent)
Returns a coefficient beforevariable^exponentas a multivariate polynomial- Parameters:
variable- the variableexponent- the exponent- Returns:
- coefficient before
variable^exponentas a multivariate polynomial
-
coefficientOf
public final Poly coefficientOf(int[] variables, int[] exponents)
Returns a coefficient beforevariables^exponentsas a multivariate polynomial- Parameters:
variables- the variablesexponents- the exponents- Returns:
- coefficient before
variables^exponentsas a multivariate polynomial
-
dropCoefficientOf
public final Poly dropCoefficientOf(int[] variables, int[] exponents)
Returns a coefficient beforevariables^exponentsas a multivariate polynomial and drops all such terms from this- Parameters:
variables- the variablesexponents- the exponents- Returns:
- coefficient before
variables^exponentsas a multivariate polynomial
-
asUnivariate
public final UnivariatePolynomial<Poly> asUnivariate(int variable)
Converts this polynomial to a univariate polynomial over specified variable with the multivariate coefficient ring.- Parameters:
variable- variable which will be treated as univariate variable- Returns:
- univariate polynomial over the ring of multivariate coefficients
- Throws:
IllegalArgumentException- if this is not effectively a univariate polynomial
-
asUnivariateEliminate
public final UnivariatePolynomial<Poly> asUnivariateEliminate(int variable)
Converts this polynomial to a univariate polynomial over specified variable with the multivariate coefficient ring.- Parameters:
variable- variable which will be treated as univariate variable- Returns:
- univariate polynomial over the ring of multivariate coefficients
- Throws:
IllegalArgumentException- if this is not effectively a univariate polynomial
-
asMultivariate
public static <Term extends AMonomial<Term>,Poly extends AMultivariatePolynomial<Term,Poly>> Poly asMultivariate(UnivariatePolynomial<Poly> univariate, int uVariable, boolean join)
-
asOverUnivariate
public abstract MultivariatePolynomial<? extends IUnivariatePolynomial> asOverUnivariate(int variable)
Converts this to a multivariate polynomial with coefficients being univariate polynomials overvariable- Parameters:
variable- variable- Returns:
- multivariate polynomial with coefficients being univariate polynomials over
variable
-
asOverUnivariateEliminate
public abstract MultivariatePolynomial<? extends IUnivariatePolynomial> asOverUnivariateEliminate(int variable)
Converts this to a multivariate polynomial with coefficients being univariate polynomials overvariable, the resulting polynomial have (nVariable - 1) multivariate variables (specifiedvariableis eliminated)- Parameters:
variable- the variable- Returns:
- multivariate polynomial with coefficients being univariate polynomials over
variable, the resulting polynomial have (nVariable - 1) multivariate variables
-
asOverMultivariate
public abstract MultivariatePolynomial<Poly> asOverMultivariate(int... variables)
Converts this to a multivariate polynomial with coefficients being multivariate polynomials polynomials overvariablesthat is polynomial in R[variables][other_variables]- Parameters:
variables- the variables to separate- Returns:
- multivariate polynomial with coefficients being multivariate polynomials polynomials over
variablesthat is polynomial in R[variables][other_variables]
-
asOverMultivariateEliminate
public final MultivariatePolynomial<Poly> asOverMultivariateEliminate(int... variables)
Converts this to a multivariate polynomial with coefficients being multivariate polynomials polynomials overvariablesthat is polynomial in R[variables][other_variables]- Parameters:
variables- the variables to separate- Returns:
- multivariate polynomial with coefficients being multivariate polynomials polynomials over
variablesthat is polynomial in R[variables][other_variables]
-
asOverMultivariateEliminate
public abstract MultivariatePolynomial<Poly> asOverMultivariateEliminate(int[] variables, Comparator<DegreeVector> ordering)
Converts this to a multivariate polynomial with coefficients being multivariate polynomials polynomials overvariablesthat is polynomial in R[variables][other_variables]- Parameters:
variables- the variables to separateordering- monomial order to use for result- Returns:
- multivariate polynomial with coefficients being multivariate polynomials polynomials over
variablesthat is polynomial in R[variables][other_variables]
-
asMultivariate
public static <Term extends AMonomial<Term>,Poly extends AMultivariatePolynomial<Term,Poly>> Poly asMultivariate(UnivariatePolynomial<Poly> uPoly, int variable)
Convert univariate polynomial over multivariate polynomials to a normal multivariate poly- Parameters:
uPoly- univariate polynomial over multivariate polynomialsvariable- the univariate variable- Returns:
- multivariate poly
-
primitivePart
public abstract Poly primitivePart(int variable)
Gives primitive part of this considered as R[variable][other_variables]- Parameters:
variable- the variable- Returns:
- primitive part of this considered as R[variable][other_variables]
-
contentUnivariate
public abstract IUnivariatePolynomial contentUnivariate(int variable)
Gives the content of this considered as R[variable][other_variables]- Parameters:
variable- the variable- Returns:
- the content of this considered as R[variable][other_variables]
-
monic
public abstract Poly monic(Comparator<DegreeVector> ordering)
Make this poly monic considering leading term with respect to given ordering
-
monicWithLC
public abstract Poly monicWithLC(Comparator<DegreeVector> ordering, Poly oth)
Setsthisto its monic part multiplied by the leading coefficient ofotherwith respect to given ordering
-
content
public final Poly content(int variable)
Gives the content of this considered as R[variable][other_variables]- Parameters:
variable- the variable- Returns:
- the content of this considered as R[variable][other_variables]
-
contentExcept
public final Poly contentExcept(int variable)
Gives the content of this considered as R[other_variables][variable]- Parameters:
variable- the variable- Returns:
- the content of this considered as R[other_variables][variable]
-
multiplyByMonomial
public final Poly multiplyByMonomial(int variable, int exponent)
Multiplies this by variable^exponent- Parameters:
variable- the variableexponent- the exponent- Returns:
- this multiplied by variable^exponent
-
lc
public final Poly lc(int variable)
Returns the leading coefficient of this viewed as R[other_variables][variable]- Parameters:
variable- the variable- Returns:
- multivariate leading coefficient of this viewed as R[other_variables][variable]
-
setLC
public final Poly setLC(int variable, Poly lc)
Set the leading coefficient of specified variable to a specified value (this is considered as R[other_variables][variable])- Parameters:
variable- the variablelc- the leading coefficient of this viewed as R[other_variables][variable]
-
lt
public final Term lt(Comparator<DegreeVector> ordering)
Returns the leading term in this polynomial according to specified ordering- Returns:
- the leading term in this polynomial according to specified ordering
-
lt
public final Term lt()
Returns the leading term in this polynomial according to ordering- Returns:
- the leading term in this polynomial according to ordering
-
mt
public final Term mt()
Returns the minimal term in this polynomial according to ordering- Returns:
- the minimal term in this polynomial according to ordering
-
lcAsPoly
public abstract Poly lcAsPoly(Comparator<DegreeVector> ordering)
Returns the leading coefficient with respect to specified ordering as a constant poly
-
ltAsPoly
public final Poly ltAsPoly()
Returns the leading term in this polynomial according to ordering- Returns:
- the leading term in this polynomial according to ordering
-
monomialContent
public final Term monomialContent()
Returns the monomial content of this polynomial- Returns:
- the monomial content of this polynomial
-
divideDegreeVectorOrNull
public final Poly divideDegreeVectorOrNull(DegreeVector monomial)
Divides this polynomial by amonomialor returnsnull(causing loss of internal data) if some of the elements can't be exactly divided by themonomial. NOTE: ifnullis returned, the content ofthisis destroyed.- Parameters:
monomial- monomial- Returns:
thisdivided by thefactor * monomialornull
-
divideOrNull
public abstract Poly divideOrNull(Term monomial)
Divides this polynomial by amonomialor returnsnull(causing loss of internal data) if some of the elements can't be exactly divided by themonomial. NOTE: ifnullis returned, the content ofthisis destroyed.- Parameters:
monomial- monomial degrees- Returns:
thisdivided by thefactor * monomialornull
-
add
public final Poly add(Poly oth)
Description copied from interface:IPolynomialAddsothtothis.- Specified by:
addin interfaceIPolynomial<Term extends AMonomial<Term>>- Parameters:
oth- the polynomial- Returns:
this + oth
-
subtract
public final Poly subtract(Poly oth)
Description copied from interface:IPolynomialSubtractsothfromthis.- Specified by:
subtractin interfaceIPolynomial<Term extends AMonomial<Term>>- Parameters:
oth- the polynomial- Returns:
this - oth
-
add
public final Poly add(Term monomial)
Addsmonomialto this polynomial- Parameters:
monomial- the monomial- Returns:
this + monomial
-
put
public final Poly put(Term monomial)
Putsmonomialto this polynomial replacing the previous entry if was
-
subtract
public final Poly subtract(Term monomial)
Subtractsmonomialfrom this polynomial- Parameters:
monomial- the monomial- Returns:
this - monomial
-
negate
public final Poly negate()
Description copied from interface:IPolynomialNegates this and returns- Specified by:
negatein interfaceIPolynomial<Term extends AMonomial<Term>>- Returns:
- this negated
-
add
public final Poly add(Iterable<Term> monomials)
Adds monomials to this polynomial- Parameters:
monomials- terms- Returns:
this + monomials
-
add
public final Poly add(Term... monomials)
Adds monomials to this polynomial- Parameters:
monomials- terms- Returns:
this + monomials
-
subtractLt
public final Poly subtractLt()
Removes the leading term from this polynomial- Returns:
- this - this.lt()
-
multiply
public abstract Poly multiply(Term monomial)
Multipliesthisby themonomial- Parameters:
monomial- the monomial- Returns:
- this multiplied by the
monomial
-
multiplyByDegreeVector
public final Poly multiplyByDegreeVector(DegreeVector dv)
Multipliesthisby the degree vector- Parameters:
dv- the degree vector- Returns:
- this multiplied by the degree vector
-
getSkeleton
public final Set<DegreeVector> getSkeleton()
Returns skeleton of this poly- Returns:
- skeleton of this poly
-
setAllCoefficientsToUnit
public final Poly setAllCoefficientsToUnit()
Set all coefficients to units
-
getSkeleton
public final Set<DegreeVector> getSkeleton(int... variables)
Returns skeleton of this poly with respect to specifiedvariables- Parameters:
variables- the variables- Returns:
- skeleton of this poly with respect to specified
variables
-
getSkeletonDrop
public final Set<DegreeVector> getSkeletonDrop(int... variables)
Returns skeleton of this poly with respect to specifiedvariables- Parameters:
variables- the variables- Returns:
- skeleton of this poly with respect to specified
variables
-
getSkeletonExcept
public final Set<DegreeVector> getSkeletonExcept(int... variables)
Returns skeleton of this poly with respect to all except specifiedvariables- Parameters:
variables- the variables to exclude- Returns:
- skeleton of this poly with respect to all except specified
variables
-
sameSkeletonQ
public final boolean sameSkeletonQ(AMultivariatePolynomial oth)
Tests whetherthisandothhave the same skeleton- Parameters:
oth- other multivariate polynomial- Returns:
trueifthisandothhave the same skeleton andfalseotherwise
-
sameSkeletonQ
public final boolean sameSkeletonQ(AMultivariatePolynomial oth, int... variables)
Tests whetherthisandothhave the same skeleton with respect to specifiedvariables- Parameters:
oth- other multivariate polynomialvariables- variables to test- Returns:
trueifthisandothhave the same skeleton with respect to specifiedvariablesandfalseotherwise
-
sameSkeletonExceptQ
public final boolean sameSkeletonExceptQ(AMultivariatePolynomial oth, int... variables)
Tests whetherthisandothhave the same skeleton with respect all except specifiedvariables- Parameters:
oth- other multivariate polynomialvariables- variables to exclude- Returns:
trueifthisandothhave the same skeleton with respect to all except specifiedvariablesandfalseotherwise
-
derivative
public final Poly derivative(int variable)
Gives partial derivative with respect to specified variable (new instance created)- Parameters:
variable- the variable- Returns:
- partial derivative with respect to specified variable
-
derivative
public abstract Poly derivative(int variable, int order)
Gives partial derivative of specifiedorderwith respect to specified variable (new instance created)- Parameters:
variable- the variableorder- derivative order- Returns:
- partial derivative of specified
orderwith respect to specified variable
-
seriesCoefficient
public abstract Poly seriesCoefficient(int variable, int order)
Gives (unevaluated) coefficient of Taylor series expansion for specified variable that isderivative(poly, variable, order) / order!, where the derivative is formal derivative and calculated with arithmetic performed in Z ring (to overcome possible zeros in Zp).- Parameters:
variable- the variableorder- 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)
-
evaluateAtZero
public final Poly evaluateAtZero(int variable)
Substitutes0forvariable(new instance created).- Parameters:
variable- the variable- Returns:
- a new multivariate polynomial with
0substituted forvariable
-
evaluateAtZero
public final Poly evaluateAtZero(int[] variables)
Substitutes0for all specifiedvariables(new instance created).- Parameters:
variables- the variables- Returns:
- a new multivariate polynomial with
0substituted for all specifiedvariables
-
derivative
public final Poly[] derivative()
Gives the derivative vector- Returns:
- derivative vector
-
asOverPoly
public final MultivariatePolynomial<Poly> asOverPoly(Poly factory)
Consider coefficients of this as constant polynomials of the same type as a given factory polynomial- Parameters:
factory- factory polynomial
-
composition
public final Poly composition(Poly... values)
Substitutes given polynomials instead of variables of this (that isthis(values_1, ..., values_N))- Parameters:
values- polynomial values (may have different nvars from this)
-
composition
public final <sPoly extends IUnivariatePolynomial<sPoly>> sPoly composition(sPoly... values)
Substitutes given polynomials instead of variables of this (that isthis(values_1, ..., values_N))- Parameters:
values- polynomial values (may have different nvars from this)
-
composition
public final <sPoly extends IUnivariatePolynomial<sPoly>> sPoly composition(Ring<sPoly> uRing, sPoly... values)
Substitutes given polynomials instead of variables of this (that isthis(values_1, ..., values_N))- Parameters:
uRing- ring of univariate polynomialsvalues- polynomial values (may have different nvars from this)
-
composition
public final Poly composition(List<Poly> values)
Substitutes given polynomials instead of variables of this (that isthis(values_1, ..., values_N))- Parameters:
values- polynomial values (may have different nvars from this)
-
composition
public final Poly composition(int variable, Poly value)
Substitutes given polynomial instead of specified variable (that isthis(x_1, ..., value, ..., x_N), where value is on the place of specified variable)
-
composition
public final Poly composition(int[] variables, Poly[] values)
Substitutes given polynomial instead of specified variable (that isthis(x_1, ..., value, ..., x_N), where value is on the place of specified variable)
-
skeletonHashCode
public int skeletonHashCode()
-
clone
public abstract Poly clone()
Description copied from interface:IPolynomialDeep copy of this
-
evaluateAtRandom
public abstract Poly evaluateAtRandom(int variable, org.apache.commons.math3.random.RandomGenerator rnd)
Evaluatespolyat random point
-
evaluateAtRandomPreservingSkeleton
public abstract Poly evaluateAtRandomPreservingSkeleton(int variable, org.apache.commons.math3.random.RandomGenerator rnd)
Evaluatespolyat random point chosen in such way that the skeleton of evaluated version is the same as of the originalpolywith respect to all exceptvariablevariables
-
mapCoefficientsAsPolys
public abstract <E> MultivariatePolynomial<E> mapCoefficientsAsPolys(Ring<E> ring, Function<Poly,E> mapper)
-
-