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 extension F(α) represented as a univariate quotient ring F[x]/<m(x)> where m(x) is the minimal polynomial of α. Elements of extension field are represented as univariate polynomials in α. To create simple field extensions one should use either FiniteField for extensions of finite fields or AlgebraicNumberField for extensions of rationals. See MultipleFieldExtension for implementation of multiple extensions.
Since:
2.5
See Also:
FiniteField, AlgebraicNumberField, Rings.SimpleFieldExtension(IUnivariatePolynomial), MultipleFieldExtension, Serialized Form
  • Constructor Details

    • SimpleFieldExtension

      protected SimpleFieldExtension​(E minimalPoly)
      Constructs a simple field extension F(α) 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 Details

    • 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 extension F(α)
    • 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" polynomial p(x) of this field viewed as quotient field F[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 is norm(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: IPolynomialRing
      Number of polynomial variables
      Specified by:
      nVariables in interface IPolynomialRing<E extends IUnivariatePolynomial<E>>
    • factory

      public E factory()
      Description copied from interface: IPolynomialRing
      Factory polynomial
      Specified by:
      factory in interface IPolynomialRing<E extends IUnivariatePolynomial<E>>
    • isEuclideanRing

      public boolean isEuclideanRing()
      Description copied from interface: Ring
      Returns whether this ring is a Euclidean ring
      Specified by:
      isEuclideanRing in interface Ring<E extends IUnivariatePolynomial<E>>
      Returns:
      whether this ring is a Euclidean ring
    • cardinality

      public 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<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: Ring
      Returns characteristic of this ring
      Specified by:
      characteristic in interface Ring<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: Ring
      Add two elements
      Specified by:
      add in interface Ring<E extends IUnivariatePolynomial<E>>
      Parameters:
      a - the first element
      b - the second element
      Returns:
      a + b
    • subtract

      public E subtract​(E a, E b)
      Description copied from interface: Ring
      Subtracts b from a
      Specified by:
      subtract in interface Ring<E extends IUnivariatePolynomial<E>>
      Parameters:
      a - the first element
      b - the second element
      Returns:
      a - b
    • multiply

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

      public E negate​(E element)
      Description copied from interface: Ring
      Negates the given element
      Specified by:
      negate in interface Ring<E extends IUnivariatePolynomial<E>>
      Parameters:
      element - the ring element
      Returns:
      -val
    • addMutable

      public E addMutable​(E a, E b)
      Description copied from interface: Ring
      Adds two elements and destroys the initial content of a.
      Specified by:
      addMutable in interface Ring<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: Ring
      Subtracts b from a and destroys the initial content of a
      Specified by:
      subtractMutable in interface Ring<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: Ring
      Multiplies two elements and destroys the initial content of a
      Specified by:
      multiplyMutable in interface Ring<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: Ring
      Negates the given element and destroys the initial content of element
      Specified by:
      negateMutable in interface Ring<E extends IUnivariatePolynomial<E>>
      Parameters:
      element - the ring element (may be destroyed)
      Returns:
      -element
    • reciprocal

      public E reciprocal​(E element)
      Description copied from interface: Ring
      Gives the inverse element element ^ (-1)
      Specified by:
      reciprocal in interface Ring<E extends IUnivariatePolynomial<E>>
      Parameters:
      element - the element
      Returns:
      element ^ (-1)
    • factor

      public FactorDecomposition<E> factor​(E element)
      Description copied from interface: Ring
      Factor specified element
      Specified by:
      factor in interface Ring<E extends IUnivariatePolynomial<E>>
    • getZero

      public E getZero()
      Description copied from interface: Ring
      Returns zero element of this ring
      Specified by:
      getZero in interface Ring<E extends IUnivariatePolynomial<E>>
      Returns:
      0
    • getOne

      public E getOne()
      Description copied from interface: Ring
      Returns unit element of this ring (one)
      Specified by:
      getOne in interface Ring<E extends IUnivariatePolynomial<E>>
      Returns:
      1
    • isZero

      public boolean isZero​(E element)
      Description copied from interface: Ring
      Tests whether specified element is zero
      Specified by:
      isZero in interface Ring<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: Ring
      Tests whether specified element is one (exactly)
      Specified by:
      isOne in interface Ring<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: Ring
      Returns ring element associated with specified long
      Specified by:
      valueOf in interface Ring<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: Ring
      Returns ring element associated with specified integer
      Specified by:
      valueOfBigInteger in interface Ring<E extends IUnivariatePolynomial<E>>
      Parameters:
      val - integer
      Returns:
      ring element associated with specified integer
    • valueOf

      public E valueOf​(E 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<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: Ring
      Makes a deep copy of the specified element (for immutable instances the same reference returned).
      Specified by:
      copy in interface Ring<E extends IUnivariatePolynomial<E>>
      Parameters:
      element - the element
      Returns:
      deep copy of specified element
    • createArray

      public E[] createArray​(int length)
      Description copied from interface: Ring
      Creates generic array of ring elements of specified length
      Specified by:
      createArray in interface Ring<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: Ring
      Creates 2d array of ring elements of specified length
      Specified by:
      createArray2d in interface Ring<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: Ring
      Creates 2d array of ring elements of specified shape
      Specified by:
      createArray2d in interface Ring<E extends IUnivariatePolynomial<E>>
      Parameters:
      m - result length
      n - length of each array in the result
      Returns:
      2d array E[m][n]
    • compare

      public int compare​(E o1, E o2)
      Specified by:
      compare in interface Comparator<E extends IUnivariatePolynomial<E>>
    • randomElement

      public E randomElement​(org.apache.commons.math3.random.RandomGenerator rnd)
      Description copied from interface: Ring
      Returns a random element from this ring
      Specified by:
      randomElement in interface Ring<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: IPolynomialRing
      Creates poly representing a single specified variable
      Specified by:
      variable in interface IPolynomialRing<E extends IUnivariatePolynomial<E>>
    • parse

      public E parse​(String string)
      Description copied from interface: Ring
      Parse string into ring element
      Specified by:
      parse in interface IParser<E extends IUnivariatePolynomial<E>>
      Specified by:
      parse in interface Ring<E extends IUnivariatePolynomial<E>>
      Parameters:
      string - string
      Returns:
      ring element
      See Also:
      Coder
    • equals

      public boolean equals​(Object o)
      Specified by:
      equals in interface Comparator<E extends IUnivariatePolynomial<E>>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

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

      public String toString​(String... variables)
    • toString

      public String toString()
      Overrides:
      toString in class Object