edu.jas.arith
Class ModInteger

java.lang.Object
  extended by edu.jas.arith.ModInteger
All Implemented Interfaces:
AbelianGroupElem<ModInteger>, Element<ModInteger>, GcdRingElem<ModInteger>, MonoidElem<ModInteger>, RingElem<ModInteger>, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<ModInteger>

public final class ModInteger
extends java.lang.Object
implements GcdRingElem<ModInteger>

ModInteger class with RingElem interface and with the familiar SAC method names. Objects of this class are immutable.

Author:
Heinz Kredel
See Also:
BigInteger, Serialized Form

Field Summary
 ModIntegerRing ring
          ModIntegerRing reference.
protected  java.math.BigInteger val
          Value part of the element data structure.
 
Constructor Summary
ModInteger(ModIntegerRing m)
          The constructor creates a 0 ModInteger object from a BigInteger object module.
ModInteger(ModIntegerRing m, java.math.BigInteger a)
          The constructor creates a ModInteger object from two BigInteger objects module and value part.
ModInteger(ModIntegerRing m, long a)
          The constructor creates a ModInteger object from two longs objects module and value part.
ModInteger(ModIntegerRing m, java.lang.String s)
          The constructor creates a ModInteger object from two String objects module and value part.
 
Method Summary
 ModInteger abs()
          ModInteger absolute value.
 ModInteger clone()
          Clone this.
 int compareTo(ModInteger b)
          ModInteger comparison.
 ModInteger divide(ModInteger S)
          ModInteger divide.
 ModInteger[] egcd(ModInteger S)
          ModInteger extended greatest common divisor.
 boolean equals(java.lang.Object b)
          Comparison with any other object.
 ModInteger gcd(ModInteger S)
          ModInteger greatest common divisor.
 java.math.BigInteger getModul()
          Get the module part.
 java.math.BigInteger getVal()
          Get the value part.
 int hashCode()
          Hash code for this ModInteger.
 ModInteger inverse()
          ModInteger inverse.
 boolean isONE()
          Is ModInteger number one.
 boolean isUnit()
          Is ModInteger number a unit.
 boolean isZERO()
          Is ModInteger number zero.
static ModInteger MIABS(ModInteger A)
          ModInteger absolute value.
static int MICOMP(ModInteger A, ModInteger B)
          ModInteger comparison.
static ModInteger MIDIF(ModInteger A, ModInteger B)
          ModInteger subtraction.
static ModInteger MIINV(ModInteger A)
          ModInteger inverse.
static ModInteger MINEG(ModInteger A)
          ModInteger negative.
static ModInteger MIPROD(ModInteger A, ModInteger B)
          ModInteger product.
static ModInteger MIQ(ModInteger A, ModInteger B)
          ModInteger quotient.
static ModInteger MIREM(ModInteger A, ModInteger B)
          ModInteger remainder.
static int MISIGN(ModInteger A)
          ModInteger signum.
static ModInteger MISUM(ModInteger A, ModInteger B)
          ModInteger summation.
 ModInteger multiply(ModInteger S)
          ModInteger multiply.
 ModInteger negate()
          ModInteger negative.
 ModInteger remainder(ModInteger S)
          ModInteger remainder.
 int signum()
          ModInteger signum.
 ModInteger subtract(ModInteger S)
          ModInteger subtraction.
 ModInteger sum(ModInteger S)
          ModInteger summation.
 java.lang.String toString()
          Get the String representation.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ring

public final ModIntegerRing ring
ModIntegerRing reference.


val

protected 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 two BigInteger objects module and value part.

Parameters:
m - ModIntegerRing.
a - math.BigInteger.

ModInteger

public ModInteger(ModIntegerRing m,
                  long a)
The constructor creates a ModInteger object from two longs objects module and value part.

Parameters:
m - ModIntegerRing.
a - long.

ModInteger

public ModInteger(ModIntegerRing m,
                  java.lang.String s)
The constructor creates a ModInteger object from two String objects module and value part.

Parameters:
m - ModIntegerRing.
s - String.

ModInteger

public ModInteger(ModIntegerRing m)
The constructor creates a 0 ModInteger object from a BigInteger object module.

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.

clone

public ModInteger clone()
Clone this.

Specified by:
clone in interface Element<ModInteger>
Overrides:
clone in class java.lang.Object
See Also:
Object.clone()
Returns:
Creates and returns a copy of this Elemnt.

isZERO

public boolean isZERO()
Is ModInteger number zero.

Specified by:
isZERO in interface AbelianGroupElem<ModInteger>
See Also:
AbelianGroupElem.isZERO()
Returns:
If this is 0 then true is returned, else false.

isONE

public boolean isONE()
Is ModInteger number one.

