# 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 to `x^i` monomial.
Since:
1.0
• ## Method Summary

Modifier and Type Method Description
`default AMultivariatePolynomial` `asMultivariate()`
Convert to multivariate polynomial
`AMultivariatePolynomial` `asMultivariate​(Comparator<DegreeVector> ordering)`
Convert to multivariate polynomial
`Poly` `clone()`
Deep copy of this
`AMultivariatePolynomial` `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 monomial `x^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 store `desiredCapacity` elements
`default gnu.trove.set.hash.TIntHashSet` `exponents()`
Returns a set of exponents of non-zero terms
`int` `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 polynomial
`Poly` ```getRange​(int from, int to)```
Creates polynomial formed from the coefficients of this starting from `from` (inclusive) to `to` (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 zero
`default boolean` `isZeroCC()`
Returns true if constant term is zero
`default <E> UnivariatePolynomial<E>` ```mapCoefficientsAsPolys​(Ring<E> ring, Function<Poly,​E> mapper)```
`default int` `nNonZeroTerms()`
Returns the number of non zero terms in this poly
`Poly` `reverse()`
Reverses the coefficients of this
`Poly` `setAndDestroy​(Poly oth)`
Sets the content of this with `oth` and destroys oth
`Poly` ```setFrom​(int indexInThis, Poly poly, int indexInPoly)```
Sets i-th element of this by j-th element of other poly
`Poly` `setZero​(int i)`
Fills i-th element with zero
`Poly` `shiftLeft​(int offset)`
Returns the quotient `this / x^offset`, it is polynomial with coefficient list formed by shifting coefficients of `this` to the left by `offset`.
`Poly` `shiftRight​(int offset)`
Multiplies `this` by the `x^offset`.
`default int` `size()`
Returns the degree of this polynomial
`Stream<Poly>` `streamAsPolys()`
Stream polynomial coefficients as constant polynomials
`Poly` `truncate​(int newDegree)`
Returns the remainder `this rem x^(newDegree + 1)`, it is polynomial formed by coefficients of this from zero to `newDegree` (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 Details

• ### size

default int size()
Returns the degree of this polynomial
Specified by:
`size` in interface `IPolynomial<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 interface `IPolynomial<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 self
`poly` - other polynomial
`indexInPoly` - 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 quotient `this / x^offset`, it is polynomial with coefficient list formed by shifting coefficients of `this` to the left by `offset`.
Parameters:
`offset` - shift amount
Returns:
the quotient `this / x^offset`
• ### shiftRight

Poly shiftRight​(int offset)
Multiplies `this` by the `x^offset`.
Parameters:
`offset` - monomial exponent
Returns:
`this * x^offset`
• ### truncate

Poly truncate​(int newDegree)
Returns the remainder `this rem x^(newDegree + 1)`, it is polynomial formed by coefficients of this from zero to `newDegree` (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 from `from` (inclusive) to `to` (exclusive)
Parameters:
`from` - the initial index of the range to be copied, inclusive
`to` - 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 monomial `x^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 interface `IPolynomial<Poly extends IUnivariatePolynomial<Poly>>`
Returns:
deep copy of this
• ### setAndDestroy

Poly setAndDestroy​(Poly oth)
Sets the content of this with `oth` 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)`
• ### streamAsPolys

streamAsPolys()
Stream polynomial coefficients as constant polynomials
• ### mapCoefficientsAsPolys

default <E>  mapCoefficientsAsPolys​(Ring<E> ring, Function<Poly,​E> mapper)
• ### composition

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 store `desiredCapacity` elements
• ### isLinearOrConstant

default boolean isLinearOrConstant()
Description copied from interface: `IPolynomial`
Returns whether this polynomial is linear (i.e. of the form `a * X + b`)
Specified by:
`isLinearOrConstant` in interface `IPolynomial<Poly extends IUnivariatePolynomial<Poly>>`
• ### isLinearExactly

default boolean isLinearExactly()
Description copied from interface: `IPolynomial`
Returns whether this polynomial is linear (i.e. of the form `a * X + b` with nonzero `a`)
Specified by:
`isLinearExactly` in interface `IPolynomial<Poly extends IUnivariatePolynomial<Poly>>`