Package edu.jas.arith

Class ModLongRing

java.lang.Object
edu.jas.arith.ModLongRing
All Implemented Interfaces:
ModularRingFactory<ModLong>, AbelianGroupFactory<ModLong>, ElemFactory<ModLong>, MonoidFactory<ModLong>, RingFactory<ModLong>, Serializable, Iterable<ModLong>

public final class ModLongRing extends Object implements ModularRingFactory<ModLong>, Iterable<ModLong>
ModLongRing factory with RingFactory interface. Effectively immutable.
See Also:
  • Field Details

    • modul

      public final long modul
      Module part of the factory data structure.
    • random

      private static final Random random
      Random number generator.
    • isField

      private int isField
      Indicator if this ring is a field.
    • MAX_LONG

      public static final BigInteger MAX_LONG
      maximal representable integer.
  • Constructor Details

    • ModLongRing

      public ModLongRing(long m)
      The constructor creates a ModLongRing object from a long integer as module part.
      Parameters:
      m - long integer.
    • ModLongRing

      public ModLongRing(long m, boolean isField)
      The constructor creates a ModLongRing object from a long integer as module part.
      Parameters:
      m - long integer.
      isField - indicator if m is prime.
    • ModLongRing

      public ModLongRing(Long m)
      The constructor creates a ModLongRing object from a Long integer as module part.
      Parameters:
      m - Long integer.
    • ModLongRing

      public ModLongRing(Long m, boolean isField)
      The constructor creates a ModLongRing object from a Long integer as module part.
      Parameters:
      m - Long integer.
      isField - indicator if m is prime.
    • ModLongRing

      public ModLongRing(BigInteger m)
      The constructor creates a ModLongRing object from a BigInteger converted to long as module part.
      Parameters:
      m - java.math.BigInteger.
    • ModLongRing

      public ModLongRing(BigInteger m, boolean isField)
      The constructor creates a ModLongRing object from a BigInteger converted to long as module part.
      Parameters:
      m - java.math.BigInteger.
      isField - indicator if m is prime.
    • ModLongRing

      public ModLongRing(String m)
      The constructor creates a ModLongRing object from a String object as module part.
      Parameters:
      m - String.
    • ModLongRing

      public ModLongRing(String m, boolean isField)
      The constructor creates a ModLongRing object from a String object as module part.
      Parameters:
      m - String.
      isField - indicator if m is prime.
  • Method Details

    • getModul

      public BigInteger getModul()
      Get the module part as BigInteger.
      Returns:
      modul.
    • getLongModul

      public long getLongModul()
      Get the module part as long.
      Returns:
      modul.
    • getIntegerModul

      public BigInteger getIntegerModul()
      Get the module part as BigInteger.
      Specified by:
      getIntegerModul in interface ModularRingFactory<ModLong>
      Returns:
      modul.
    • create

      public ModLong create(BigInteger c)
      Create ModLong element c.
      Parameters:
      c -
      Returns:
      a ModLong of c.
    • create

      public ModLong create(long c)
      Create ModLong element c.
      Parameters:
      c -
      Returns:
      a ModLong of c.
    • create

      public ModLong create(String c)
      Create ModLong element c.
      Parameters:
      c -
      Returns:
      a ModLong of c.
    • copy

      public ModLong copy(ModLong c)
      Copy ModLong element c.
      Specified by:
      copy in interface ElemFactory<ModLong>
      Parameters:
      c -
      Returns:
      a copy of c.
    • getZERO

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

      public ModLong getONE()
      Get the one element.
      Specified by:
      getONE in interface MonoidFactory<ModLong>
      Returns:
      1 as ModLong.
    • generators

      public List<ModLong> generators()
      Get a list of the generating elements.
      Specified by:
      generators in interface ElemFactory<ModLong>
      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<ModLong>
      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<ModLong>
      Returns:
      true.
    • isAssociative

      public boolean isAssociative()
      Query if this ring is associative.
      Specified by:
      isAssociative in interface MonoidFactory<ModLong>
      Returns:
      true.
    • isField

      public boolean isField()
      Query if this ring is a field.
      Specified by:
      isField in interface RingFactory<ModLong>
      Returns:
      true if module is prime, else false.
    • characteristic

      public BigInteger characteristic()
      Characteristic of this ring.
      Specified by:
      characteristic in interface RingFactory<ModLong>
      Returns:
      characteristic of this ring.
    • fromInteger

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

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

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

      public String toScript()
      Get a scripting compatible string representation.
      Specified by:
      toScript in interface ElemFactory<ModLong>
      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 ModLongRing.
      Overrides:
      hashCode in class Object
      See Also:
    • random

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

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

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

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

      public ModLong chineseRemainder(ModLong c, ModLong ci, ModLong a)
      ModLong chinese remainder algorithm. This is a factory method. Assert c.modul ≥ a.modul and c.modul * a.modul = this.modul.
      Specified by:
      chineseRemainder in interface ModularRingFactory<ModLong>
      Parameters:
      c - ModLong.
      ci - inverse of c.modul in ring of a.
      a - other ModLong.
      Returns:
      S, with S mod c.modul == c and S mod a.modul == a.
    • chineseRemainder

      public static List<ModLong> chineseRemainder(ModLong m1, ModLong m2, List<ModLong> L1, List<ModLong> L2)
      Modular digit list chinese remainder algorithm. m1 and m2 are positive beta-integers, with GCD(m1,m2)=1 and m=m1*m2 less than beta. L1 and L2 are lists of elements of Z(m1) and Z(m2) respectively. L is a list of all a in Z(m) such that a is congruent to a1 modulo m1 and a is congruent to a2 modulo m2 with a1 in L1 and a2 in L2. This is a factory method. Assert c.modul ≥ a.modul and c.modul * a.modul = this.modul.
      Parameters:
      m1 - ModLong.
      m2 - other ModLong.
      Returns:
      L list of congruences.
    • iterator

      public Iterator<ModLong> iterator()
      Get a ModLong iterator.
      Specified by:
      iterator in interface Iterable<ModLong>
      Returns:
      a iterator over all modular integers in this ring.