Package cc.redberry.rings.poly.univar
Interface IUnivariatePolynomial<Poly extends IUnivariatePolynomial<Poly>>
-
- Type Parameters:
Poly
- the type of polynomial (self type)
- All Superinterfaces:
Comparable<Poly>
,IPolynomial<Poly>
,Serializable
,Stringifiable<Poly>
- All Known Implementing Classes:
UnivariatePolynomial
,UnivariatePolynomialZ64
,UnivariatePolynomialZp64
public interface IUnivariatePolynomial<Poly extends IUnivariatePolynomial<Poly>> extends IPolynomial<Poly>
Parent interface for univariate polynomials. Dense representation (array of coefficients) is used to hold univariate polynomials. Positional operations treat index so that i-th coefficient corresponds tox^i
monomial.- Since:
- 1.0
-
-
Method Summary
Modifier and Type Method Description default AMultivariatePolynomial
asMultivariate()
Convert to multivariate polynomialAMultivariatePolynomial
asMultivariate(Comparator<DegreeVector> ordering)
Convert to multivariate polynomialPoly
clone()
Deep copy of thisAMultivariatePolynomial
composition(AMultivariatePolynomial value)
Calculates the composition of this(oth)default Poly
composition(Ring<Poly> ring, Poly value)
Calculates the composition of this(oth) (new instance, so the content of this is not changed))Poly
composition(Poly value)
Calculates the composition of this(oth) (new instance, so the content of this is not changed))Poly
createMonomial(int degree)
Creates new monomialx^degree
(with the same coefficient ring)Poly
derivative()
Returns the formal derivative of this poly (new instance, so the content of this is not changed)void
ensureInternalCapacity(int desiredCapacity)
ensures that internal storage has enough size to storedesiredCapacity
elementsdefault gnu.trove.set.hash.TIntHashSet
exponents()
Returns a set of exponents of non-zero termsint
firstNonZeroCoefficientPosition()
Returns position of the first non-zero coefficient, that is common monomial exponent (e.g.Poly
getAsPoly(int i)
Returns i-th coefficient of this as a constant polynomialPoly
getRange(int from, int to)
Creates polynomial formed from the coefficients of this starting fromfrom
(inclusive) toto
(exclusive)default boolean
isLinearExactly()
Returns whether this polynomial is linear (i.e.default boolean
isLinearOrConstant()
Returns whether this polynomial is linear (i.e.boolean
isZeroAt(int i)
Returns whether i-th coefficient of this is zerodefault boolean
isZeroCC()
Returns true if constant term is zerodefault <E> UnivariatePolynomial<E>
mapCoefficientsAsPolys(Ring<E> ring, Function<Poly,E> mapper)
default int
nNonZeroTerms()
Returns the number of non zero terms in this polyPoly
reverse()
Reverses the coefficients of thisPoly
setAndDestroy(Poly oth)
Sets the content of this withoth
and destroys othPoly
setFrom(int indexInThis, Poly poly, int indexInPoly)
Sets i-th element of this by j-th element of other polyPoly
setZero(int i)
Fills i-th element with zeroPoly
shiftLeft(int offset)
Returns the quotientthis / x^offset
, it is polynomial with coefficient list formed by shifting coefficients ofthis
to the left byoffset
.Poly
shiftRight(int offset)
Multipliesthis
by thex^offset
.default int
size()
Returns the degree of this polynomialStream<Poly>
streamAsPolys()
Stream polynomial coefficients as constant polynomialsPoly
truncate(int newDegree)
Returns the remainderthis rem x^(newDegree + 1)
, it is polynomial formed by coefficients of this from zero tonewDegree
(both inclusive)-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface cc.redberry.rings.poly.IPolynomial
add, add, assertSameCoefficientRingWith, canonical, ccAsPoly, coefficientRingCardinality, coefficientRingCharacteristic, coefficientRingPerfectPowerBase, coefficientRingPerfectPowerExponent, coefficientRingToString, coefficientRingToString, contentAsPoly, copy, createArray, createArray, createArray, createArray, createArray2d, createArray2d, createConstant, createOne, createZero, decrement, degree, divideByLC, increment, isConstant, isMonic, isMonomial, isOne, isOverField, isOverFiniteField, isOverPerfectPower, isOverZ, isUnitCC, isZero, lcAsPoly, monic, monicExact, monicWithLC, multiply, multiply, multiply, multiply, multiplyByBigInteger, multiplyByLC, negate, parsePoly, primitivePart, primitivePartSameSign, sameCoefficientRingWith, set, setCoefficientRingFrom, setCoefficientRingFromOptional, signumOfLC, square, subtract, subtract, toPositiveLC, toString, toZero
-
Methods inherited from interface cc.redberry.rings.io.Stringifiable
toString
-
-
-
-
Method Detail
-
size
default int size()
Returns the degree of this polynomial- Specified by:
size
in interfaceIPolynomial<Poly extends IUnivariatePolynomial<Poly>>
- Returns:
- the degree of this polynomial
-
nNonZeroTerms
default int nNonZeroTerms()
Returns the number of non zero terms in this poly
-
isZeroAt
boolean isZeroAt(int i)
Returns whether i-th coefficient of this is zero- Parameters:
i
- the position- Returns:
- whether i-th coefficient of this is zero
-
isZeroCC
default boolean isZeroCC()
Description copied from interface:IPolynomial
Returns true if constant term is zero- Specified by:
isZeroCC
in interfaceIPolynomial<Poly extends IUnivariatePolynomial<Poly>>
- Returns:
- whether constant term is zero
-
setZero
Poly setZero(int i)
Fills i-th element with zero- Parameters:
i
- position- Returns:
- self
-
setFrom
Poly setFrom(int indexInThis, Poly poly, int indexInPoly)
Sets i-th element of this by j-th element of other poly- Parameters:
indexInThis
- index in selfpoly
- other polynomialindexInPoly
- index in other polynomial- Returns:
- self
-
getAsPoly
Poly getAsPoly(int i)
Returns i-th coefficient of this as a constant polynomial- Parameters:
i
- index in this- Returns:
- i-th coefficient of this as a constant polynomial
-
exponents
default gnu.trove.set.hash.TIntHashSet exponents()
Returns a set of exponents of non-zero terms- Returns:
- a set of exponents of non-zero terms
-
firstNonZeroCoefficientPosition
int firstNonZeroCoefficientPosition()
Returns position of the first non-zero coefficient, that is common monomial exponent (e.g. 2 for x^2 + x^3 + ...). In the case of zero polynomial, -1 returned- Returns:
- position of the first non-zero coefficient or -1 if this is zero
-
shiftLeft
Poly shiftLeft(int offset)
Returns the quotientthis / x^offset
, it is polynomial with coefficient list formed by shifting coefficients ofthis
to the left byoffset
.- Parameters:
offset
- shift amount- Returns:
- the quotient
this / x^offset
-
shiftRight
Poly shiftRight(int offset)
Multipliesthis
by thex^offset
.- Parameters:
offset
- monomial exponent- Returns:
this * x^offset
-
truncate
Poly truncate(int newDegree)
Returns the remainderthis rem x^(newDegree + 1)
, it is polynomial formed by coefficients of this from zero tonewDegree
(both inclusive)- Parameters:
newDegree
- new degree- Returns:
- remainder
this rem x^(newDegree + 1)
-
getRange
Poly getRange(int from, int to)
Creates polynomial formed from the coefficients of this starting fromfrom
(inclusive) toto
(exclusive)- Parameters:
from
- the initial index of the range to be copied, inclusiveto
- the final index of the range to be copied, exclusive.- Returns:
- polynomial formed from the range of coefficients of this
-
reverse
Poly reverse()
Reverses the coefficients of this- Returns:
- reversed polynomial
-
createMonomial
Poly createMonomial(int degree)
Creates new monomialx^degree
(with the same coefficient ring)- Parameters:
degree
- monomial degree- Returns:
- new monomial
coefficient * x^degree
-
derivative
Poly derivative()
Returns the formal derivative of this poly (new instance, so the content of this is not changed)- Returns:
- the formal derivative
-
clone
Poly clone()
Description copied from interface:IPolynomial
Deep copy of this- Specified by:
clone
in interfaceIPolynomial<Poly extends IUnivariatePolynomial<Poly>>
- Returns:
- deep copy of this
-
setAndDestroy
Poly setAndDestroy(Poly oth)
Sets the content of this withoth
and destroys oth- Parameters:
oth
- the polynomial (will be destroyed)- Returns:
- this := oth
-
composition
Poly composition(Poly value)
Calculates the composition of this(oth) (new instance, so the content of this is not changed))- Parameters:
value
- polynomial- Returns:
- composition
this(oth)
-
composition
default Poly composition(Ring<Poly> ring, Poly value)
Calculates the composition of this(oth) (new instance, so the content of this is not changed))- Parameters:
value
- polynomial- Returns:
- composition
this(oth)
-
mapCoefficientsAsPolys
default <E> UnivariatePolynomial<E> mapCoefficientsAsPolys(Ring<E> ring, Function<Poly,E> mapper)
-
composition
AMultivariatePolynomial composition(AMultivariatePolynomial value)
Calculates the composition of this(oth)- Parameters:
value
- polynomial- Returns:
- composition
this(oth)
-
asMultivariate
AMultivariatePolynomial asMultivariate(Comparator<DegreeVector> ordering)
Convert to multivariate polynomial
-
asMultivariate
default AMultivariatePolynomial asMultivariate()
Convert to multivariate polynomial
-
ensureInternalCapacity
void ensureInternalCapacity(int desiredCapacity)
ensures that internal storage has enough size to storedesiredCapacity
elements
-
isLinearOrConstant
default boolean isLinearOrConstant()
Description copied from interface:IPolynomial
Returns whether this polynomial is linear (i.e. of the forma * X + b
)- Specified by:
isLinearOrConstant
in interfaceIPolynomial<Poly extends IUnivariatePolynomial<Poly>>
-
isLinearExactly
default boolean isLinearExactly()
Description copied from interface:IPolynomial
Returns whether this polynomial is linear (i.e. of the forma * X + b
with nonzeroa
)- Specified by:
isLinearExactly
in interfaceIPolynomial<Poly extends IUnivariatePolynomial<Poly>>
-
-