Package edu.jas.arith

Class ModIntRing

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.math.BigInteger MAX_INT
      maximal representable integer.
      int modul
      Module part of the factory data structure.
    • Constructor Summary

      Constructors 
      Constructor Description
      ModIntRing​(int m)
      The constructor creates a ModIntRing object from a int integer as module part.
      ModIntRing​(int m, boolean isField)
      The constructor creates a ModIntRing object from a int integer as module part.
      ModIntRing​(java.lang.Integer m)
      The constructor creates a ModIntRing object from a Int integer as module part.
      ModIntRing​(java.lang.Integer m, boolean isField)
      The constructor creates a ModIntRing object from a Int integer as module part.
      ModIntRing​(java.lang.String m)
      The constructor creates a ModIntRing object from a String object as module part.
      ModIntRing​(java.lang.String m, boolean isField)
      The constructor creates a ModIntRing object from a String object as module part.
      ModIntRing​(java.math.BigInteger m)
      The constructor creates a ModIntRing object from a BigInteger converted to int as module part.
      ModIntRing​(java.math.BigInteger m, boolean isField)
      The constructor creates a ModIntRing object from a BigInteger converted to int as module part.
    • Field Detail

      • modul

        public final int modul
        Module part of the factory data structure.
      • MAX_INT

        public static final java.math.BigInteger MAX_INT
        maximal representable integer.
    • Constructor Detail

      • ModIntRing

        public ModIntRing​(int m)
        The constructor creates a ModIntRing object from a int integer as module part.
        Parameters:
        m - int integer.
      • ModIntRing

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

        public ModIntRing​(java.lang.Integer m)
        The constructor creates a ModIntRing object from a Int integer as module part.
        Parameters:
        m - Int integer.
      • ModIntRing

        public ModIntRing​(java.lang.Integer m,
                          boolean isField)
        The constructor creates a ModIntRing object from a Int integer as module part.
        Parameters:
        m - Int integer.
        isField - indicator if m is prime.
      • ModIntRing

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

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

        public ModIntRing​(java.lang.String m)
        The constructor creates a ModIntRing object from a String object as module part.
        Parameters:
        m - String.
      • ModIntRing

        public ModIntRing​(java.lang.String m,
                          boolean isField)
        The constructor creates a ModIntRing object from a String object as module part.
        Parameters:
        m - String.
        isField - indicator if m is prime.
    • Method Detail

      • getModul

        public java.math.BigInteger getModul()
        Get the module part as BigInteger.
        Returns:
        modul.
      • getIntModul

        public int getIntModul()
        Get the module part as int.
        Returns:
        modul.
      • create

        public ModInt create​(java.math.BigInteger c)
        Create ModInt element c.
        Parameters:
        c -
        Returns:
        a ModInt of c.
      • create

        public ModInt create​(int c)
        Create ModInt element c.
        Parameters:
        c -
        Returns:
        a ModInt of c.
      • create

        public ModInt create​(java.lang.String c)
        Create ModInt element c.
        Parameters:
        c -
        Returns:
        a ModInt of c.
      • isField

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

        public ModInt fromInteger​(int a)
        Get a ModInt element from a int value.
        Parameters:
        a - int.
        Returns:
        a ModInt.
      • toString

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

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

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

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

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

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

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

        public ModInt chineseRemainder​(ModInt c,
                                       ModInt ci,
                                       ModInt a)
        ModInt 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<ModInt>
        Parameters:
        c - ModInt.
        ci - inverse of c.modul in ring of a.
        a - other ModInt.
        Returns:
        S, with S mod c.modul == c and S mod a.modul == a.
      • chineseRemainder

        public static java.util.List<ModIntchineseRemainder​(ModInt m1,
                                                              ModInt m2,
                                                              java.util.List<ModInt> L1,
                                                              java.util.List<ModInt> 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 - ModInt.
        m2 - other ModInt.
        Returns:
        L list of congruences.
      • iterator

        public java.util.Iterator<ModIntiterator()
        Get a ModInt iterator.
        Specified by:
        iterator in interface java.lang.Iterable<ModInt>
        Returns:
        a iterator over all modular integers in this ring.