cc.redberry.rings.poly

## Class UnivariateRing<Poly extends IUnivariatePolynomial<Poly>>

• ### Constructor Summary

Constructors
Constructor and Description
`UnivariateRing(Poly factory)`
Creates ring of univariate polynomials which support operations over univariate polynomials of the type same as of provided `factory` polynomial
• ### Method Summary

All Methods
Modifier and Type Method and Description
`Poly` ```add(Poly a, Poly b)```
`Poly` ```addMutable(Poly a, Poly b)```
Adds two elements and destroys the initial content of `a`.
`BigInteger` `cardinality()`
Returns the number of elements in this ring (cardinality) or null if ring is infinite
`BigInteger` `characteristic()`
Returns characteristic of this ring
`int` ```compare(Poly o1, Poly o2)```
`Poly` `copy(Poly element)`
Makes a deep copy of the specified element (for immutable instances the same reference returned).
`Poly[]` ```divideAndRemainder(Poly a, Poly b)```
Returns quotient and remainder of `dividend / divider`
`boolean` `equals(Object o)`
`Poly[]` ```extendedGCD(Poly a, Poly b)```
Returns array of `[gcd(a,b), s, t]` such that `s * a + t * b = gcd(a, b)`
`PolynomialFactorDecomposition<Poly>` `factor(Poly element)`
Factor specified element
`PolynomialFactorDecomposition<Poly>` `factorSquareFree(Poly element)`
Square-free factorization of specified element
`Poly` `factory()`
Factory polynomial
`Poly[]` ```firstBezoutCoefficient(Poly a, Poly b)```
Returns array of `[gcd(a,b), s]` such that `s * a + t * b = gcd(a, b)`
`Poly` ```gcd(Poly a, Poly b)```
Returns the greatest common divisor of two elements
`Poly` `getOne()`
Returns unit element of this ring (one)
`Poly` `getZero()`
Returns zero element of this ring
`int` `hashCode()`
`boolean` `isEuclideanRing()`
Returns whether this ring is a Euclidean ring
`boolean` `isField()`
Returns whether this ring is a field
`boolean` `isOne(Poly element)`
Tests whether specified element is one (exactly)
`boolean` `isUnit(Poly element)`
Tests whether specified element is a ring unit
`boolean` `isZero(Poly element)`
Tests whether specified element is zero
`Iterator<Poly>` `iterator()`
Returns iterator over ring elements (for finite rings, otherwise throws exception)
`Poly` ```multiply(Poly a, Poly b)```
Multiplies two elements
`Poly` ```multiplyMutable(Poly a, Poly b)```
Multiplies two elements and destroys the initial content of `a`
`Poly` `negate(Poly element)`
Negates the given element
`Poly` `negateMutable(Poly element)`
Negates the given element and destroys the initial content of `element`
`int` `nVariables()`
Number of polynomial variables
`Poly` `parse(String string)`
Parse string into ring element
`Poly` ```pow(Poly base, BigInteger exponent)```
Returns `base` in a power of `exponent` (non negative)
`Poly` ```randomElement(int minDegree, int maxDegree, org.apache.commons.math3.random.RandomGenerator rnd)```
Gives a random univariate polynomial with the degree randomly picked from `minDegree` (inclusive) to `maxDegree` (exclusive)
`Poly` ```randomElement(int degree, org.apache.commons.math3.random.RandomGenerator rnd)```
Gives a random univariate polynomial with the specified degree
`Poly` `randomElement(org.apache.commons.math3.random.RandomGenerator rnd)`
Gives a random univariate polynomial with the degree randomly picked from `MIN_DEGREE_OF_RANDOM_POLY` (inclusive) to `MAX_DEGREE_OF_RANDOM_POLY` (exclusive)
`Poly` ```randomElementTree(int minDegree, int maxDegree, org.apache.commons.math3.random.RandomGenerator rnd)```
Gives a random univariate polynomial with the degree randomly picked from `minDegree` (inclusive) to `maxDegree` (exclusive) and coefficients generated via `Ring.randomElementTree(RandomGenerator)` method
`Poly` `randomElementTree(org.apache.commons.math3.random.RandomGenerator rnd)`
Gives a random univariate polynomial with the degree randomly picked from `MIN_DEGREE_OF_RANDOM_POLY` (inclusive) to `MAX_DEGREE_OF_RANDOM_POLY` (exclusive)
`Poly` `reciprocal(Poly element)`
Gives the inverse element `element ^ (-1) `
`Poly` ```remainder(Poly a, Poly b)```
Returns the remainder of `dividend / divider`
`Poly` ```subtract(Poly a, Poly b)```
Subtracts `b` from `a`
`Poly` ```subtractMutable(Poly a, Poly b)```
Subtracts `b` from `a` and destroys the initial content of `a`
`String` `toString()`
`String` `toString(IStringifier<Poly> stringifier)`
convert this to string with the use of stringifier
`String` `toString(String... variables)`
`Poly` `valueOf(long val)`
Returns ring element associated with specified `long`
`Poly` `valueOf(Poly val)`
Converts a value from other ring to this ring.
`Poly` `valueOfBigInteger(BigInteger val)`
Returns ring element associated with specified integer
`Poly` `variable(int variable)`
Creates poly representing a single specified variable
• ### Methods inherited from class cc.redberry.rings.ARing

