com.perisic.ring
Class ModularIntegerRing

java.lang.Object
  extended by com.perisic.ring.Ring
      extended by com.perisic.ring.ModularIntegerRing
Direct Known Subclasses:
FinitePrimeField

public class ModularIntegerRing
extends Ring

The modular integer ring Z/nZ. This ring uses the BigInteger arithmetic of the java.math.* package and is therefore more efficient then a construction via the ModularRing class of this package

Version:
0.3
Author:
Marc Conrad

Field Summary
 
Fields inherited from class com.perisic.ring.Ring
C, F2, Q, R, Z
 
Constructor Summary
ModularIntegerRing(int m)
           
ModularIntegerRing(java.lang.Object modulus)
          Construction of Z/mZ with m = modulus.
 
Method Summary
 RingElt add(RingElt a, RingElt b)
          Returns a + b mod m.
 boolean equals(java.lang.Object ob)
          Two ModularIntegerRing objects are equal, if the modulus is the same.
 boolean equalZero(RingElt b)
          True if b == 0, false otherwise.
 java.math.BigInteger getModulus()
          Returns m where this ModularIntegerRing is Z/mZ.
 RingElt inv(RingElt b)
          Returns b^-1 mod m.
 RingElt map(RingElt a)
          Performs the ususal map as in Ring.map(RingElt).
 RingElt mult(RingElt a, RingElt b)
          Returns a * b mod m.
 RingElt neg(RingElt b)
          Returns -b mod m.
 RingElt one()
          Returns 1.
 RingElt tdiv(RingElt a, RingElt b)
          The same as div(a,b).
static java.math.BigInteger toBigInteger(RingElt b)
          Returns the BigInteger value of b.
 RingElt zero()
          Returns 0.
 
Methods inherited from class com.perisic.ring.Ring
div, ediv, eltToString, equal, evaluatePolynomial, gcd, isEuclidian, isField, isUFD, map, map, map, map, mod, pow, pow, sub
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModularIntegerRing

public ModularIntegerRing(java.lang.Object modulus)
Construction of Z/mZ with m = modulus.

Parameters:
modulus - An instance of a BigInteger or a RingElt which can be mapped to Ring.Z.

ModularIntegerRing

public ModularIntegerRing(int m)
Method Detail

getModulus

public java.math.BigInteger getModulus()
Returns m where this ModularIntegerRing is Z/mZ.


toBigInteger

public static java.math.BigInteger toBigInteger(RingElt b)
Returns the BigInteger value of b. A value between 0 and m


add

public RingElt add(RingElt a,
                   RingElt b)
Returns a + b mod m.

Specified by:
add in class Ring

mult

public RingElt mult(RingElt a,
                    RingElt b)
Returns a * b mod m.

Specified by:
mult in class Ring

one

public RingElt one()
Returns 1.

Overrides:
one in class Ring

zero

public RingElt zero()
Returns 0.

Specified by:
zero in class Ring

inv

public RingElt inv(RingElt b)
Returns b^-1 mod m. b must be an unit in Z/mZ.

Overrides:
inv in class Ring
Throws:
java.lang.ArithmeticException - if b is not an unit mod m.

tdiv

public RingElt tdiv(RingElt a,
                    RingElt b)
The same as div(a,b). b must be a unit of Z/mZ.

Overrides:
tdiv in class Ring
Throws:
java.lang.ArithmeticException - if b is not a unit mod m.

neg

public RingElt neg(RingElt b)
Returns -b mod m.

Specified by:
neg in class Ring

equalZero

public boolean equalZero(RingElt b)
True if b == 0, false otherwise.

Specified by:
equalZero in class Ring

equals

public boolean equals(java.lang.Object ob)
Two ModularIntegerRing objects are equal, if the modulus is the same.

Overrides:
equals in class java.lang.Object

map

public RingElt map(RingElt a)
Performs the ususal map as in Ring.map(RingElt). In addition an element of another ModularIntegerRing M with M.modulus == this.modulus is mapped to this. (Not yet implemented: Mapping in case that this.modulus is a divisor of M.modulus. Also to do (if this makes sense): Mapping from F2Field if modulus == 2).

Overrides:
map in class Ring