Package edu.jas.poly
Class GenPolynomialRing<C extends RingElem<C>>
java.lang.Object
edu.jas.poly.GenPolynomialRing<C>
- Type Parameters:
C
- coefficient type
- All Implemented Interfaces:
AbelianGroupFactory<GenPolynomial<C>>
,ElemFactory<GenPolynomial<C>>
,MonoidFactory<GenPolynomial<C>>
,RingFactory<GenPolynomial<C>>
,Serializable
,Iterable<GenPolynomial<C>>
- Direct Known Subclasses:
GenSolvablePolynomialRing
public class GenPolynomialRing<C extends RingElem<C>>
extends Object
implements RingFactory<GenPolynomial<C>>, Iterable<GenPolynomial<C>>
GenPolynomialRing generic polynomial factory. It implements RingFactory for
n-variate ordered polynomials over coefficients C. The variables commute with
each other and with the coefficients. For non-commutative coefficients some
care is taken to respect the multiplication order.
Almost immutable object, except variable names.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean
Flag to enable if preemptive interrupt is checked.final RingFactory
<C> The factory for the coefficients.(package private) static int
Count for number of polynomial creations.final ExpVector
The constant exponent vector 0 for this ring.protected int
Indicator if this ring is a field.private static final org.apache.logging.log4j.Logger
Log4j logger object.final int
The number of variables.The constant polynomial 1 for this ring.protected boolean
True for partially reversed variables.protected static final Random
A default random sequence generator.final TermOrder
The term order.private static AtomicLong
Counter to distinguish new variables.protected String[]
The names of the variables.The constant polynomial 0 for this ring. -
Constructor Summary
ConstructorsConstructorDescriptionGenPolynomialRing
(GenPolynomialRing<C> o, TermOrder to) The constructor creates a polynomial factory object with the the same coefficient factory, number of variables and variable names as the given polynomial factory, only the term order differs.GenPolynomialRing
(RingFactory<C> cf, int n) The constructor creates a polynomial factory object with the default term order.GenPolynomialRing
(RingFactory<C> cf, int n, TermOrder t) The constructor creates a polynomial factory object.GenPolynomialRing
(RingFactory<C> cf, int n, TermOrder t, String[] v) The constructor creates a polynomial factory object.GenPolynomialRing
(RingFactory<C> cf, int n, String[] v) The constructor creates a polynomial factory object.The constructor creates a polynomial factory object with the the same term order, number of variables and variable names as the given polynomial factory, only the coefficient factories differ.GenPolynomialRing
(RingFactory<C> cf, TermOrder t, String[] v) The constructor creates a polynomial factory object.GenPolynomialRing
(RingFactory<C> cf, String[] v) The constructor creates a polynomial factory object.GenPolynomialRing
(RingFactory<C> cf, String[] v, TermOrder t) The constructor creates a polynomial factory object. -
Method Summary
Modifier and TypeMethodDescriptionCharacteristic of this ring.charPolynomial
(GenMatrix<C> A) Characteristic polynomial of matrix.contract
(int i) Contract variables.copy()
Copy this factory.copy
(GenPolynomial<C> c) Copy polynomial c.copy
(List<GenPolynomial<C>> L) Copy polynomial list.determinant
(GenMatrix<C> A) Determinant of matrix via characteristic polynomial.Determinant of matrix from characteristic polynomial.Distributive representation as polynomial with all main variables.boolean
Comparison with any other object.extend
(int i) Extend variables.extend
(int i, boolean top) Extend variables.Extend variables.Extend variables.extendLower
(int i) Extend lower variables.extendLower
(String[] vn) Extend lower variables.extendLower
(String[] vn, boolean top) Extend lower variables.fromInteger
(long a) Get a (constant) GenPolynomial<C> element from a long value.Get a (constant) GenPolynomial<C> element from a BigInteger value.fromVector
(GenVector<C> a) Get a GenPolynomial<C> from a GenVector<C>.Get a list of the generating elements.generators
(int modv) Get a list of the generating elements excluding the module variables.Get PolynomialComparator.getComparator
(boolean rev) Get PolynomialComparator.int
Get the number of polynomial creations.Get the generating elements excluding the generators for the coefficient ring.getONE()
Get the one element.Get the one element from the coefficients.String[]
getVars()
Get the variable names.getZERO()
Get the zero element.Get the zero element from the coefficients.int
hashCode()
Hash code for this polynomial ring.boolean
Query if this ring is associative.boolean
Query if this ring is commutative.boolean
isField()
Query if this ring is a field.boolean
isFinite()
Is this structure finite or infinite.iterator()
Get a GenPolynomial iterator.String[]
newVars()
New variable names.static String[]
newVars
(int n) New variable names.String[]
New variable names.static String[]
New variable names.Parse a polynomial with the use of GenPolynomialTokenizer.Parse a polynomial with the use of GenPolynomialTokenizer.permutation
(List<Integer> P) Permutation of polynomial ring variables.static String[]
permuteVars
(List<Integer> P, String[] vars) Permute variable names.random
(int n) Random polynomial.random
(int k, int l, int d, float q) Generate a random polynomial.Generate a random polynomial.Random polynomial.recursive
(int i) Recursive representation as polynomial with i main variables.reverse()
Reverse variables.reverse
(boolean partial) Reverse variables.String[]
Set the variable names.toScript()
Get a scripting compatible string representation.Get a scripting compatible string representation of an ExpVector of this ring.toString()
Get the String representation.Trace of matrix from characteristic polynomial.univariate
(int i) Generate univariate polynomial in a given variable.univariate
(int modv, int i, long e) Generate univariate polynomial in a given variable with given exponent.univariate
(int i, long e) Generate univariate polynomial in a given variable with given exponent.univariate
(String x) Generate univariate polynomial in a given variable with given exponent.univariate
(String x, long e) Generate univariate polynomial in a given variable with given exponent.List
<? extends GenPolynomial<C>> Generate list of univariate polynomials in all variables.List
<? extends GenPolynomial<C>> univariateList
(int modv) Generate list of univariate polynomials in all variables.List
<? extends GenPolynomial<C>> univariateList
(int modv, long e) Generate list of univariate polynomials in all variables with given exponent.Get a (constant) GenPolynomial<C> element from a coefficient value.Get a GenPolynomial<C> element from a coefficient and an exponent vector.Get a GenPolynomial<C> element from an exponent vector.Get a GenPolynomial<C> element from a monomial.Get a GenPolynomial<C> element from a list of exponent vectors.Get a String representation of the variable names.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface edu.jas.structure.ElemFactory
valueOf
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
coFac
The factory for the coefficients. -
nvar
public final int nvarThe number of variables. -
tord
The term order. -
partial
protected boolean partialTrue for partially reversed variables. -
vars
The names of the variables. This value can be modified. -
varCounter
Counter to distinguish new variables. -
ZERO
The constant polynomial 0 for this ring. -
ONE
The constant polynomial 1 for this ring. -
evzero
The constant exponent vector 0 for this ring. -
random
A default random sequence generator. -
isField
protected int isFieldIndicator if this ring is a field. -
logger
private static final org.apache.logging.log4j.Logger loggerLog4j logger object. -
creations
static int creationsCount for number of polynomial creations. -
checkPreempt
volatile boolean checkPreemptFlag to enable if preemptive interrupt is checked.
-
-
Constructor Details
-
GenPolynomialRing
The constructor creates a polynomial factory object with the default term order.- Parameters:
cf
- factory for coefficients of type C.n
- number of variables.
-
GenPolynomialRing
The constructor creates a polynomial factory object.- Parameters:
cf
- factory for coefficients of type C.n
- number of variables.t
- a term order.
-
GenPolynomialRing
The constructor creates a polynomial factory object.- Parameters:
cf
- factory for coefficients of type C.v
- names for the variables.
-
GenPolynomialRing
The constructor creates a polynomial factory object.- Parameters:
cf
- factory for coefficients of type C.n
- number of variables.v
- names for the variables.
-
GenPolynomialRing
The constructor creates a polynomial factory object.- Parameters:
cf
- factory for coefficients of type C.t
- a term order.v
- names for the variables.
-
GenPolynomialRing
The constructor creates a polynomial factory object.- Parameters:
cf
- factory for coefficients of type C.v
- names for the variables.t
- a term order.
-
GenPolynomialRing
The constructor creates a polynomial factory object.- Parameters:
cf
- factory for coefficients of type C.n
- number of variables.t
- a term order.v
- names for the variables.
-
GenPolynomialRing
The constructor creates a polynomial factory object with the the same term order, number of variables and variable names as the given polynomial factory, only the coefficient factories differ.- Parameters:
cf
- factory for coefficients of type C.o
- other polynomial ring.
-
GenPolynomialRing
The constructor creates a polynomial factory object with the the same coefficient factory, number of variables and variable names as the given polynomial factory, only the term order differs.- Parameters:
o
- other polynomial ring.to
- term order.
-
-
Method Details
-
copy
Copy this factory.- Returns:
- a clone of this.
-
toString
Get the String representation. -
toScript
Get a scripting compatible string representation.- Specified by:
toScript
in interfaceElemFactory<C extends RingElem<C>>
- Returns:
- script compatible representation for this Element.
- See Also:
-
toScript
Get a scripting compatible string representation of an ExpVector of this ring.- Parameters:
e
- exponent vector- Returns:
- script compatible representation for the ExpVector.
-
equals
Comparison with any other object. -
hashCode
public int hashCode()Hash code for this polynomial ring. -
getCreations
public int getCreations()Get the number of polynomial creations.- Returns:
- creations.
-
getVars
Get the variable names.- Returns:
- vars.
-
setVars
Set the variable names.- Returns:
- old vars.
-
varsToString
Get a String representation of the variable names.- Returns:
- names separated by commas.
-
getZEROCoefficient
Get the zero element from the coefficients.- Returns:
- 0 as C.
-
getONECoefficient
Get the one element from the coefficients.- Returns:
- 1 as C.
-
getZERO
Get the zero element.- Specified by:
getZERO
in interfaceAbelianGroupFactory<C extends RingElem<C>>
- Returns:
- 0 as GenPolynomial
.
-
getONE
Get the one element.- Specified by:
getONE
in interfaceMonoidFactory<C extends RingElem<C>>
- Returns:
- 1 as GenPolynomial
.
-
isCommutative
public boolean isCommutative()Query if this ring is commutative.- Specified by:
isCommutative
in interfaceMonoidFactory<C extends RingElem<C>>
- Returns:
- true if this ring is commutative, else false.
-
isAssociative
public boolean isAssociative()Query if this ring is associative.- Specified by:
isAssociative
in interfaceMonoidFactory<C extends RingElem<C>>
- Returns:
- true if this ring is associative, else false.
-
isField
public boolean isField()Query if this ring is a field.- Specified by:
isField
in interfaceRingFactory<C extends RingElem<C>>
- Returns:
- false.
-
characteristic
Characteristic of this ring.- Specified by:
characteristic
in interfaceRingFactory<C extends RingElem<C>>
- Returns:
- characteristic of this ring.
-
valueOf
Get a (constant) GenPolynomial<C> element from a coefficient value.- Parameters:
a
- coefficient.- Returns:
- a GenPolynomial<C>.
-
valueOf
Get a GenPolynomial<C> element from an exponent vector.- Parameters:
e
- exponent vector.- Returns:
- a GenPolynomial<C>.
-
valueOf
Get a GenPolynomial<C> element from a list of exponent vectors.- Parameters:
E
- list of exponent vector.- Returns:
- a GenPolynomial<C>.
-
valueOf
Get a GenPolynomial<C> element from a coefficient and an exponent vector.- Parameters:
a
- coefficient.e
- exponent vector.- Returns:
- a GenPolynomial<C>.
-
valueOf
Get a GenPolynomial<C> element from a monomial.- Parameters:
m
- monomial.- Returns:
- a GenPolynomial<C>.
-
fromInteger
Get a (constant) GenPolynomial<C> element from a long value.- Specified by:
fromInteger
in interfaceElemFactory<C extends RingElem<C>>
- Parameters:
a
- long.- Returns:
- a GenPolynomial<C>.
-
fromInteger
Get a (constant) GenPolynomial<C> element from a BigInteger value.- Specified by:
fromInteger
in interfaceElemFactory<C extends RingElem<C>>
- Parameters:
a
- BigInteger.- Returns:
- a GenPolynomial<C>.
-
fromVector
Get a GenPolynomial<C> from a GenVector<C>.- Parameters:
a
- GenVector<C>.- Returns:
- a GenPolynomial<C>.
-
random
Random polynomial. Generates a random polynomial with k = 5, l = n, d = (nvar == 1) ? n : 3, q = (nvar == 1) ? 0.7 : 0.3.- Specified by:
random
in interfaceElemFactory<C extends RingElem<C>>
- Parameters:
n
- number of terms.- Returns:
- a random polynomial.
-
random
Random polynomial. Generates a random polynomial with k = 5, l = n, d = n, q = (nvar == 1) ? 0.5 : 0.3.- Specified by:
random
in interfaceElemFactory<C extends RingElem<C>>
- Parameters:
n
- number of terms.rnd
- is a source for random bits.- Returns:
- a random polynomial.
-
random
Generate a random polynomial.- Parameters:
k
- bitsize of random coefficients.l
- number of terms.d
- maximal degree in each variable.q
- density of nozero exponents.- Returns:
- a random polynomial.
-
random
Generate a random polynomial.- Parameters:
k
- bitsize of random coefficients.l
- number of terms.d
- maximal degree in each variable.q
- density of nozero exponents.rnd
- is a source for random bits.- Returns:
- a random polynomial.
-
copy
Copy polynomial c.- Specified by:
copy
in interfaceElemFactory<C extends RingElem<C>>
- Parameters:
c
-- Returns:
- a copy of c.
-
copy
Copy polynomial list.- Parameters:
L
- polynomial list- Returns:
- a copy of L in this ring.
-
parse
Parse a polynomial with the use of GenPolynomialTokenizer.- Specified by:
parse
in interfaceElemFactory<C extends RingElem<C>>
- Parameters:
s
- String.- Returns:
- GenPolynomial from s.
-
parse
Parse a polynomial with the use of GenPolynomialTokenizer.- Specified by:
parse
in interfaceElemFactory<C extends RingElem<C>>
- Parameters:
r
- Reader.- Returns:
- next GenPolynomial from r.
-
univariate
Generate univariate polynomial in a given variable with given exponent.- Parameters:
x
- the name of a variable.- Returns:
- x as univariate polynomial.
-
univariate
Generate univariate polynomial in a given variable with given exponent.- Parameters:
x
- the name of the variable.e
- the exponent of the variable.- Returns:
- x^e as univariate polynomial.
-
univariate
Generate univariate polynomial in a given variable.- Parameters:
i
- the index of the variable.- Returns:
- X_i as univariate polynomial.
-
univariate
Generate univariate polynomial in a given variable with given exponent.- Parameters:
i
- the index of the variable.e
- the exponent of the variable.- Returns:
- X_i^e as univariate polynomial.
-
univariate
Generate univariate polynomial in a given variable with given exponent.- Parameters:
modv
- number of module variables.i
- the index of the variable.e
- the exponent of the variable.- Returns:
- X_i^e as univariate polynomial.
-
getGenerators
Get the generating elements excluding the generators for the coefficient ring.- Returns:
- a list of generating elements for this ring.
-
generators
Get a list of the generating elements.- Specified by:
generators
in interfaceElemFactory<C extends RingElem<C>>
- Returns:
- list of generators for the algebraic structure.
- See Also:
-
generators
Get a list of the generating elements excluding the module variables.- Parameters:
modv
- number of module variables- Returns:
- list of generators for the polynomial ring.
-
isFinite
public boolean isFinite()Is this structure finite or infinite.- Specified by:
isFinite
in interfaceElemFactory<C extends RingElem<C>>
- Returns:
- true if this structure is finite, else false.
- See Also:
-
univariateList
Generate list of univariate polynomials in all variables.- Returns:
- List(X_1,...,X_n) a list of univariate polynomials.
-
univariateList
Generate list of univariate polynomials in all variables.- Parameters:
modv
- number of module variables.- Returns:
- List(X_1,...,X_n) a list of univariate polynomials.
-
univariateList
Generate list of univariate polynomials in all variables with given exponent.- Parameters:
modv
- number of module variables.e
- the exponent of the variables.- Returns:
- List(X_1^e,...,X_n^e) a list of univariate polynomials.
-
extend
Extend variables. Used e.g. in module embedding. Extend number of variables by i.- Parameters:
i
- number of variables to extend.- Returns:
- extended polynomial ring factory.
-
extend
Extend variables. Used e.g. in module embedding. Extend number of variables by i.- Parameters:
i
- number of variables to extend.top
- true for TOP term order, false for POT term order.- Returns:
- extended polynomial ring factory.
-
extend
Extend variables. Used e.g. in module embedding. Extend number of variables by length(vn).- Parameters:
vn
- names for extended variables.- Returns:
- extended polynomial ring factory.
-
extend
Extend variables. Used e.g. in module embedding. Extend number of variables by length(vn).- Parameters:
vn
- names for extended variables.top
- true for TOP term order, false for POT term order.- Returns:
- extended polynomial ring factory.
-
extendLower
Extend lower variables. Extend number of variables by i.- Parameters:
i
- number of variables to extend.- Returns:
- extended polynomial ring factory.
-
extendLower
Extend lower variables. Extend number of variables by length(vn).- Parameters:
vn
- names for extended lower variables.- Returns:
- extended polynomial ring factory.
-
extendLower
Extend lower variables. Extend number of variables by length(vn).- Parameters:
vn
- names for extended lower variables.top
- true for TOP term order, false for POT term order.- Returns:
- extended polynomial ring factory.
-
contract
Contract variables. Used e.g. in module embedding. Contract number of variables by i.- Parameters:
i
- number of variables to remove.- Returns:
- contracted polynomial ring factory.
-
recursive
Recursive representation as polynomial with i main variables.- Parameters:
i
- number of main variables.- Returns:
- recursive polynomial ring factory.
-
distribute
Distributive representation as polynomial with all main variables.- Returns:
- distributive polynomial ring factory.
-
reverse
Reverse variables. Used e.g. in opposite rings.- Returns:
- polynomial ring factory with reversed variables.
-
reverse
Reverse variables. Used e.g. in opposite rings. The coefficient ring must be commuative.- Parameters:
partial
- true for partially reversed term orders.- Returns:
- polynomial ring factory with reversed variables.
-
getComparator
Get PolynomialComparator.- Returns:
- polynomial comparator.
-
getComparator
Get PolynomialComparator.- Parameters:
rev
- for reverse comparator.- Returns:
- polynomial comparator.
-
newVars
New variable names. Generate new names for variables,- Parameters:
prefix
- name prefix.n
- number of variables.- Returns:
- new variable names.
-
newVars
New variable names. Generate new names for variables,- Parameters:
prefix
- name prefix.- Returns:
- new variable names.
-
newVars
New variable names. Generate new names for variables,- Parameters:
n
- number of variables.- Returns:
- new variable names.
-
newVars
New variable names. Generate new names for variables,- Returns:
- new variable names.
-
permuteVars
Permute variable names.- Parameters:
P
- permutation.vars
- variable names.- Returns:
- P(vars).
-
permutation
Permutation of polynomial ring variables.- Parameters:
P
- permutation.- Returns:
- P(this).
-
charPolynomial
Characteristic polynomial of matrix. Note: using Faddeev–LeVerrier algorithm- Parameters:
A
- a square matrix.- Returns:
- characteristic polynomial of A.
-
determinantFromCharPol
Determinant of matrix from characteristic polynomial. Note: using Faddeev–LeVerrier algorithm- Parameters:
P
- characteristic polynomial of a matrix.- Returns:
- determinant from characteristic polynomial.
-
determinant
Determinant of matrix via characteristic polynomial. Note: using Faddeev–LeVerrier algorithm- Parameters:
A
- square matrix.- Returns:
- determinant of A from characteristic polynomial of A.
-
traceFromCharPol
Trace of matrix from characteristic polynomial.- Parameters:
P
- characteristic polynomial of a matrix.- Returns:
- trace from characteristic polynomial.
-
iterator
Get a GenPolynomial iterator.
-