Package edu.jas.arith

Class ModLongRing

    • Field Summary

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

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

      • modul

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

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

      • 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​(java.lang.Long m)
        The constructor creates a ModLongRing object from a Long integer as module part.
        Parameters:
        m - Long integer.
      • ModLongRing

        public ModLongRing​(java.lang.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​(java.math.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​(java.math.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​(java.lang.String m)
        The constructor creates a ModLongRing object from a String object as module part.
        Parameters:
        m - String.
      • ModLongRing

        public ModLongRing​(java.lang.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 Detail

      • getModul

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

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

        public ModLong create​(java.math.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​(java.lang.String c)
        Create ModLong element c.
        Parameters:
        c -
        Returns:
        a ModLong of c.
      • 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.
      • 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 ModLongRing.
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        Object.hashCode()
      • 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,
                              java.util.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​(java.lang.String s)
        Parse ModLong from String.
        Specified by:
        parse in interface ElemFactory<ModLong>
        Parameters:
        s - String.
        Returns:
        ModLong from s.
      • parse

        public ModLong parse​(java.io.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 java.util.List<ModLongchineseRemainder​(ModLong m1,
                                                               ModLong m2,
                                                               java.util.List<ModLong> L1,
                                                               java.util.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 java.util.Iterator<ModLongiterator()
        Get a ModLong iterator.
        Specified by:
        iterator in interface java.lang.Iterable<ModLong>
        Returns:
        a iterator over all modular integers in this ring.