edu.jas.arith
Class ModLongRing

java.lang.Object
  extended by edu.jas.arith.ModLongRing
All Implemented Interfaces:
ModularRingFactory<ModLong>, AbelianGroupFactory<ModLong>, ElemFactory<ModLong>, MonoidFactory<ModLong>, RingFactory<ModLong>, java.io.Serializable, java.lang.Iterable<ModLong>

public final class ModLongRing
extends java.lang.Object
implements ModularRingFactory<ModLong>, java.lang.Iterable<ModLong>

ModLongRing factory with RingFactory interface. Effectively immutable.

Author:
Heinz Kredel
See Also:
Serialized Form

Field Summary
protected  int certainty
          Certainty if module is probable prime.
protected  int isField
          Indicator if this ring is a field.
static java.math.BigInteger MAX_LONG
          maximal representable integer.
 long modul
          Module part of the factory data structure.
 
Constructor Summary
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.
ModLongRing(long m)
          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(long m, boolean isField)
          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.
 
Method Summary
 java.math.BigInteger characteristic()
          Characteristic of this ring.
 ModLong chineseRemainder(ModLong c, ModLong ci, ModLong a)
          ModLong chinese remainder algorithm.
 ModLong copy(ModLong c)
          Copy ModLong element c.
 ModLong create(java.math.BigInteger c)
          Create ModLong element c.
 ModLong create(long c)
          Create ModLong element c.
 ModLong create(java.lang.String c)
          Create ModLong element c.
 boolean equals(java.lang.Object b)
          Comparison with any other object.
 ModLong fromInteger(java.math.BigInteger a)
          Get a ModLong element from a BigInteger value.
 ModLong fromInteger(long a)
          Get a ModLong element from a long value.
 java.util.List<ModLong> generators()
          Get a list of the generating elements.
 BigInteger getIntegerModul()
          Get the module part as BigInteger.
 long getLongModul()
          Get the module part as long.
 java.math.BigInteger getModul()
          Get the module part as BigInteger.
 ModLong getONE()
          Get the one element.
 ModLong getZERO()
          Get the zero element.
 int hashCode()
          Hash code for this ModLongRing.
 boolean isAssociative()
          Query if this ring is associative.
 boolean isCommutative()
          Query if this ring is commutative.
 boolean isField()
          Query if this ring is a field.
 boolean isFinite()
          Is this structure finite or infinite.
 java.util.Iterator<ModLong> iterator()
          Get a ModLong iterator.
 ModLong parse(java.io.Reader r)
          Parse ModLong from Reader.
 ModLong parse(java.lang.String s)
          Parse ModLong from String.
 ModLong random(int n)
          ModLong random.
 ModLong random(int n, java.util.Random rnd)
          ModLong random.
 java.lang.String toScript()
          Get a scripting compatible string representation.
 java.lang.String toString()
          Get the String representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

modul

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


isField

protected int isField
Indicator if this ring is a field.


certainty

protected int certainty
Certainty if module is probable prime.


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.

getIntegerModul

public BigInteger getIntegerModul()
Get the module part as BigInteger.

Specified by:
getIntegerModul in interface ModularRingFactory<ModLong>
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.

copy

public ModLong copy(ModLong c)
Copy ModLong element c.

Specified by:
copy in interface ElemFactory<ModLong>
Parameters:
c -
Returns:
a copy of c.

getZERO

public ModLong getZERO()
Get the zero element.

Specified by:
getZERO in interface AbelianGroupFactory<ModLong>
Returns:
0 as ModLong.

getONE

public ModLong getONE()
Get the one element.

Specified by:
getONE in interface MonoidFactory<ModLong>
Returns:
1 as ModLong.

generators

public java.util.List<ModLong> generators()
Get a list of the generating elements.

Specified by:
generators in interface ElemFactory<ModLong>
Returns:
list of generators for the algebraic structure.
See Also:
ElemFactory.generators()

isFinite

public boolean isFinite()
Is this structure finite or infinite.

Specified by:
isFinite in interface ElemFactory<ModLong>
Returns:
true if this structure is finite, else false.
See Also:
ElemFactory.isFinite()

isCommutative

public boolean isCommutative()
Query if this ring is commutative.

Specified by:
isCommutative in interface MonoidFactory<ModLong>
Returns:
true.

isAssociative

public boolean isAssociative()
Query if this ring is associative.

Specified by:
isAssociative in interface MonoidFactory<ModLong>
Returns:
true.

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.

characteristic

public java.math.BigInteger characteristic()
Characteristic of this ring.

Specified by:
characteristic in interface RingFactory<ModLong>
Returns:
characteristic of this ring.

fromInteger

public ModLong fromInteger(java.math.BigInteger a)
Get a ModLong element from a BigInteger value.

Specified by:
fromInteger in interface ElemFactory<ModLong>
Parameters:
a - BigInteger.
Returns:
a ModLong.

fromInteger

public ModLong fromInteger(long a)
Get a ModLong element from a long value.

Specified by:
fromInteger in interface ElemFactory<ModLong>
Parameters:
a - long.
Returns:
a ModLong.

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 ElemFactory<ModLong>
Returns:
script compatible representation for this ElemFactory.
See Also:
ElemFactory.toScript()

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.

iterator

public java.util.Iterator<ModLong> iterator()
Get a ModLong iterator.

Specified by:
iterator in interface java.lang.Iterable<ModLong>
Returns:
a iterator over all modular integers in this ring.