Package edu.jas.arith

Class ModInteger

    • Field Detail

      • val

        public final java.math.BigInteger val
        Value part of the element data structure.
    • Constructor Detail

      • ModInteger

        public ModInteger​(ModIntegerRing m,
                          java.math.BigInteger a)
        The constructor creates a ModInteger object from a ModIntegerRing and a value part.
        Parameters:
        m - ModIntegerRing.
        a - math.BigInteger.
      • ModInteger

        public ModInteger​(ModIntegerRing m,
                          long a)
        The constructor creates a ModInteger object from a ModIntegerRing and a long value part.
        Parameters:
        m - ModIntegerRing.
        a - long.
      • ModInteger

        public ModInteger​(ModIntegerRing m,
                          java.lang.String s)
        The constructor creates a ModInteger object from a ModIntegerRing and a String value part.
        Parameters:
        m - ModIntegerRing.
        s - String.
      • ModInteger

        public ModInteger​(ModIntegerRing m)
        The constructor creates a 0 ModInteger object from a given ModIntegerRing.
        Parameters:
        m - ModIntegerRing.
    • Method Detail

      • getVal

        public java.math.BigInteger getVal()
        Get the value part.
        Returns:
        val.
      • getModul

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

        public java.math.BigInteger getSymmetricVal()
        Get the symmetric value part.
        Returns:
        val with -modul/2 ≤ val < modul/2.
      • getInteger

        public BigInteger getInteger()
        Return a BigInteger from this Element.
        Specified by:
        getInteger in interface Modular
        Returns:
        a BigInteger of this.
      • getSymmetricInteger

        public BigInteger getSymmetricInteger()
        Return a symmetric BigInteger from this Element.
        Specified by:
        getSymmetricInteger in interface Modular
        Returns:
        a symmetric BigInteger of this.
      • copy

        public ModInteger copy()
        Clone this.
        Specified by:
        copy in interface Element<ModInteger>
        Returns:
        Creates and returns a copy of this Element.
        See Also:
        Object.clone()
      • toString

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

        public java.lang.String toScript()
        Get a scripting compatible string representation.
        Specified by:
        toScript in interface Element<ModInteger>
        Returns:
        script compatible representation for this Element.
        See Also:
        Element.toScript()
      • toScriptFactory

        public java.lang.String toScriptFactory()
        Get a scripting compatible string representation of the factory.
        Specified by:
        toScriptFactory in interface Element<ModInteger>
        Returns:
        script compatible representation for this ElemFactory.
        See Also:
        Element.toScriptFactory()
      • compareTo

        public int compareTo​(ModInteger b)
        ModInteger comparison.
        Specified by:
        compareTo in interface java.lang.Comparable<ModInteger>
        Specified by:
        compareTo in interface Element<ModInteger>
        Parameters:
        b - ModInteger.
        Returns:
        sign(this-b).
      • MICOMP

        public static int MICOMP​(ModInteger A,
                                 ModInteger B)
        ModInteger comparison.
        Parameters:
        A - ModInteger.
        B - ModInteger.
        Returns:
        sign(this-b).
      • equals

        public boolean equals​(java.lang.Object b)
        Comparison with any other object.
        Specified by:
        equals in interface Element<ModInteger>
        Overrides:
        equals in class java.lang.Object
        Returns:
        true if this is equal to b, else false.
        See Also:
        Object.equals(java.lang.Object)
      • hashCode

        public int hashCode()
        Hash code for this ModInteger.
        Specified by:
        hashCode in interface Element<ModInteger>
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashCode.
        See Also:
        Object.hashCode()
      • MIABS

        public static ModInteger MIABS​(ModInteger A)
        ModInteger absolute value.
        Parameters:
        A - ModInteger.
        Returns:
        the absolute value of A.
      • MINEG

        public static ModInteger MINEG​(ModInteger A)
        ModInteger negative.
        Parameters:
        A - ModInteger.
        Returns:
        -A.
      • MISIGN

        public static int MISIGN​(ModInteger A)
        ModInteger signum.
        Parameters:
        A - ModInteger
        Returns:
        signum(A).
      • MIDIF

        public static ModInteger MIDIF​(ModInteger A,
                                       ModInteger B)
        ModInteger subtraction.
        Parameters:
        A - ModInteger.
        B - ModInteger.
        Returns:
        A-B.
      • MIREM

        public static ModInteger MIREM​(ModInteger A,
                                       ModInteger B)
        ModInteger remainder.
        Parameters:
        A - ModInteger.
        B - ModInteger.
        Returns:
        A - (A/B)*B.
      • MIPROD

        public static ModInteger MIPROD​(ModInteger A,
                                        ModInteger B)
        ModInteger product.
        Parameters:
        A - ModInteger.
        B - ModInteger.
        Returns:
        A*B.
      • MISUM

        public static ModInteger MISUM​(ModInteger A,
                                       ModInteger B)
        ModInteger summation.
        Parameters:
        A - ModInteger.
        B - ModInteger.
        Returns:
        A+B.
      • hegcd

        public ModInteger[] hegcd​(ModInteger S)
        ModInteger half extended greatest common divisor.
        Parameters:
        S - ModInteger.
        Returns:
        [ gcd(this,S), a ] with a*this + b*S = gcd(this,S) for some b.
      • egcd

        public ModInteger[] egcd​(ModInteger S)
        ModInteger extended greatest common divisor.
        Specified by:
        egcd in interface RingElem<ModInteger>
        Parameters:
        S - ModInteger.
        Returns:
        [ gcd(this,S), a, b ] with a*this + b*S = gcd(this,S).
      • bitLength

        public long bitLength()
        Returns the number of bits in the representation of this ModInteger, including a sign bit. For positive ModIntegers, this is equivalent to val.bitLength().)
        Returns:
        number of bits in the representation of this ModInteger, including a sign bit.