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>
,Serializable
,Iterable<ModInteger>
public final class ModIntegerRing
extends Object
implements ModularRingFactory<ModInteger>, Iterable<ModInteger>
ModIntegerRing factory with RingFactory interface. Effectively immutable.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
Indicator if this ring is a field.final BigInteger
Module part of the factory data structure.private static final Random
-
Constructor Summary
ConstructorsConstructorDescriptionModIntegerRing
(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.The constructor creates a ModIntegerRing object from a String object as module part.ModIntegerRing
(String m, boolean isField) The constructor creates a ModIntegerRing object from a String object as module part.The constructor creates a ModIntegerRing object from a BigInteger object as module part.ModIntegerRing
(BigInteger m, boolean isField) The constructor creates a ModIntegerRing object from a BigInteger object as module part. -
Method Summary
Modifier and TypeMethodDescriptionCharacteristic of this ring.chineseRemainder
(ModInteger c, ModInteger ci, ModInteger a) ModInteger chinese remainder algorithm.static List
<ModInteger> chineseRemainder
(ModInteger m1, ModInteger m2, List<ModInteger> L1, List<ModInteger> L2) Modular integer list chinese remainder algorithm.copy
(ModInteger c) Copy ModInteger element c.create
(long c) Create ModInteger element c.Create ModInteger element c.create
(BigInteger c) Create ModInteger element c.boolean
Comparison with any other object.fromInteger
(long a) Get a ModInteger element from a long value.Get a ModInteger element from a BigInteger value.Get a list of the generating elements.Get the module part as BigInteger.getModul()
Get the module part.getONE()
Get the one element.getZERO()
Get the zero element.int
hashCode()
Hash code for this ModIntegerRing.boolean
Query if this ring is associative.boolean
Query if this ring is commutative.boolean
isField()
Query if this ring is a field.boolean
isFinite()
Is this structure finite or infinite.iterator()
Get a ModInteger iterator.Parse ModInteger from Reader.Parse ModInteger from String.random
(int n) ModInteger random.ModInteger random.toScript()
Get a scripting compatible string representation.toString()
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
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
modul
Module part of the factory data structure. -
random
-
isField
private int isFieldIndicator if this ring is a field.
-
-
Constructor Details
-
ModIntegerRing
The constructor creates a ModIntegerRing object from a BigInteger object as module part.- Parameters:
m
- math.BigInteger.
-
ModIntegerRing
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
The constructor creates a ModIntegerRing object from a String object as module part.- Parameters:
m
- String.
-
ModIntegerRing
The constructor creates a ModIntegerRing object from a String object as module part.- Parameters:
m
- String.isField
- indicator if m is prime.
-
-
Method Details
-
getModul
Get the module part.- Returns:
- modul.
-
getIntegerModul
Get the module part as BigInteger.- Specified by:
getIntegerModul
in interfaceModularRingFactory<ModInteger>
- Returns:
- modul.
-
create
Create ModInteger element c.- Parameters:
c
-- Returns:
- a ModInteger of c.
-
create
Create ModInteger element c.- Parameters:
c
-- Returns:
- a ModInteger of c.
-
create
Create ModInteger element c.- Parameters:
c
-- Returns:
- a ModInteger of c.
-
copy
Copy ModInteger element c.- Specified by:
copy
in interfaceElemFactory<ModInteger>
- Parameters:
c
-- Returns:
- a copy of c.
-
getZERO
Get the zero element.- Specified by:
getZERO
in interfaceAbelianGroupFactory<ModInteger>
- Returns:
- 0 as ModInteger.
-
getONE
Get the one element.- Specified by:
getONE
in interfaceMonoidFactory<ModInteger>
- Returns:
- 1 as ModInteger.
-
generators
Get a list of the generating elements.- Specified by:
generators
in interfaceElemFactory<ModInteger>
- Returns:
- list of generators for the algebraic structure.
- See Also:
-
isFinite
public boolean isFinite()Is this structure finite or infinite.- Specified by:
isFinite
in interfaceElemFactory<ModInteger>
- Returns:
- true if this structure is finite, else false.
- See Also:
-
isCommutative
public boolean isCommutative()Query if this ring is commutative.- Specified by:
isCommutative
in interfaceMonoidFactory<ModInteger>
- Returns:
- true.
-
isAssociative
public boolean isAssociative()Query if this ring is associative.- Specified by:
isAssociative
in interfaceMonoidFactory<ModInteger>
- Returns:
- true.
-
isField
public boolean isField()Query if this ring is a field.- Specified by:
isField
in interfaceRingFactory<ModInteger>
- Returns:
- true if module is prime, else false.
-
characteristic
Characteristic of this ring.- Specified by:
characteristic
in interfaceRingFactory<ModInteger>
- Returns:
- characteristic of this ring.
-
fromInteger
Get a ModInteger element from a BigInteger value.- Specified by:
fromInteger
in interfaceElemFactory<ModInteger>
- Parameters:
a
- BigInteger.- Returns:
- a ModInteger.
-
fromInteger
Get a ModInteger element from a long value.- Specified by:
fromInteger
in interfaceElemFactory<ModInteger>
- Parameters:
a
- long.- Returns:
- a ModInteger.
-
toString
Get the String representation. -
toScript
Get a scripting compatible string representation.- Specified by:
toScript
in interfaceElemFactory<ModInteger>
- Returns:
- script compatible representation for this ElemFactory.
- See Also:
-
equals
Comparison with any other object. -
hashCode
public int hashCode()Hash code for this ModIntegerRing. -
random
ModInteger random.- Specified by:
random
in interfaceElemFactory<ModInteger>
- Parameters:
n
- such that 0 ≤ v ≤ (2n-1).- Returns:
- a random integer mod modul.
-
random
ModInteger random.- Specified by:
random
in interfaceElemFactory<ModInteger>
- Parameters:
n
- such that 0 ≤ v ≤ (2n-1).rnd
- is a source for random bits.- Returns:
- a random integer mod modul.
-
parse
Parse ModInteger from String.- Specified by:
parse
in interfaceElemFactory<ModInteger>
- Parameters:
s
- String.- Returns:
- ModInteger from s.
-
parse
Parse ModInteger from Reader.- Specified by:
parse
in interfaceElemFactory<ModInteger>
- Parameters:
r
- Reader.- Returns:
- next ModInteger from r.
-
chineseRemainder
ModInteger chinese remainder algorithm. This is a factory method. Assert c.modul ≥ a.modul and c.modul * a.modul = this.modul.- Specified by:
chineseRemainder
in 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 List<ModInteger> chineseRemainder(ModInteger m1, ModInteger m2, List<ModInteger> L1, 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
Get a ModInteger iterator.- Specified by:
iterator
in interfaceIterable<ModInteger>
- Returns:
- a iterator over all modular integers in this ring.
-