Package cc.redberry.rings.poly
Class MultivariateRing<Poly extends AMultivariatePolynomial<?,Poly>>
- java.lang.Object
-
- cc.redberry.rings.ARing<Poly>
-
- cc.redberry.rings.poly.MultivariateRing<Poly>
-
- Type Parameters:
Poly- type of multivariate polynomials
- All Implemented Interfaces:
IParser<Poly>,Stringifiable<Poly>,IPolynomialRing<Poly>,Ring<Poly>,Serializable,Iterable<Poly>,Comparator<Poly>
public final class MultivariateRing<Poly extends AMultivariatePolynomial<?,Poly>> extends ARing<Poly>
Ring of multivariate polynomials.- Since:
- 1.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intDEGREE_OF_RANDOM_POLYDefault degree of polynomial generated withrandomElementTree(RandomGenerator)static intSIZE_OF_RANDOM_POLYDefault size of polynomial generated withrandomElementTree(RandomGenerator)
-
Constructor Summary
Constructors Constructor Description MultivariateRing(Poly factory)Creates ring of multivariate polynomials which support operations over multivariate polynomials of the type and number of variables same as of providedfactorypolynomial
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Polyadd(Poly a, Poly b)Add two elementsPolyaddMutable(Poly a, Poly b)Adds two elements and destroys the initial content ofa.BigIntegercardinality()Returns the number of elements in this ring (cardinality) or null if ring is infiniteBigIntegercharacteristic()Returns characteristic of this ringintcompare(Poly o1, Poly o2)Polycopy(Poly element)Makes a deep copy of the specified element (for immutable instances the same reference returned).Polycreate(DegreeVector term)Creates multivariate polynomial over the same ring as this with the single monomialPoly[]divideAndRemainder(Poly dividend, Poly divider)Returns quotient and remainder ofdividend / dividerMultivariateRing<Poly>dropVariable()booleanequals(Object o)PolynomialFactorDecomposition<Poly>factor(Poly element)Factor specified elementPolynomialFactorDecomposition<Poly>factorSquareFree(Poly element)Square-free factorization of specified elementPolyfactory()Factory polynomialPolygcd(Iterable<Poly> elements)Returns greatest common divisor of specified elementsPolygcd(Poly[] elements)Returns greatest common divisor of specified elementsPolygcd(Poly a, Poly b)Returns the greatest common divisor of two elementsPolygetOne()Returns unit element of this ring (one)PolygetZero()Returns zero element of this ringinthashCode()booleanisEuclideanRing()Returns whether this ring is a Euclidean ringbooleanisField()Returns whether this ring is a fieldbooleanisOne(Poly element)Tests whether specified element is one (exactly)booleanisUnit(Poly element)Tests whether specified element is a ring unitbooleanisZero(Poly element)Tests whether specified element is zeroIterator<Poly>iterator()Returns iterator over ring elements (for finite rings, otherwise throws exception)<Term extends AMonomial<Term>>
IMonomialAlgebra<Term>monomialAlgebra()Polymultiply(Poly a, Poly b)Multiplies two elementsPolymultiplyMutable(Poly a, Poly b)Multiplies two elements and destroys the initial content ofaPolynegate(Poly element)Negates the given elementPolynegateMutable(Poly element)Negates the given element and destroys the initial content ofelementintnVariables()Number of polynomial variablesComparator<DegreeVector>ordering()Polyparse(String string)Parse string into ring elementPolypow(Poly base, BigInteger exponent)Returnsbasein a power ofexponent(non negative)PolyrandomElement(int degree, int size)Generates random multivariate polynomialPolyrandomElement(int degree, int size, org.apache.commons.math3.random.RandomGenerator rnd)Generates random multivariate polynomialPolyrandomElement(org.apache.commons.math3.random.RandomGenerator rnd)Gives a random constant polynomial.PolyrandomElementTree(int degree, int size, org.apache.commons.math3.random.RandomGenerator rnd)Generates random multivariate polynomialPolyrandomElementTree(org.apache.commons.math3.random.RandomGenerator rnd)If this ring has a complicated nested structure, this method guaranties that the resulting random element will reflect ring complicated structure, i.e.Polyreciprocal(Poly element)Gives the inverse elementelement ^ (-1)Polysubtract(Poly a, Poly b)SubtractsbfromaPolysubtractMutable(Poly a, Poly b)Subtractsbfromaand destroys the initial content ofaStringtoString()StringtoString(IStringifier<Poly> stringifier)convert this to string with the use of stringifierStringtoString(String... variables)PolyvalueOf(long val)Returns ring element associated with specifiedlongPolyvalueOf(Poly val)Converts a value from other ring to this ring.PolyvalueOfBigInteger(BigInteger val)Returns ring element associated with specified integerPolyvariable(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 java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface cc.redberry.rings.poly.IPolynomialRing
mkCoder, parse, signum
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface cc.redberry.rings.Ring
abs, add, createArray, createArray, createArray, createArray, createArray2d, createArray2d, createZeroesArray, createZeroesArray2d, decrement, divideExact, divideExactMutable, divideOrNull, extendedGCD, factorial, fillZeros, firstBezoutCoefficient, getNegativeOne, increment, isFinite, isFiniteField, isMinusOne, isPerfectPower, isUnitOrZero, lcm, lcm, lcm, max, min, multiply, multiply, multiply, perfectPowerBase, perfectPowerExponent, pow, pow, quotient, randomElement, randomElementTree, randomNonZeroElement, remainder, setToValueOf, valueOf
-
-
-
-
Field Detail
-
DEGREE_OF_RANDOM_POLY
public static final int DEGREE_OF_RANDOM_POLY
Default degree of polynomial generated withrandomElementTree(RandomGenerator)- See Also:
- Constant Field Values
-
SIZE_OF_RANDOM_POLY
public static final int SIZE_OF_RANDOM_POLY
Default size of polynomial generated withrandomElementTree(RandomGenerator)- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MultivariateRing
public MultivariateRing(Poly factory)
Creates ring of multivariate polynomials which support operations over multivariate polynomials of the type and number of variables same as of providedfactorypolynomial- Parameters:
factory- the factory polynomial (the exact value offactoryis irrelevant) which fixes the element type of this ring, coefficient ring and the number of variables
-
-
Method Detail
-
monomialAlgebra
public <Term extends AMonomial<Term>> IMonomialAlgebra<Term> monomialAlgebra()
-
nVariables
public int nVariables()
Description copied from interface:IPolynomialRingNumber of polynomial variables
-
ordering
public Comparator<DegreeVector> ordering()
-
dropVariable
public MultivariateRing<Poly> dropVariable()
-
divideAndRemainder
public Poly[] divideAndRemainder(Poly dividend, Poly divider)
Description copied from interface:RingReturns quotient and remainder ofdividend / divider- Parameters:
dividend- the dividenddivider- the divider- Returns:
{quotient, remainder}
-
gcd
public Poly gcd(Poly a, Poly b)
Description copied from interface:RingReturns the greatest common divisor of two elements- Parameters:
a- the first elementb- the second element- Returns:
- gcd
-
gcd
public Poly gcd(Poly[] elements)
Description copied from interface:RingReturns greatest common divisor of specified elements- Parameters:
elements- the elements- Returns:
- gcd
-
gcd
public Poly gcd(Iterable<Poly> elements)
Description copied from interface:RingReturns greatest common divisor of specified elements- Parameters:
elements- the elements- Returns:
- gcd
-
factorSquareFree
public PolynomialFactorDecomposition<Poly> factorSquareFree(Poly element)
Description copied from interface:RingSquare-free factorization of specified element
-
factor
public PolynomialFactorDecomposition<Poly> factor(Poly element)
Description copied from interface:RingFactor specified element
-
variable
public Poly variable(int variable)
Description copied from interface:IPolynomialRingCreates poly representing a single specified variable
-
create
public Poly create(DegreeVector term)
Creates multivariate polynomial over the same ring as this with the single monomial- Parameters:
term- the monomial- Returns:
- multivariate polynomial
-
randomElement
public Poly randomElement(int degree, int size, org.apache.commons.math3.random.RandomGenerator rnd)
Generates random multivariate polynomial- Parameters:
degree- maximal degree of the resultsize- number of elements in the resultrnd- random source- Returns:
- random polynomial
-
randomElementTree
public Poly randomElementTree(int degree, int size, org.apache.commons.math3.random.RandomGenerator rnd)
Generates random multivariate polynomial- Parameters:
degree- maximal degree of the resultsize- number of elements in the resultrnd- random source- Returns:
- random polynomial
-
randomElement
public Poly randomElement(int degree, int size)
Generates random multivariate polynomial- Parameters:
degree- maximal degree of the resultsize- number of elements in the result- Returns:
- random polynomial
-
randomElement
public Poly randomElement(org.apache.commons.math3.random.RandomGenerator rnd)
Gives a random constant polynomial. For generating non-constant random polynomials seeRandomMultivariatePolynomials- Parameters:
rnd- the source of randomness- Returns:
- random constant polynomial
- See Also:
RandomMultivariatePolynomials
-
randomElementTree
public Poly randomElementTree(org.apache.commons.math3.random.RandomGenerator rnd)
Description copied from interface:RingIf this ring has a complicated nested structure, this method guaranties that the resulting random element will reflect ring complicated structure, i.e. the result will be roughly as complicated as the ring is- Returns:
- random element from this ring
-
factory
public Poly factory()
Description copied from interface:IPolynomialRingFactory polynomial- Specified by:
factoryin interfaceIPolynomialRing<Poly extends IPolynomial<Poly>>
-
isEuclideanRing
public boolean isEuclideanRing()
Description copied from interface:RingReturns whether this ring is a Euclidean ring- Specified by:
isEuclideanRingin interfaceRing<Poly extends IPolynomial<Poly>>- Returns:
- whether this ring is a Euclidean ring
-
isField
public final boolean isField()
Description copied from interface:RingReturns whether this ring is a field- Specified by:
isFieldin interfaceRing<Poly extends IPolynomial<Poly>>- Returns:
- whether this ring is a field
-
cardinality
public final BigInteger cardinality()
Description copied from interface:RingReturns the number of elements in this ring (cardinality) or null if ring is infinite- Specified by:
cardinalityin interfaceRing<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:RingReturns characteristic of this ring- Specified by:
characteristicin interfaceRing<Poly extends IPolynomial<Poly>>- Returns:
- characteristic of this ring
-
add
public final Poly add(Poly a, Poly b)Description copied from interface:RingAdd two elements- Specified by:
addin interfaceRing<Poly extends IPolynomial<Poly>>- Parameters:
a- the first elementb- the second element- Returns:
- a + b
-
subtract
public final Poly subtract(Poly a, Poly b)Description copied from interface:RingSubtractsbfroma- Specified by:
subtractin interfaceRing<Poly extends IPolynomial<Poly>>- Parameters:
a- the first elementb- the second element- Returns:
- a - b
-
multiply
public final Poly multiply(Poly a, Poly b)Description copied from interface:RingMultiplies two elements- Specified by:
multiplyin interfaceRing<Poly extends IPolynomial<Poly>>- Parameters:
a- the first elementb- the second element- Returns:
- a * b
-
negate
public final Poly negate(Poly element)
Description copied from interface:RingNegates the given element- Specified by:
negatein interfaceRing<Poly extends IPolynomial<Poly>>- Parameters:
element- the ring element- Returns:
- -val
-
pow
public Poly pow(Poly base, BigInteger exponent)Description copied from interface:RingReturnsbasein a power ofexponent(non negative)- Specified by:
powin interfaceRing<Poly extends IPolynomial<Poly>>- Parameters:
base- baseexponent- exponent (non negative)- Returns:
basein a power ofexponent
-
addMutable
public Poly addMutable(Poly a, Poly b)Description copied from interface:RingAdds two elements and destroys the initial content ofa.- Specified by:
addMutablein interfaceRing<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:RingSubtractsbfromaand destroys the initial content ofa- Specified by:
subtractMutablein interfaceRing<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:RingMultiplies two elements and destroys the initial content ofa- Specified by:
multiplyMutablein interfaceRing<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:RingNegates the given element and destroys the initial content ofelement- Specified by:
negateMutablein interfaceRing<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:RingGives the inverse elementelement ^ (-1)- Specified by:
reciprocalin interfaceRing<Poly extends IPolynomial<Poly>>- Parameters:
element- the element- Returns:
element ^ (-1)
-
getZero
public final Poly getZero()
Description copied from interface:RingReturns zero element of this ring- Specified by:
getZeroin interfaceRing<Poly extends IPolynomial<Poly>>- Returns:
- 0
-
getOne
public final Poly getOne()
Description copied from interface:RingReturns unit element of this ring (one)- Specified by:
getOnein interfaceRing<Poly extends IPolynomial<Poly>>- Returns:
- 1
-
isZero
public final boolean isZero(Poly element)
Description copied from interface:RingTests whether specified element is zero- Specified by:
isZeroin interfaceRing<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:RingTests whether specified element is one (exactly)- Specified by:
isOnein interfaceRing<Poly extends IPolynomial<Poly>>- Parameters:
element- the ring element- Returns:
- whether specified element is exactly one
- See Also:
Ring.isUnit(Object)
-
isUnit
public boolean isUnit(Poly element)
Description copied from interface:RingTests whether specified element is a ring unit- Specified by:
isUnitin interfaceRing<Poly extends IPolynomial<Poly>>- Parameters:
element- the ring element- Returns:
- whether specified element is a ring unit
- See Also:
Ring.isOne(Object)
-
valueOf
public final Poly valueOf(long val)
Description copied from interface:RingReturns ring element associated with specifiedlong- Specified by:
valueOfin interfaceRing<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:RingReturns ring element associated with specified integer- Specified by:
valueOfBigIntegerin interfaceRing<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:RingConverts 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:
valueOfin interfaceRing<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:RingMakes a deep copy of the specified element (for immutable instances the same reference returned).- Specified by:
copyin interfaceRing<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:
comparein interfaceComparator<Poly extends IPolynomial<Poly>>
-
equals
public final boolean equals(Object o)
- Specified by:
equalsin interfaceComparator<Poly extends IPolynomial<Poly>>- Overrides:
equalsin classObject
-
iterator
public Iterator<Poly> iterator()
Description copied from interface:RingReturns iterator over ring elements (for finite rings, otherwise throws exception)- Specified by:
iteratorin interfaceIterable<Poly extends IPolynomial<Poly>>- Specified by:
iteratorin interfaceRing<Poly extends IPolynomial<Poly>>
-
parse
public Poly parse(String string)
Description copied from interface:RingParse string into ring element- Specified by:
parsein interfaceIParser<Poly extends IPolynomial<Poly>>- Specified by:
parsein interfaceRing<Poly extends IPolynomial<Poly>>- Parameters:
string- string- Returns:
- ring element
- See Also:
Coder
-
toString
public String toString(IStringifier<Poly> stringifier)
Description copied from interface:Stringifiableconvert this to string with the use of stringifier- Specified by:
toStringin interfaceStringifiable<Poly extends IPolynomial<Poly>>
-
-