`isPerfectPower, perfectPowerBase, perfectPowerExponent`
• ### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`
• ### Methods inherited from interface cc.redberry.rings.poly.IPolynomialRing

`mkCoder, parse, signum`
• ### Methods inherited from interface cc.redberry.rings.Ring

`abs, add, createArray, createArray, createArray, createArray, createArray2d, createArray2d, createZeroesArray, createZeroesArray2d, decrement, divideExact, divideExactMutable, divideOrNull, factorial, fillZeros, gcd, gcd, getNegativeOne, increment, isFinite, isFiniteField, isMinusOne, isPerfectPower, isUnitOrZero, lcm, lcm, lcm, max, min, multiply, multiply, multiply, perfectPowerBase, perfectPowerExponent, pow, pow, quotient, randomElement, randomElementTree, randomNonZeroElement, setToValueOf, valueOf`
• ### Methods inherited from interface java.util.Comparator

`comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`
• ### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`
• ### Constructor Detail

• #### UnivariateRing

`public UnivariateRing(Poly factory)`
Creates ring of univariate polynomials which support operations over univariate polynomials of the type same as of provided `factory` polynomial
Parameters:
`factory` - factory polynomial (the exact value of `factory` is irrelevant)
• ### Method Detail

• #### nVariables

`public int nVariables()`
Description copied from interface: `IPolynomialRing`
Number of polynomial variables
• #### remainder

```public Poly remainder(Poly a,
Poly b)```
Description copied from interface: `Ring`
Returns the remainder of `dividend / divider`
Parameters:
`a` - the dividend
`b` - the divider
Returns:
the remainder of `dividend / divider`
• #### divideAndRemainder

```public Poly[] divideAndRemainder(Poly a,
Poly b)```
Description copied from interface: `Ring`
Returns quotient and remainder of `dividend / divider`
Parameters:
`a` - the dividend
`b` - the divider
Returns:
`{quotient, remainder}`
• #### gcd

```public Poly gcd(Poly a,
Poly b)```
Description copied from interface: `Ring`
Returns the greatest common divisor of two elements
Parameters:
`a` - the first element
`b` - the second element
Returns:
gcd
• #### extendedGCD

```public Poly[] extendedGCD(Poly a,
Poly b)```
Description copied from interface: `Ring`
Returns array of `[gcd(a,b), s, t]` such that `s * a + t * b = gcd(a, b)`
• #### firstBezoutCoefficient

```public Poly[] firstBezoutCoefficient(Poly a,
Poly b)```
Description copied from interface: `Ring`
Returns array of `[gcd(a,b), s]` such that `s * a + t * b = gcd(a, b)`
Parameters:
`a` - the first ring element (for which the Bezout coefficient is computed)
`b` - the second ring element
Returns:
array of `[gcd(a,b), s]` such that `s * a + t * b = gcd(a, b)`
• #### factorSquareFree

`public PolynomialFactorDecomposition<Poly> factorSquareFree(Poly element)`
Description copied from interface: `Ring`
Square-free factorization of specified element
• #### factor

`public PolynomialFactorDecomposition<Poly> factor(Poly element)`
Description copied from interface: `Ring`
Factor specified element
• #### variable

`public Poly variable(int variable)`
Description copied from interface: `IPolynomialRing`
Creates poly representing a single specified variable
• #### randomElement

```public Poly randomElement(int minDegree,
int maxDegree,
org.apache.commons.math3.random.RandomGenerator rnd)```
Gives a random univariate polynomial with the degree randomly picked from `minDegree` (inclusive) to `maxDegree` (exclusive)
Parameters:
`minDegree` - the minimal degree of the result
`maxDegree` - the maximal degree of the result
`rnd` - the source of randomness
Returns:
random univariate polynomial with the degree randomly picked from `minDegree` (inclusive) to `maxDegree` (exclusive)
`RandomUnivariatePolynomials`
• #### randomElement

