Package cc.redberry.rings.poly
Interface IPolynomial<Poly extends IPolynomial<Poly>>
-
- Type Parameters:
Poly- the type of polynomial (self type)
- All Superinterfaces:
Comparable<Poly>,Serializable,Stringifiable<Poly>
- All Known Subinterfaces:
IUnivariatePolynomial<Poly>
- All Known Implementing Classes:
AMultivariatePolynomial,MultivariatePolynomial,MultivariatePolynomialZp64,UnivariatePolynomial,UnivariatePolynomialZ64,UnivariatePolynomialZp64
public interface IPolynomial<Poly extends IPolynomial<Poly>> extends Comparable<Poly>, Stringifiable<Poly>, Serializable
Parent interface for all polynomials. All polynomial instances are mutable, so all structural operations except those where it is stated explicitly will in general modify the instance. All arithmetic operations (add(oth), multiply(oth), monic()etc.) applies tothisinplace and returnthisreference ( so e.g.(poly == poly.add(other))).Note: modifier operations are not synchronized.
- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description Polyadd(Poly oth)Addsothtothis.default Polyadd(Poly... oth)Addsothtothis.default voidassertSameCoefficientRingWith(Poly oth)Checks whetherothandthishave the same coefficient ring, if not exception will be throwndefault Polycanonical()Makes this poly monic if coefficient ring is field, otherwise makes this primitivePolyccAsPoly()Returns the constant coefficient as a constant polyPolyclone()Deep copy of thisBigIntegercoefficientRingCardinality()Returns cardinality of the coefficient ring of this polyBigIntegercoefficientRingCharacteristic()Returns characteristic of the coefficient ring of this polyBigIntegercoefficientRingPerfectPowerBase()Returnsbaseso thatcoefficientRingCardinality() == base^exponentor null if cardinality is not finiteBigIntegercoefficientRingPerfectPowerExponent()Returnsexponentso thatcoefficientRingCardinality() == base^exponentor null if cardinality is not finitedefault StringcoefficientRingToString()String representation of the coefficient ring of thisStringcoefficientRingToString(IStringifier<Poly> stringifier)String representation of the coefficient ring of thisPolycontentAsPoly()Returns the content of this (gcd of coefficients) as a constant polydefault Polycopy()Deep copy of this (alias forclone(), required for scala)Poly[]createArray(int length)overcome Java generics...default Poly[]createArray(Poly a)overcome Java generics...default Poly[]createArray(Poly a, Poly b)overcome Java generics...default Poly[]createArray(Poly a, Poly b, Poly c)overcome Java generics...Poly[][]createArray2d(int length)overcome Java generics...Poly[][]createArray2d(int length1, int length2)overcome Java generics...default PolycreateConstant(long value)Creates constant polynomial with specified valuePolycreateOne()Returns the new instance of unit polynomial (with the same coefficient ring)PolycreateZero()Returns the new instance of zero polynomial (with the same coefficient ring)Polydecrement()Subtracts 1 from thisintdegree()Returns the degree of this polynomialPolydivideByLC(Poly other)Divides this polynomial by the leading coefficient ofotheror returnsnull(causing loss of internal data) if some of the elements can't be exactly divided by theother.lc().Polyincrement()Adds 1 to thisbooleanisConstant()Returnstrueif this polynomial has only constant termbooleanisLinearExactly()Returns whether this polynomial is linear (i.e.booleanisLinearOrConstant()Returns whether this polynomial is linear (i.e.booleanisMonic()Returnstrueif this polynomial is monicbooleanisMonomial()Returnstrueif this polynomial has only one monomial termbooleanisOne()Returnstrueif this is onebooleanisOverField()Returns whether the coefficient ring of this polynomial is a fieldbooleanisOverFiniteField()Returns whether the coefficient ring of this polynomial is a finite fieldbooleanisOverPerfectPower()Returns whether thecoefficientRingCardinality()is a perfect powerbooleanisOverZ()Returns whether the coefficient ring of this polynomial is ZbooleanisUnitCC()Returns true if constant term is equal to onebooleanisZero()Returnstrueif this is zerobooleanisZeroCC()Returns true if constant term is zeroPolylcAsPoly()Returns the leading coefficient as a constant polyPolymonic()Setsthisto its monic part (that isthisdivided by its leading coefficient), or returnsnull(causing loss of internal data) if some of the elements can't be exactly divided by thelc().default PolymonicExact()Setsthisto its monic part (that isthisdivided by its leading coefficient), or throwsArithmeticExceptionif some of the elements can't be exactly divided by the l.c.PolymonicWithLC(Poly other)Setsthisto its monic part multiplied by the leading coefficient ofother;Polymultiply(long factor)Multiplies this byfactordefault Polymultiply(Iterable<Poly> oth)Multiplies this byothPolymultiply(Poly oth)Multiplies this byothdefault Polymultiply(Poly... oth)Multiplies this byothPolymultiplyByBigInteger(BigInteger factor)Multiplies this byfactorPolymultiplyByLC(Poly other)Multiply this by the leading coefficient ofotherPolynegate()Negates this and returnsPolyparsePoly(String string)Deprecated.useCoderto parse polynomialsPolyprimitivePart()Reduces poly to its primitive part (primitive part will always have positive l.c.)PolyprimitivePartSameSign()Reduces poly to its primitive part, so that primitive part will have the same signum as the initial polybooleansameCoefficientRingWith(Poly oth)Returns whetherothandthishave the same coefficient ringPolyset(Poly oth)Sets the content of this toothPolysetCoefficientRingFrom(Poly poly)Set the coefficient ring from specified polydefault PolysetCoefficientRingFromOptional(Poly poly)intsignumOfLC()Gives signum of the leading coefficientintsize()Returns the size of this polynomialPolysquare()SquaresthisPolysubtract(Poly oth)Subtractsothfromthis.default Polysubtract(Poly... oth)Subtractsothfromthis.default PolytoPositiveLC()If signum of leading coefficient is minus one, negate thisdefault StringtoString(String... variables)String representation of this polynomial with specified string variablesPolytoZero()Sets this to zero-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface cc.redberry.rings.io.Stringifiable
toString
-
-
-
-
Method Detail
-
sameCoefficientRingWith
boolean sameCoefficientRingWith(Poly oth)
Returns whetherothandthishave the same coefficient ring- Parameters:
oth- other polynomial- Returns:
- whether this and oth are over the same coefficient ring
-
assertSameCoefficientRingWith
default void assertSameCoefficientRingWith(Poly oth)
Checks whetherothandthishave the same coefficient ring, if not exception will be thrown- Parameters:
oth- other polynomial- Throws:
IllegalArgumentException- if this and oth have different coefficient ring
-
setCoefficientRingFrom
Poly setCoefficientRingFrom(Poly poly)
Set the coefficient ring from specified poly- Parameters:
poly- the polynomial- Returns:
- a copy of this with the coefficient ring taken from
poly
-
degree
int degree()
Returns the degree of this polynomial- Returns:
- the degree
-
size
int size()
Returns the size of this polynomial- Returns:
- the size
-
isZero
boolean isZero()
Returnstrueif this is zero- Returns:
- whether
thisis zero
-
isOne
boolean isOne()
Returnstrueif this is one- Returns:
- whether
thisis one
-
isMonic
boolean isMonic()
Returnstrueif this polynomial is monic- Returns:
- whether
thisis monic
-
isUnitCC
boolean isUnitCC()
Returns true if constant term is equal to one- Returns:
- whether constant term is 1
-
isZeroCC
boolean isZeroCC()
Returns true if constant term is zero- Returns:
- whether constant term is zero
-
isConstant
boolean isConstant()
Returnstrueif this polynomial has only constant term- Returns:
- whether
thisis constant
-
isMonomial
boolean isMonomial()
Returnstrueif this polynomial has only one monomial term- Returns:
- whether
thishas only one monomial term
-
isOverField
boolean isOverField()
Returns whether the coefficient ring of this polynomial is a field- Returns:
- whether the coefficient ring of this polynomial is a field
-
isOverZ
boolean isOverZ()
Returns whether the coefficient ring of this polynomial is Z- Returns:
- whether the coefficient ring of this polynomial is Z
-
isOverFiniteField
boolean isOverFiniteField()
Returns whether the coefficient ring of this polynomial is a finite field- Returns:
- whether the coefficient ring of this polynomial is a finite field
-
isLinearOrConstant
boolean isLinearOrConstant()
Returns whether this polynomial is linear (i.e. of the forma * X + b)
-
isLinearExactly
boolean isLinearExactly()
Returns whether this polynomial is linear (i.e. of the forma * X + bwith nonzeroa)
-
coefficientRingCardinality
BigInteger coefficientRingCardinality()
Returns cardinality of the coefficient ring of this poly- Returns:
- cardinality of the coefficient ring
-
coefficientRingCharacteristic
BigInteger coefficientRingCharacteristic()
Returns characteristic of the coefficient ring of this poly- Returns:
- characteristic of the coefficient ring
-
isOverPerfectPower
boolean isOverPerfectPower()
Returns whether thecoefficientRingCardinality()is a perfect power- Returns:
- whether the
coefficientRingCardinality()is a perfect power
-
coefficientRingPerfectPowerBase
BigInteger coefficientRingPerfectPowerBase()
Returnsbaseso thatcoefficientRingCardinality() == base^exponentor null if cardinality is not finite- Returns:
baseso thatcoefficientRingCardinality() == base^exponentor null if cardinality is not finite
-
coefficientRingPerfectPowerExponent
BigInteger coefficientRingPerfectPowerExponent()
Returnsexponentso thatcoefficientRingCardinality() == base^exponentor null if cardinality is not finite- Returns:
exponentso thatcoefficientRingCardinality() == base^exponentor null if cardinality is not finite
-
monic
Poly monic()
Setsthisto its monic part (that isthisdivided by its leading coefficient), or returnsnull(causing loss of internal data) if some of the elements can't be exactly divided by thelc(). NOTE: ifnullis returned, the content ofthisis destroyed.- Returns:
- monic
thisornull
-
monicExact
default Poly monicExact()
Setsthisto its monic part (that isthisdivided by its leading coefficient), or throwsArithmeticExceptionif some of the elements can't be exactly divided by the l.c.- Returns:
- monic
thisornull - Throws:
ArithmeticException- if some of the elements can't be exactly divided by the l.c.
-
canonical
default Poly canonical()
Makes this poly monic if coefficient ring is field, otherwise makes this primitive
-
signumOfLC
int signumOfLC()
Gives signum of the leading coefficient- Returns:
- signum of the leading coefficient
-
toPositiveLC
default Poly toPositiveLC()
If signum of leading coefficient is minus one, negate this
-
toZero
Poly toZero()
Sets this to zero- Returns:
- this := zero
-
set
Poly set(Poly oth)
Sets the content of this tooth- Parameters:
oth- the polynomial- Returns:
- this := oth
-
primitivePart
Poly primitivePart()
Reduces poly to its primitive part (primitive part will always have positive l.c.)- Returns:
- primitive part (poly will be modified)
-
primitivePartSameSign
Poly primitivePartSameSign()
Reduces poly to its primitive part, so that primitive part will have the same signum as the initial poly- Returns:
- primitive part (poly will be modified)
-
increment
Poly increment()
Adds 1 to this- Returns:
this + 1
-
decrement
Poly decrement()
Subtracts 1 from this- Returns:
this - 1
-
createZero
Poly createZero()
Returns the new instance of zero polynomial (with the same coefficient ring)- Returns:
- new instance of 0
-
createOne
Poly createOne()
Returns the new instance of unit polynomial (with the same coefficient ring)- Returns:
- new instance of 1
-
createConstant
default Poly createConstant(long value)
Creates constant polynomial with specified value- Parameters:
value- the value- Returns:
- constant polynomial
-
add
default Poly add(Poly... oth)
Addsothtothis.- Parameters:
oth- the polynomials- Returns:
this + oth
-
subtract
Poly subtract(Poly oth)
Subtractsothfromthis.- Parameters:
oth- the polynomial- Returns:
this - oth
-
subtract
default Poly subtract(Poly... oth)
Subtractsothfromthis.- Parameters:
oth- the polynomial- Returns:
this - oth
-
negate
Poly negate()
Negates this and returns- Returns:
- this negated
-
multiply
Poly multiply(Poly oth)
Multiplies this byoth- Parameters:
oth- the polynomial- Returns:
this * oth
-
multiply
default Poly multiply(Poly... oth)
Multiplies this byoth- Parameters:
oth- the polynomials- Returns:
this * oth
-
multiply
default Poly multiply(Iterable<Poly> oth)
Multiplies this byoth- Parameters:
oth- the polynomials- Returns:
this * oth
-
multiply
Poly multiply(long factor)
Multiplies this byfactor- Parameters:
factor- the factor- Returns:
this * factor
-
multiplyByBigInteger
Poly multiplyByBigInteger(BigInteger factor)
Multiplies this byfactor- Parameters:
factor- the factor- Returns:
this * factor
-
square
Poly square()
Squaresthis- Returns:
this * this
-
contentAsPoly
Poly contentAsPoly()
Returns the content of this (gcd of coefficients) as a constant poly
-
lcAsPoly
Poly lcAsPoly()
Returns the leading coefficient as a constant poly
-
ccAsPoly
Poly ccAsPoly()
Returns the constant coefficient as a constant poly
-
divideByLC
Poly divideByLC(Poly other)
Divides this polynomial by the leading coefficient ofotheror returnsnull(causing loss of internal data) if some of the elements can't be exactly divided by theother.lc(). NOTE: ifnullis returned, the content ofthisis destroyed.- Parameters:
other- the polynomial- Returns:
thisdivided by theother.lc()ornullif exact division is not possible
-
monicWithLC
Poly monicWithLC(Poly other)
Setsthisto its monic part multiplied by the leading coefficient ofother;- Parameters:
other- other polynomial- Returns:
- monic part multiplied by the leading coefficient of
otheror null if exact division by the reduced leading coefficient is not possible
-
multiplyByLC
Poly multiplyByLC(Poly other)
Multiply this by the leading coefficient ofother- Parameters:
other- polynomial- Returns:
- this * lc(other)
-
clone
Poly clone()
Deep copy of this- Returns:
- deep copy of this
-
copy
default Poly copy()
Deep copy of this (alias forclone(), required for scala)- Returns:
- deep copy of this
-
createArray
Poly[] createArray(int length)
overcome Java generics...
-
createArray2d
Poly[][] createArray2d(int length)
overcome Java generics...
-
createArray2d
Poly[][] createArray2d(int length1, int length2)
overcome Java generics...
-
coefficientRingToString
String coefficientRingToString(IStringifier<Poly> stringifier)
String representation of the coefficient ring of this
-
coefficientRingToString
default String coefficientRingToString()
String representation of the coefficient ring of this
-
toString
default String toString(String... variables)
String representation of this polynomial with specified string variables
-
parsePoly
@Deprecated Poly parsePoly(String string)
Deprecated.useCoderto parse polynomials
-
-