Package edu.jas.arith
Class ModIntegerRing
- java.lang.Object
-
- edu.jas.arith.ModIntegerRing
-
- All Implemented Interfaces:
ModularRingFactory<ModInteger>,AbelianGroupFactory<ModInteger>,ElemFactory<ModInteger>,MonoidFactory<ModInteger>,RingFactory<ModInteger>,java.io.Serializable,java.lang.Iterable<ModInteger>
public final class ModIntegerRing extends java.lang.Object implements ModularRingFactory<ModInteger>, java.lang.Iterable<ModInteger>
ModIntegerRing factory with RingFactory interface. Effectively immutable.- Author:
- Heinz Kredel
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description java.math.BigIntegermodulModule part of the factory data structure.
-
Constructor Summary
Constructors Constructor Description ModIntegerRing(long m)The constructor creates a ModIntegerRing object from a long as module part.ModIntegerRing(long m, boolean isField)The constructor creates a ModIntegerRing object from a long as module part.ModIntegerRing(java.lang.String m)The constructor creates a ModIntegerRing object from a String object as module part.ModIntegerRing(java.lang.String m, boolean isField)The constructor creates a ModIntegerRing object from a String object as module part.ModIntegerRing(java.math.BigInteger m)The constructor creates a ModIntegerRing object from a BigInteger object as module part.ModIntegerRing(java.math.BigInteger m, boolean isField)The constructor creates a ModIntegerRing object from a BigInteger object as module part.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigIntegercharacteristic()Characteristic of this ring.ModIntegerchineseRemainder(ModInteger c, ModInteger ci, ModInteger a)ModInteger chinese remainder algorithm.static java.util.List<ModInteger>chineseRemainder(ModInteger m1, ModInteger m2, java.util.List<ModInteger> L1, java.util.List<ModInteger> L2)Modular integer list chinese remainder algorithm. m1 and m2 are positive integers, with GCD(m1,m2)=1 and m=m1*m2 less than beta.ModIntegercopy(ModInteger c)Copy ModInteger element c.ModIntegercreate(long c)Create ModInteger element c.ModIntegercreate(java.lang.String c)Create ModInteger element c.ModIntegercreate(java.math.BigInteger c)Create ModInteger element c.booleanequals(java.lang.Object b)Comparison with any other object.ModIntegerfromInteger(long a)Get a ModInteger element from a long value.ModIntegerfromInteger(java.math.BigInteger a)Get a ModInteger element from a BigInteger value.java.util.List<ModInteger>generators()Get a list of the generating elements.BigIntegergetIntegerModul()Get the module part as BigInteger.java.math.BigIntegergetModul()Get the module part.ModIntegergetONE()Get the one element.ModIntegergetZERO()Get the zero element.inthashCode()Hash code for this ModIntegerRing.booleanisAssociative()Query if this ring is associative.booleanisCommutative()Query if this ring is commutative.booleanisField()Query if this ring is a field.booleanisFinite()Is this structure finite or infinite.java.util.Iterator<ModInteger>iterator()Get a ModInteger iterator.ModIntegerparse(java.io.Reader r)Parse ModInteger from Reader.ModIntegerparse(java.lang.String s)Parse ModInteger from String.ModIntegerrandom(int n)ModInteger random.ModIntegerrandom(int n, java.util.Random rnd)ModInteger random.java.lang.StringtoScript()Get a scripting compatible string representation.java.lang.StringtoString()Get the String representation.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface edu.jas.structure.ElemFactory
valueOf
-
-
-
-
Field Detail
-
modul
public final java.math.BigInteger modul
Module part of the factory data structure.
-
-
Constructor Detail
-
ModIntegerRing
public ModIntegerRing(java.math.BigInteger m)
The constructor creates a ModIntegerRing object from a BigInteger object as module part.- Parameters:
m- math.BigInteger.
-
ModIntegerRing
public ModIntegerRing(java.math.BigInteger m, boolean isField)
The constructor creates a ModIntegerRing object from a BigInteger object as module part.- Parameters:
m- math.BigInteger.isField- indicator if m is prime.
-
ModIntegerRing
public ModIntegerRing(long m)
The constructor creates a ModIntegerRing object from a long as module part.- Parameters:
m- long.
-
ModIntegerRing
public ModIntegerRing(long m, boolean isField)
The constructor creates a ModIntegerRing object from a long as module part.- Parameters:
m- long.isField- indicator if m is prime.
-
ModIntegerRing
public ModIntegerRing(java.lang.String m)
The constructor creates a ModIntegerRing object from a String object as module part.- Parameters:
m- String.
-
ModIntegerRing
public ModIntegerRing(java.lang.String m, boolean isField)
The constructor creates a ModIntegerRing 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.- Returns:
- modul.
-
getIntegerModul
public BigInteger getIntegerModul()
Get the module part as BigInteger.- Specified by:
getIntegerModulin interfaceModularRingFactory<ModInteger>- Returns:
- modul.
-
create
public ModInteger create(java.math.BigInteger c)
Create ModInteger element c.- Parameters:
c-- Returns:
- a ModInteger of c.
-
create
public ModInteger create(long c)
Create ModInteger element c.- Parameters:
c-- Returns:
- a ModInteger of c.
-
create
public ModInteger create(java.lang.String c)
Create ModInteger element c.- Parameters:
c-- Returns:
- a ModInteger of c.
-
copy
public ModInteger copy(ModInteger c)
Copy ModInteger element c.- Specified by:
copyin interfaceElemFactory<ModInteger>- Parameters:
c-- Returns:
- a copy of c.
-
getZERO
public ModInteger getZERO()
Get the zero element.- Specified by:
getZEROin interfaceAbelianGroupFactory<ModInteger>- Returns:
- 0 as ModInteger.
-
getONE
public ModInteger getONE()
Get the one element.- Specified by:
getONEin interfaceMonoidFactory<ModInteger>- Returns:
- 1 as ModInteger.
-
generators
public java.util.List<ModInteger> generators()
Get a list of the generating elements.- Specified by:
generatorsin interfaceElemFactory<ModInteger>- Returns:
- list of generators for the algebraic structure.
- See Also:
ElemFactory.generators()
-
isFinite
public boolean isFinite()
Is this structure finite or infinite.- Specified by:
isFinitein interfaceElemFactory<ModInteger>- 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:
isCommutativein interfaceMonoidFactory<ModInteger>- Returns:
- true.
-
isAssociative
public boolean isAssociative()
Query if this ring is associative.- Specified by:
isAssociativein interfaceMonoidFactory<ModInteger>- Returns:
- true.
-
isField
public boolean isField()
Query if this ring is a field.- Specified by:
isFieldin interfaceRingFactory<ModInteger>- Returns:
- true if module is prime, else false.
-
characteristic
public java.math.BigInteger characteristic()
Characteristic of this ring.- Specified by:
characteristicin interfaceRingFactory<ModInteger>- Returns:
- characteristic of this ring.
-
fromInteger
public ModInteger fromInteger(java.math.BigInteger a)
Get a ModInteger element from a BigInteger value.- Specified by:
fromIntegerin interfaceElemFactory<ModInteger>- Parameters:
a- BigInteger.- Returns:
- a ModInteger.
-
fromInteger
public ModInteger fromInteger(long a)
Get a ModInteger element from a long value.- Specified by:
fromIntegerin interfaceElemFactory<ModInteger>- Parameters:
a- long.- Returns:
- a ModInteger.
-
toString
public java.lang.String toString()
Get the String representation.- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
toScript
public java.lang.String toScript()
Get a scripting compatible string representation.- Specified by:
toScriptin interfaceElemFactory<ModInteger>- 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:
equalsin classjava.lang.Object- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
Hash code for this ModIntegerRing.- Overrides:
hashCodein classjava.lang.Object- See Also:
Object.hashCode()
-
random
public ModInteger random(int n)
ModInteger random.- Specified by:
randomin interfaceElemFactory<ModInteger>- Parameters:
n- such that 0 ≤ v ≤ (2n-1).- Returns:
- a random integer mod modul.
-
random
public ModInteger random(int n, java.util.Random rnd)
ModInteger random.- Specified by:
randomin interfaceElemFactory<ModInteger>- Parameters:
n- such that 0 ≤ v ≤ (2n-1).rnd- is a source for random bits.- Returns:
- a random integer mod modul.
-
parse
public ModInteger parse(java.lang.String s)
Parse ModInteger from String.- Specified by:
parsein interfaceElemFactory<ModInteger>- Parameters:
s- String.- Returns:
- ModInteger from s.
-
parse
public ModInteger parse(java.io.Reader r)
Parse ModInteger from Reader.- Specified by:
parsein interfaceElemFactory<ModInteger>- Parameters:
r- Reader.- Returns:
- next ModInteger from r.
-
chineseRemainder
public ModInteger chineseRemainder(ModInteger c, ModInteger ci, ModInteger a)
ModInteger chinese remainder algorithm. This is a factory method. Assert c.modul ≥ a.modul and c.modul * a.modul = this.modul.- Specified by:
chineseRemainderin interfaceModularRingFactory<ModInteger>- Parameters:
c- ModInteger.ci- inverse of c.modul in ring of a.a- other ModInteger.- Returns:
- S, with S mod c.modul == c and S mod a.modul == a.
-
chineseRemainder
public static java.util.List<ModInteger> chineseRemainder(ModInteger m1, ModInteger m2, java.util.List<ModInteger> L1, java.util.List<ModInteger> L2)
Modular integer list chinese remainder algorithm. m1 and m2 are positive 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- modular integer.m2- other modular integer.- Returns:
- L list of congruences.
-
iterator
public java.util.Iterator<ModInteger> iterator()
Get a ModInteger iterator.- Specified by:
iteratorin interfacejava.lang.Iterable<ModInteger>- Returns:
- a iterator over all modular integers in this ring.
-
-