```public Poly randomElement(int degree,
org.apache.commons.math3.random.RandomGenerator rnd)```
Gives a random univariate polynomial with the specified degree
Parameters:
`degree` - the degree of the result
`rnd` - the source of randomness
Returns:
random univariate polynomial with the specified degree
• #### randomElement

`public Poly randomElement(org.apache.commons.math3.random.RandomGenerator rnd)`
Gives a random univariate polynomial with the degree randomly picked from `MIN_DEGREE_OF_RANDOM_POLY` (inclusive) to `MAX_DEGREE_OF_RANDOM_POLY` (exclusive)
Parameters:
`rnd` - the source of randomness
Returns:
random univariate polynomial
• #### randomElementTree

```public Poly randomElementTree(int minDegree,
int maxDegree,
org.apache.commons.math3.random.RandomGenerator rnd)```
Gives a random univariate polynomial with the degree randomly picked from `minDegree` (inclusive) to `maxDegree` (exclusive) and coefficients generated via `Ring.randomElementTree(RandomGenerator)` method
Parameters:
`minDegree` - the minimal degree of the result
`maxDegree` - the maximal degree of the result
`rnd` - the source of randomness
Returns:
random univariate polynomial with the degree randomly picked from `minDegree` (inclusive) to `maxDegree` (exclusive)
`RandomUnivariatePolynomials`
• #### randomElementTree

`public Poly randomElementTree(org.apache.commons.math3.random.RandomGenerator rnd)`
Gives a random univariate polynomial with the degree randomly picked from `MIN_DEGREE_OF_RANDOM_POLY` (inclusive) to `MAX_DEGREE_OF_RANDOM_POLY` (exclusive)
Parameters:
`rnd` - the source of randomness
Returns:
random univariate polynomial
• #### factory

`public Poly factory()`
Description copied from interface: `IPolynomialRing`
Factory polynomial
Specified by:
`factory` in interface `IPolynomialRing<Poly extends IPolynomial<Poly>>`
• #### isEuclideanRing

`public boolean isEuclideanRing()`
Description copied from interface: `Ring`
Returns whether this ring is a Euclidean ring
Specified by:
`isEuclideanRing` in interface `Ring<Poly extends IPolynomial<Poly>>`
Returns:
whether this ring is a Euclidean ring
• #### isField

`public final boolean isField()`
Description copied from interface: `Ring`
Returns whether this ring is a field
Specified by:
`isField` in interface `Ring<Poly extends IPolynomial<Poly>>`
Returns:
whether this ring is a field
• #### cardinality

`public final BigInteger cardinality()`
Description copied from interface: `Ring`
Returns the number of elements in this ring (cardinality) or null if ring is infinite
Specified by:
`cardinality` in interface `Ring<Poly extends IPolynomial<Poly>>`
Returns:
the number of elements in this ring (cardinality) or null if ring is infinite
• #### characteristic

`public final BigInteger characteristic()`
Description copied from interface: `Ring`
Returns characteristic of this ring
Specified by:
`characteristic` in interface `Ring<Poly extends IPolynomial<Poly>>`
Returns:
characteristic of this ring

```public final Poly add(Poly a,
Poly b)```
Description copied from interface: `Ring`
Specified by:
`add` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`a` - the first element
`b` - the second element
Returns:
a + b
• #### subtract

```public final Poly subtract(Poly a,
Poly b)```
Description copied from interface: `Ring`
Subtracts `b` from `a`
Specified by:
`subtract` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`a` - the first element
`b` - the second element
Returns:
a - b
• #### multiply

```public final Poly multiply(Poly a,
Poly b)```
Description copied from interface: `Ring`
Multiplies two elements
Specified by:
`multiply` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`a` - the first element
`b` - the second element
Returns:
a * b
• #### negate

`public final Poly negate(Poly element)`
Description copied from interface: `Ring`
Negates the given element
Specified by:
`negate` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`element` - the ring element
Returns:
-val
• #### pow

```public Poly pow(Poly base,
BigInteger exponent)```
Description copied from interface: `Ring`
Returns `base` in a power of `exponent` (non negative)
Specified by:
`pow` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`base` - base
`exponent` - exponent (non negative)
Returns:
`base` in a power of `exponent`

```public Poly addMutable(Poly a,
Poly b)```
Description copied from interface: `Ring`
Adds two elements and destroys the initial content of `a`.
Specified by:
`addMutable` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`a` - the first element (may be destroyed)
`b` - the second element
Returns:
a + b
• #### subtractMutable

```public Poly subtractMutable(Poly a,
Poly b)```
Description copied from interface: `Ring`
Subtracts `b` from `a` and destroys the initial content of `a`
Specified by:
`subtractMutable` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`a` - the first element (may be destroyed)
`b` - the second element
Returns:
a - b
• #### multiplyMutable

