Package edu.jas.poly

Class AlgebraicNumberRing<C extends RingElem<C>>

java.lang.Object
edu.jas.poly.AlgebraicNumberRing<C>
All Implemented Interfaces:
AbelianGroupFactory<AlgebraicNumber<C>>, ElemFactory<AlgebraicNumber<C>>, MonoidFactory<AlgebraicNumber<C>>, RingFactory<AlgebraicNumber<C>>, Serializable, Iterable<AlgebraicNumber<C>>

public class AlgebraicNumberRing<C extends RingElem<C>> extends Object implements RingFactory<AlgebraicNumber<C>>, Iterable<AlgebraicNumber<C>>
Algebraic number factory. Based on GenPolynomial factory with RingElem interface. Objects of this class are immutable.
See Also:
  • Field Details

    • ring

      public final GenPolynomialRing<C extends RingElem<C>> ring
      Ring part of the factory data structure.
    • modul

      public final GenPolynomial<C extends RingElem<C>> modul
      Module part of the factory data structure.
    • isField

      protected int isField
      Indicator if this ring is a field
    • logger

      private static final org.apache.logging.log4j.Logger logger
  • Constructor Details

    • AlgebraicNumberRing

      public AlgebraicNumberRing(GenPolynomial<C> m)
      The constructor creates a AlgebraicNumber factory object from a GenPolynomial objects module.
      Parameters:
      m - module GenPolynomial.
    • AlgebraicNumberRing

      public AlgebraicNumberRing(GenPolynomial<C> m, boolean isField)
      The constructor creates a AlgebraicNumber factory object from a GenPolynomial objects module.
      Parameters:
      m - module GenPolynomial.
      isField - indicator if m is prime.
  • Method Details

    • getModul

      public GenPolynomial<C> getModul()
      Get the module part.
      Returns:
      modul.
    • copy

      public AlgebraicNumber<C> copy(AlgebraicNumber<C> c)
      Copy AlgebraicNumber element c.
      Specified by:
      copy in interface ElemFactory<C extends RingElem<C>>
      Parameters:
      c - algebraic number to copy.
      Returns:
      a copy of c.
    • getZERO

      public AlgebraicNumber<C> getZERO()
      Get the zero element.
      Specified by:
      getZERO in interface AbelianGroupFactory<C extends RingElem<C>>
      Returns:
      0 as AlgebraicNumber.
    • getONE

      public AlgebraicNumber<C> getONE()
      Get the one element.
      Specified by:
      getONE in interface MonoidFactory<C extends RingElem<C>>
      Returns:
      1 as AlgebraicNumber.
    • getGenerator

      public AlgebraicNumber<C> getGenerator()
      Get the generating element.
      Returns:
      alpha as AlgebraicNumber.
    • generators

      public List<AlgebraicNumber<C>> generators()
      Get a list of the generating elements.
      Specified by:
      generators in interface ElemFactory<C extends RingElem<C>>
      Returns:
      list of generators for the algebraic structure.
      See Also:
    • isFinite

      public boolean isFinite()
      Is this structure finite or infinite.
      Specified by:
      isFinite in interface ElemFactory<C extends RingElem<C>>
      Returns:
      true if this structure is finite, else false.
      See Also:
    • isCommutative

      public boolean isCommutative()
      Query if this ring is commutative.
      Specified by:
      isCommutative in interface MonoidFactory<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 interface MonoidFactory<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 interface RingFactory<C extends RingElem<C>>
      Returns:
      true if modul is prime, else false.
    • setField

      public void setField(boolean field)
      Set field property of this ring.
      Parameters:
      field - true, if this ring is determined to be a field, false, if it is determined that it is not a field.
    • getField

      public int getField()
      Get the internal field indicator.
      Returns:
      internal field indicator.
    • characteristic

      public BigInteger characteristic()
      Characteristic of this ring.
      Specified by:
      characteristic in interface RingFactory<C extends RingElem<C>>
      Returns:
      characteristic of this ring.
    • fillFromInteger

      public AlgebraicNumber<C> fillFromInteger(BigInteger a)
      Get an AlgebraicNumber element from a BigInteger value. If a = a_k p^k + ... + a_0 p^0 then b = a_k x^k + ... + a_0 x^0, where p = characteristic( this ).
      Parameters:
      a - BigInteger.
      Returns:
      b an AlgebraicNumber.
    • fillFromInteger

      public AlgebraicNumber<C> fillFromInteger(long a)
      Get a AlgebraicNumber element from a long value.
      Parameters:
      a - long.
      Returns:
      a AlgebraicNumber.
    • fromInteger

      public AlgebraicNumber<C> fromInteger(BigInteger a)
      Get a AlgebraicNumber element from a BigInteger value.
      Specified by:
      fromInteger in interface ElemFactory<C extends RingElem<C>>
      Parameters:
      a - BigInteger.
      Returns:
      a AlgebraicNumber.
    • fromInteger

      public AlgebraicNumber<C> fromInteger(long a)
      Get a AlgebraicNumber element from a long value.
      Specified by:
      fromInteger in interface ElemFactory<C extends RingElem<C>>
      Parameters:
      a - long.
      Returns:
      a AlgebraicNumber.
    • toString

      public String toString()
      Get the String representation as RingFactory.
      Overrides:
      toString in class Object
      See Also:
    • toScript

      public String toScript()
      Get a scripting compatible string representation.
      Specified by:
      toScript in interface ElemFactory<C extends RingElem<C>>
      Returns:
      script compatible representation for this ElemFactory.
      See Also:
    • equals

      public boolean equals(Object b)
      Comparison with any other object.
      Overrides:
      equals in class Object
      See Also:
    • hashCode

      public int hashCode()
      Hash code for this AlgebraicNumber.
      Overrides:
      hashCode in class Object
      See Also:
    • random

      public AlgebraicNumber<C> random(int n)
      AlgebraicNumber random.
      Specified by:
      random in interface ElemFactory<C extends RingElem<C>>
      Parameters:
      n - such that 0 ≤ v ≤ (2n-1).
      Returns:
      a random integer mod modul.
    • random

      public AlgebraicNumber<C> random(int n, Random rnd)
      AlgebraicNumber random.
      Specified by:
      random in interface ElemFactory<C extends RingElem<C>>
      Parameters:
      n - such that 0 ≤ v ≤ (2n-1).
      rnd - is a source for random bits.
      Returns:
      a random integer mod modul.
    • parse

      public AlgebraicNumber<C> parse(String s)
      Parse AlgebraicNumber from String.
      Specified by:
      parse in interface ElemFactory<C extends RingElem<C>>
      Parameters:
      s - String.
      Returns:
      AlgebraicNumber from s.
    • parse

      public AlgebraicNumber<C> parse(Reader r)
      Parse AlgebraicNumber from Reader.
      Specified by:
      parse in interface ElemFactory<C extends RingElem<C>>
      Parameters:
      r - Reader.
      Returns:
      next AlgebraicNumber from r.
    • chineseRemainder

      public AlgebraicNumber<C> chineseRemainder(AlgebraicNumber<C> c, AlgebraicNumber<C> ci, AlgebraicNumber<C> a)
      AlgebraicNumber chinese remainder algorithm. Assert deg(c.modul) ≥ deg(a.modul) and c.modul * a.modul = this.modul.
      Parameters:
      c - AlgebraicNumber.
      ci - inverse of c.modul in ring of a.
      a - other AlgebraicNumber.
      Returns:
      S, with S mod c.modul == c and S mod a.modul == a.
    • interpolate

      public AlgebraicNumber<C> interpolate(AlgebraicNumber<C> c, C ci, C am, C a)
      AlgebraicNumber interpolation algorithm. Assert deg(c.modul) ≥ deg(A.modul) and c.modul * A.modul = this.modul. Special case with deg(A.modul) == 1. Similar algorithm as chinese remainder algorithm.
      Parameters:
      c - AlgebraicNumber.
      ci - inverse of (c.modul)(a) in ring of A.
      am - trailing base coefficient of modul of other AlgebraicNumber A.
      a - value of other AlgebraicNumber A.
      Returns:
      S, with S(c) == c and S(A) == a.
    • depth

      public int depth()
      Depth of extension field tower.
      Returns:
      number of nested algebraic extension fields
    • extensionDegree

      public long extensionDegree()
      Degree of extension field.
      Returns:
      degree of this algebraic extension field
    • totalExtensionDegree

      public long totalExtensionDegree()
      Total degree of nested extension fields.
      Returns:
      degree of tower of algebraic extension fields
    • iterator

      public Iterator<AlgebraicNumber<C>> iterator()
      Get a AlgebraicNumber iterator. Note: Only for finite field coefficients or fields which are iterable.
      Specified by:
      iterator in interface Iterable<C extends RingElem<C>>
      Returns:
      a iterator over all algebraic numbers in this ring.