Specified by:
isONE in interface MonoidElem<ModInteger>
See Also:
MonoidElem.isONE()
Returns:
If this is 1 then true is returned, else false.

isUnit

public boolean isUnit()
Is ModInteger number a unit.

Specified by:
isUnit in interface MonoidElem<ModInteger>
See Also:
MonoidElem.isUnit()
Returns:
If this is a unit then true is returned, else false.

toString

public java.lang.String toString()
Get the String representation.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

compareTo

public int compareTo(ModInteger b)
ModInteger comparison.

Specified by:
compareTo in interface Element<ModInteger>
Specified by:
compareTo in interface java.lang.Comparable<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
See Also:
Object.equals(java.lang.Object)
Returns:
true if this is equal to b, else false.

hashCode

public int hashCode()
Hash code for this ModInteger.

Specified by:
hashCode in interface Element<ModInteger>
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()
Returns:
the hashCode.

abs

public ModInteger abs()
ModInteger absolute value.

Specified by:
abs in interface AbelianGroupElem<ModInteger>
See Also:
AbelianGroupElem.abs()
Returns:
the absolute value of this.

MIABS

public static ModInteger MIABS(ModInteger A)
ModInteger absolute value.

Parameters:
A - ModInteger.
Returns:
the absolute value of A.

negate

public ModInteger negate()
ModInteger negative.

Specified by:
negate in interface AbelianGroupElem<ModInteger>
See Also:
AbelianGroupElem.negate()
Returns:
-this.

MINEG

public static ModInteger MINEG(ModInteger A)
ModInteger negative.

Parameters:
A - ModInteger.
Returns:
-A.

signum

public int signum()
ModInteger signum.

Specified by:
signum in interface AbelianGroupElem<ModInteger>
See Also:
AbelianGroupElem.signum()
Returns:
signum(this).

MISIGN

public static int MISIGN(ModInteger A)
ModInteger signum.

Parameters:
A - ModInteger
Returns:
signum(A).

subtract

public ModInteger subtract(ModInteger S)
ModInteger subtraction.

Specified by:
subtract in interface AbelianGroupElem<ModInteger>
Parameters:
S - ModInteger.
Returns:
this-S.

MIDIF

public static ModInteger MIDIF(ModInteger A,
                               ModInteger B)
ModInteger subtraction.

Parameters:
A - ModInteger.
B - ModInteger.
Returns:
A-B.

divide

public ModInteger divide(ModInteger S)
ModInteger divide.

Specified by:
divide in interface MonoidElem<ModInteger>
Parameters:
S - ModInteger.
Returns:
this/S.

MIQ

public static ModInteger MIQ(ModInteger A,
                             ModInteger B)
ModInteger quotient.

Parameters:
A - ModInteger.
B - ModInteger.
Returns:
A/B.

inverse

public ModInteger inverse()
ModInteger inverse.

Specified by:
inverse in interface MonoidElem<ModInteger>
Throws:
NotInvertibleException - if the element is not invertible.
See Also:
MonoidElem.inverse()
Returns:
S with S=1/this if defined.

MIINV

public static ModInteger MIINV(ModInteger A)
ModInteger inverse.

See Also:
MonoidElem.inverse()
Parameters:
A - is a non-zero integer.
Returns:
S with S=1/A if defined.

remainder

public ModInteger remainder(ModInteger S)
ModInteger remainder.

Specified by:
remainder in interface MonoidElem<ModInteger>
Parameters:
S - ModInteger.
Returns:
remainder(this,S).

MIREM

public static ModInteger MIREM(ModInteger A,
                               ModInteger B)
ModInteger remainder.

Parameters:
A - ModInteger.
B - ModInteger.
Returns:
A - (A/B)*B.

multiply

public ModInteger multiply(ModInteger S)
ModInteger multiply.

Specified by:
multiply in interface MonoidElem<ModInteger>
Parameters:
S - ModInteger.
Returns:
this*S.

MIPROD

public static ModInteger MIPROD(ModInteger A,
                                ModInteger B)
ModInteger product.

Parameters:
A - ModInteger.
B - ModInteger.
Returns:
A*B.

sum

public ModInteger sum(ModInteger S)
ModInteger summation.

Specified by:
sum in interface AbelianGroupElem<ModInteger>
Parameters:
S - ModInteger.
Returns:
this+S.

MISUM

public static ModInteger MISUM(ModInteger A,
                               ModInteger B)
ModInteger summation.

Parameters:
A - ModInteger.
B - ModInteger.
Returns:
A+B.

gcd

public ModInteger gcd(ModInteger S)
ModInteger greatest common divisor.

Specified by:
gcd in interface RingElem<ModInteger>
Parameters:
S - ModInteger.
Returns:
gcd(this,S).

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).