```public Poly multiplyMutable(Poly a,
Poly b)```
Description copied from interface: `Ring`
Multiplies two elements and destroys the initial content of `a`
Specified by:
`multiplyMutable` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`a` - the first element (may be destroyed)
`b` - the second element
Returns:
a * b
• #### negateMutable

`public Poly negateMutable(Poly element)`
Description copied from interface: `Ring`
Negates the given element and destroys the initial content of `element`
Specified by:
`negateMutable` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`element` - the ring element (may be destroyed)
Returns:
-element
• #### reciprocal

`public final Poly reciprocal(Poly element)`
Description copied from interface: `Ring`
Gives the inverse element `element ^ (-1) `
Specified by:
`reciprocal` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`element` - the element
Returns:
`element ^ (-1)`
• #### getZero

`public final Poly getZero()`
Description copied from interface: `Ring`
Returns zero element of this ring
Specified by:
`getZero` in interface `Ring<Poly extends IPolynomial<Poly>>`
Returns:
0
• #### getOne

`public final Poly getOne()`
Description copied from interface: `Ring`
Returns unit element of this ring (one)
Specified by:
`getOne` in interface `Ring<Poly extends IPolynomial<Poly>>`
Returns:
1
• #### isZero

`public final boolean isZero(Poly element)`
Description copied from interface: `Ring`
Tests whether specified element is zero
Specified by:
`isZero` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`element` - the ring element
Returns:
whether specified element is zero
• #### isOne

`public final boolean isOne(Poly element)`
Description copied from interface: `Ring`
Tests whether specified element is one (exactly)
Specified by:
`isOne` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`element` - the ring element
Returns:
whether specified element is exactly one
`Ring.isUnit(Object)`
• #### isUnit

`public boolean isUnit(Poly element)`
Description copied from interface: `Ring`
Tests whether specified element is a ring unit
Specified by:
`isUnit` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`element` - the ring element
Returns:
whether specified element is a ring unit
`Ring.isOne(Object)`
• #### valueOf

`public final Poly valueOf(long val)`
Description copied from interface: `Ring`
Returns ring element associated with specified `long`
Specified by:
`valueOf` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`val` - machine integer
Returns:
ring element associated with specified `long`
• #### valueOfBigInteger

`public Poly valueOfBigInteger(BigInteger val)`
Description copied from interface: `Ring`
Returns ring element associated with specified integer
Specified by:
`valueOfBigInteger` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`val` - integer
Returns:
ring element associated with specified integer
• #### valueOf

`public final Poly valueOf(Poly val)`
Description copied from interface: `Ring`
Converts a value from other ring to this ring. The result is not guarantied to be a new instance (i.e. ```val == valueOf(val)``` is possible).
Specified by:
`valueOf` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`val` - some element from any ring
Returns:
this ring element associated with specified `val`
• #### copy

`public Poly copy(Poly element)`
Description copied from interface: `Ring`
Makes a deep copy of the specified element (for immutable instances the same reference returned).
Specified by:
`copy` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`element` - the element
Returns:
deep copy of specified element
• #### compare

```public final int compare(Poly o1,
Poly o2)```
Specified by:
`compare` in interface `Comparator<Poly extends IPolynomial<Poly>>`
• #### equals

`public final boolean equals(Object o)`
Specified by:
`equals` in interface `Comparator<Poly extends IPolynomial<Poly>>`
Overrides:
`equals` in class `Object`
• #### hashCode

`public final int hashCode()`
Overrides:
`hashCode` in class `Object`
• #### iterator

`public Iterator<Poly> iterator()`
Description copied from interface: `Ring`
Returns iterator over ring elements (for finite rings, otherwise throws exception)
Specified by:
`iterator` in interface `Ring<Poly extends IPolynomial<Poly>>`
Specified by:
`iterator` in interface `Iterable<Poly extends IPolynomial<Poly>>`
• #### parse

`public Poly parse(String string)`
Description copied from interface: `Ring`
Parse string into ring element
Specified by:
`parse` in interface `IParser<Poly extends IPolynomial<Poly>>`
Specified by:
`parse` in interface `Ring<Poly extends IPolynomial<Poly>>`
Parameters:
`string` - string
Returns:
ring element
`Coder`
• #### toString

`public String toString(IStringifier<Poly> stringifier)`
Description copied from interface: `Stringifiable`
convert this to string with the use of stringifier
Specified by:
`toString` in interface `Stringifiable<Poly extends IPolynomial<Poly>>`
• #### toString

`public String toString(String... variables)`
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`