Package cc.redberry.rings.poly
Class SimpleFieldExtension<E extends IUnivariatePolynomial<E>>
- java.lang.Object
-
- cc.redberry.rings.ARing<E>
-
- cc.redberry.rings.poly.SimpleFieldExtension<E>
-
- All Implemented Interfaces:
IParser<E>,Stringifiable<E>,IPolynomialRing<E>,Ring<E>,Serializable,Iterable<E>,Comparator<E>
- Direct Known Subclasses:
AlgebraicNumberField,FiniteField
public abstract class SimpleFieldExtension<E extends IUnivariatePolynomial<E>> extends ARing<E> implements IPolynomialRing<E>
A simple field extensionF(α)represented as a univariate quotient ringF[x]/<m(x)>wherem(x)is the minimal polynomial ofα. Elements of extension field are represented as univariate polynomials inα. To create simple field extensions one should use eitherFiniteFieldfor extensions of finite fields orAlgebraicNumberFieldfor extensions of rationals. SeeMultipleFieldExtensionfor implementation of multiple extensions.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSimpleFieldExtension(E minimalPoly)Constructs a simple field extensionF(α)generated by the algebraic numberαwith the specified minimal polynomial.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Eadd(E a, E b)Add two elementsEaddMutable(E a, E b)Adds two elements and destroys the initial content ofa.<Term extends AMonomial<Term>,mPoly extends AMultivariatePolynomial<Term,mPoly>>
MultipleFieldExtension<Term,mPoly,E>asMultipleExtension()Returns a view of this as a multiple field extensionBigIntegercardinality()Returns the number of elements in this ring (cardinality) or null if ring is infiniteBigIntegercharacteristic()Returns characteristic of this ringintcompare(E o1, E o2)EconjugatesProduct(E element)Gives the product of all conjugates of given element (except element itself), that isnorm(element) / elementEcopy(E element)Makes a deep copy of the specified element (for immutable instances the same reference returned).E[]createArray(int length)Creates generic array of ring elements of specified lengthE[][]createArray2d(int length)Creates 2d array of ring elements of specified lengthE[][]createArray2d(int m, int n)Creates 2d array of ring elements of specified shapeintdegree()Returns the degree of this filed extension (that is the degree of minimal polynomial)booleanequals(Object o)FactorDecomposition<E>factor(E element)Factor specified elementEfactory()Factory polynomialEgenerator()Returns the generator elementαof this field extensionF(α)EgetMinimalPolynomial()Returns the minimal polynomial of the generator (that is the "modulo" polynomialp(x)of this field viewed as quotient fieldF[x]/<p(x)>)EgetMinimalPolynomialRef()INTERNALEgetOne()Returns unit element of this ring (one)EgetZero()Returns zero element of this ringinthashCode()booleanisEuclideanRing()Returns whether this ring is a Euclidean ringbooleanisInTheBaseField(E element)Returns whether the given element belongs to the base fieldbooleanisOne(E element)Tests whether specified element is one (exactly)booleanisZero(E element)Tests whether specified element is zeroEminimalPolynomial(E element)Computes minimal polynomial of a given algebraic elementEmultiply(E a, E b)Multiplies two elementsEmultiplyMutable(E a, E b)Multiplies two elements and destroys the initial content ofaEnegate(E element)Negates the given elementEnegateMutable(E element)Negates the given element and destroys the initial content ofelementEnorm(E element)Gives the norm of field extension element (it is always belongs to the base field)<MPoly extends AMultivariatePolynomial>
MPolynormOfPolynomial(MultivariatePolynomial<E> poly)Gives the norm of multivariate polynomial over this field extension, which is always a polynomial with the coefficients from the base field.EnormOfPolynomial(UnivariatePolynomial<E> poly)Gives the norm of univariate polynomial over this field extension, which is always a polynomial with the coefficients from the base fieldintnVariables()Number of polynomial variablesEparse(String string)Parse string into ring elementErandomElement(org.apache.commons.math3.random.RandomGenerator rnd)Returns a random element from this ringEreciprocal(E element)Gives the inverse elementelement ^ (-1)protected booleanshouldReduceFast(int dividendDegree)empiric to switch between fast and plain divisionEsubtract(E a, E b)SubtractsbfromaEsubtractMutable(E a, E b)Subtractsbfromaand destroys the initial content ofaStringtoString()StringtoString(IStringifier<E> stringifier)convert this to string with the use of stringifierStringtoString(String... variables)Etrace(E element)Gives the trace of field extension element (it is always belongs to the base field)EvalueOf(long val)Returns ring element associated with specifiedlongEvalueOf(E val)Converts a value from other ring to this ring.EvalueOfBigInteger(BigInteger val)Returns ring element associated with specified integerEvariable(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, createZeroesArray, createZeroesArray2d, decrement, divideAndRemainder, divideExact, divideExactMutable, divideOrNull, extendedGCD, factorial, factorSquareFree, fillZeros, firstBezoutCoefficient, gcd, gcd, gcd, getNegativeOne, increment, isField, isFinite, isFiniteField, isMinusOne, isPerfectPower, isUnit, isUnitOrZero, iterator, lcm, lcm, lcm, max, min, multiply, multiply, multiply, perfectPowerBase, perfectPowerExponent, pow, pow, pow, quotient, randomElement, randomElementTree, randomElementTree, randomNonZeroElement, remainder, setToValueOf, valueOf
-
-
-
-
Constructor Detail
-
SimpleFieldExtension
protected SimpleFieldExtension(E minimalPoly)
Constructs a simple field extensionF(α)generated by the algebraic numberαwith the specified minimal polynomial.NOTE: irreducibility test for the minimal polynomial is not performed here, use
IrreduciblePolynomials.irreducibleQ(IUnivariatePolynomial)to test irreducibility.- Parameters:
minimalPoly- the minimal polynomial
-
-
Method Detail
-
isInTheBaseField
public boolean isInTheBaseField(E element)
Returns whether the given element belongs to the base field
-
generator
public E generator()
Returns the generator elementαof this field extensionF(α)
-
degree
public int degree()
Returns the degree of this filed extension (that is the degree of minimal polynomial)
-
getMinimalPolynomial
public E getMinimalPolynomial()
Returns the minimal polynomial of the generator (that is the "modulo" polynomialp(x)of this field viewed as quotient fieldF[x]/<p(x)>)
-
getMinimalPolynomialRef
public E getMinimalPolynomialRef()
INTERNAL
-
norm
public E norm(E element)
Gives the norm of field extension element (it is always belongs to the base field)
-
conjugatesProduct
public E conjugatesProduct(E element)
Gives the product of all conjugates of given element (except element itself), that isnorm(element) / element
-
trace
public E trace(E element)
Gives the trace of field extension element (it is always belongs to the base field)
-
normOfPolynomial
public E normOfPolynomial(UnivariatePolynomial<E> poly)
Gives the norm of univariate polynomial over this field extension, which is always a polynomial with the coefficients from the base field
-
normOfPolynomial
public <MPoly extends AMultivariatePolynomial> MPoly normOfPolynomial(MultivariatePolynomial<E> poly)
Gives the norm of multivariate polynomial over this field extension, which is always a polynomial with the coefficients from the base field.
-
minimalPolynomial
public E minimalPolynomial(E element)
Computes minimal polynomial of a given algebraic element
-
asMultipleExtension
public <Term extends AMonomial<Term>,mPoly extends AMultivariatePolynomial<Term,mPoly>> MultipleFieldExtension<Term,mPoly,E> asMultipleExtension()
Returns a view of this as a multiple field extension
-
nVariables
public int nVariables()
Description copied from interface:IPolynomialRingNumber of polynomial variables- Specified by:
nVariablesin interfaceIPolynomialRing<E extends IUnivariatePolynomial<E>>
-
factory
public E factory()
Description copied from interface:IPolynomialRingFactory polynomial- Specified by:
factoryin interfaceIPolynomialRing<E extends IUnivariatePolynomial<E>>
-
isEuclideanRing
public boolean isEuclideanRing()
Description copied from interface:RingReturns whether this ring is a Euclidean ring- Specified by:
isEuclideanRingin interfaceRing<E extends IUnivariatePolynomial<E>>- Returns:
- whether this ring is a Euclidean ring
-
cardinality
public 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<E extends IUnivariatePolynomial<E>>- Returns:
- the number of elements in this ring (cardinality) or null if ring is infinite
-
characteristic
public BigInteger characteristic()
Description copied from interface:RingReturns characteristic of this ring- Specified by:
characteristicin interfaceRing<E extends IUnivariatePolynomial<E>>- Returns:
- characteristic of this ring
-
shouldReduceFast
protected boolean shouldReduceFast(int dividendDegree)
empiric to switch between fast and plain division
-
add
public E add(E a, E b)
Description copied from interface:RingAdd two elements- Specified by:
addin interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
a- the first elementb- the second element- Returns:
- a + b
-
subtract
public E subtract(E a, E b)
Description copied from interface:RingSubtractsbfroma- Specified by:
subtractin interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
a- the first elementb- the second element- Returns:
- a - b
-
multiply
public E multiply(E a, E b)
Description copied from interface:RingMultiplies two elements- Specified by:
multiplyin interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
a- the first elementb- the second element- Returns:
- a * b
-
negate
public E negate(E element)
Description copied from interface:RingNegates the given element- Specified by:
negatein interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
element- the ring element- Returns:
- -val
-
addMutable
public E addMutable(E a, E b)
Description copied from interface:RingAdds two elements and destroys the initial content ofa.- Specified by:
addMutablein interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
a- the first element (may be destroyed)b- the second element- Returns:
- a + b
-
subtractMutable
public E subtractMutable(E a, E b)
Description copied from interface:RingSubtractsbfromaand destroys the initial content ofa- Specified by:
subtractMutablein interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
a- the first element (may be destroyed)b- the second element- Returns:
- a - b
-
multiplyMutable
public E multiplyMutable(E a, E b)
Description copied from interface:RingMultiplies two elements and destroys the initial content ofa- Specified by:
multiplyMutablein interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
a- the first element (may be destroyed)b- the second element- Returns:
- a * b
-
negateMutable
public E negateMutable(E element)
Description copied from interface:RingNegates the given element and destroys the initial content ofelement- Specified by:
negateMutablein interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
element- the ring element (may be destroyed)- Returns:
- -element
-
reciprocal
public E reciprocal(E element)
Description copied from interface:RingGives the inverse elementelement ^ (-1)- Specified by:
reciprocalin interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
element- the element- Returns:
element ^ (-1)
-
factor
public FactorDecomposition<E> factor(E element)
Description copied from interface:RingFactor specified element- Specified by:
factorin interfaceRing<E extends IUnivariatePolynomial<E>>
-
getZero
public E getZero()
Description copied from interface:RingReturns zero element of this ring- Specified by:
getZeroin interfaceRing<E extends IUnivariatePolynomial<E>>- Returns:
- 0
-
getOne
public E getOne()
Description copied from interface:RingReturns unit element of this ring (one)- Specified by:
getOnein interfaceRing<E extends IUnivariatePolynomial<E>>- Returns:
- 1
-
isZero
public boolean isZero(E element)
Description copied from interface:RingTests whether specified element is zero- Specified by:
isZeroin interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
element- the ring element- Returns:
- whether specified element is zero
-
isOne
public boolean isOne(E element)
Description copied from interface:RingTests whether specified element is one (exactly)- Specified by:
isOnein interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
element- the ring element- Returns:
- whether specified element is exactly one
- See Also:
Ring.isUnit(Object)
-
valueOf
public E valueOf(long val)
Description copied from interface:RingReturns ring element associated with specifiedlong- Specified by:
valueOfin interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
val- machine integer- Returns:
- ring element associated with specified
long
-
valueOfBigInteger
public E valueOfBigInteger(BigInteger val)
Description copied from interface:RingReturns ring element associated with specified integer- Specified by:
valueOfBigIntegerin interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
val- integer- Returns:
- ring element associated with specified integer
-
valueOf
public E valueOf(E 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<E extends IUnivariatePolynomial<E>>- Parameters:
val- some element from any ring- Returns:
- this ring element associated with specified
val
-
copy
public E copy(E element)
Description copied from interface:RingMakes a deep copy of the specified element (for immutable instances the same reference returned).- Specified by:
copyin interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
element- the element- Returns:
- deep copy of specified element
-
createArray
public E[] createArray(int length)
Description copied from interface:RingCreates generic array of ring elements of specified length- Specified by:
createArrayin interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
length- array length- Returns:
- array of ring elements of specified
length
-
createArray2d
public E[][] createArray2d(int length)
Description copied from interface:RingCreates 2d array of ring elements of specified length- Specified by:
createArray2din interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
length- array length- Returns:
- 2d array of ring elements of specified
length
-
createArray2d
public E[][] createArray2d(int m, int n)
Description copied from interface:RingCreates 2d array of ring elements of specified shape- Specified by:
createArray2din interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
m- result lengthn- length of each array in the result- Returns:
- 2d array E[m][n]
-
compare
public int compare(E o1, E o2)
- Specified by:
comparein interfaceComparator<E extends IUnivariatePolynomial<E>>
-
randomElement
public E randomElement(org.apache.commons.math3.random.RandomGenerator rnd)
Description copied from interface:RingReturns a random element from this ring- Specified by:
randomElementin interfaceRing<E extends IUnivariatePolynomial<E>>- Parameters:
rnd- the source of randomness- Returns:
- random element from this ring
-
variable
public E variable(int variable)
Description copied from interface:IPolynomialRingCreates poly representing a single specified variable- Specified by:
variablein interfaceIPolynomialRing<E extends IUnivariatePolynomial<E>>
-
parse
public E parse(String string)
Description copied from interface:RingParse string into ring element
-
equals
public boolean equals(Object o)
- Specified by:
equalsin interfaceComparator<E extends IUnivariatePolynomial<E>>- Overrides:
equalsin classObject
-
toString
public String toString(IStringifier<E> stringifier)
Description copied from interface:Stringifiableconvert this to string with the use of stringifier- Specified by:
toStringin interfaceStringifiable<E extends IUnivariatePolynomial<E>>
-
-