Class ModIntRing
java.lang.Object
edu.jas.arith.ModIntRing
- All Implemented Interfaces:
ModularRingFactory<ModInt>, AbelianGroupFactory<ModInt>, ElemFactory<ModInt>, MonoidFactory<ModInt>, RingFactory<ModInt>, Serializable, Iterable<ModInt>
public final class ModIntRing
extends Object
implements ModularRingFactory<ModInt>, Iterable<ModInt>
ModIntRing factory with RingFactory interface. Effectively immutable.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionModIntRing(int m) The constructor creates a ModIntRing object from a int integer as module part.ModIntRing(int m, boolean isField) The constructor creates a ModIntRing object from a int integer as module part.The constructor creates a ModIntRing object from a Int integer as module part.ModIntRing(Integer m, boolean isField) The constructor creates a ModIntRing object from a Int integer as module part.ModIntRing(String m) The constructor creates a ModIntRing object from a String object as module part.ModIntRing(String m, boolean isField) The constructor creates a ModIntRing object from a String object as module part.The constructor creates a ModIntRing object from a BigInteger converted to int as module part.ModIntRing(BigInteger m, boolean isField) The constructor creates a ModIntRing object from a BigInteger converted to int as module part. -
Method Summary
Modifier and TypeMethodDescriptionCharacteristic of this ring.chineseRemainder(ModInt c, ModInt ci, ModInt a) ModInt chinese remainder algorithm.Modular digit list chinese remainder algorithm.Copy ModInt element c.create(int c) Create ModInt element c.Create ModInt element c.create(BigInteger c) Create ModInt element c.booleanComparison with any other object.fromInteger(int a) Get a ModInt element from a int value.fromInteger(long a) Get a ModInt element from a long value.Get a ModInt element from a BigInteger value.Get a list of the generating elements.Get the module part as BigInteger.intGet the module part as int.getModul()Get the module part as BigInteger.getONE()Get the one element.getZERO()Get the zero element.inthashCode()Hash code for this ModIntRing.booleanQuery if this ring is associative.booleanQuery if this ring is commutative.booleanisField()Query if this ring is a field.booleanisFinite()Is this structure finite or infinite.iterator()Get a ModInt iterator.Parse ModInt from Reader.Parse ModInt from String.random(int n) ModInt random.ModInt random.toScript()Get a scripting compatible string representation.toString()Get the String representation.Methods inherited from interface ElemFactory
valueOfMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
modul
public final int modulModule part of the factory data structure. -
random
Random number generator. -
isField
private int isFieldIndicator if this ring is a field. -
MAX_INT
maximal representable integer.
-
-
Constructor Details
-
ModIntRing
public ModIntRing(int m) The constructor creates a ModIntRing object from a int integer as module part.- Parameters:
m- int integer.
-
ModIntRing
public ModIntRing(int m, boolean isField) The constructor creates a ModIntRing object from a int integer as module part.- Parameters:
m- int integer.isField- indicator if m is prime.
-
ModIntRing
The constructor creates a ModIntRing object from a Int integer as module part.- Parameters:
m- Int integer.
-
ModIntRing
The constructor creates a ModIntRing object from a Int integer as module part.- Parameters:
m- Int integer.isField- indicator if m is prime.
-
ModIntRing
The constructor creates a ModIntRing object from a BigInteger converted to int as module part.- Parameters:
m- java.math.BigInteger.
-
ModIntRing
The constructor creates a ModIntRing object from a BigInteger converted to int as module part.- Parameters:
m- java.math.BigInteger.isField- indicator if m is prime.
-
ModIntRing
The constructor creates a ModIntRing object from a String object as module part.- Parameters:
m- String.
-
ModIntRing
The constructor creates a ModIntRing object from a String object as module part.- Parameters:
m- String.isField- indicator if m is prime.
-
-
Method Details
-
getModul
-
getIntModul
public int getIntModul()Get the module part as int.- Returns:
- modul.
-
getIntegerModul
Get the module part as BigInteger.- Specified by:
getIntegerModulin interfaceModularRingFactory<ModInt>- Returns:
- modul.
-
create
-
create
-
create
-
copy
Copy ModInt element c.- Specified by:
copyin interfaceElemFactory<ModInt>- Parameters:
c-- Returns:
- a copy of c.
-
getZERO
Get the zero element.- Specified by:
getZEROin interfaceAbelianGroupFactory<ModInt>- Returns:
- 0 as ModInt.
-
getONE
Get the one element.- Specified by:
getONEin interfaceMonoidFactory<ModInt>- Returns:
- 1 as ModInt.
-
generators
Get a list of the generating elements.- Specified by:
generatorsin interfaceElemFactory<ModInt>- Returns:
- list of generators for the algebraic structure.
- See Also:
-
isFinite
public boolean isFinite()Is this structure finite or infinite.- Specified by:
isFinitein interfaceElemFactory<ModInt>- Returns:
- true if this structure is finite, else false.
- See Also:
-
isCommutative
public boolean isCommutative()Query if this ring is commutative.- Specified by:
isCommutativein interfaceMonoidFactory<ModInt>- Returns:
- true.
-
isAssociative
public boolean isAssociative()Query if this ring is associative.- Specified by:
isAssociativein interfaceMonoidFactory<ModInt>- Returns:
- true.
-
isField
public boolean isField()Query if this ring is a field.- Specified by:
isFieldin interfaceRingFactory<ModInt>- Returns:
- true if module is prime, else false.
-
characteristic
Characteristic of this ring.- Specified by:
characteristicin interfaceRingFactory<ModInt>- Returns:
- characteristic of this ring.
-
fromInteger
Get a ModInt element from a BigInteger value.- Specified by:
fromIntegerin interfaceElemFactory<ModInt>- Parameters:
a- BigInteger.- Returns:
- a ModInt.
-
fromInteger
Get a ModInt element from a int value.- Parameters:
a- int.- Returns:
- a ModInt.
-
fromInteger
Get a ModInt element from a long value.- Specified by:
fromIntegerin interfaceElemFactory<ModInt>- Parameters:
a- lon.- Returns:
- a ModInt.
-
toString
-
toScript
Get a scripting compatible string representation.- Specified by:
toScriptin interfaceElemFactory<ModInt>- Returns:
- script compatible representation for this ElemFactory.
- See Also:
-
equals
-
hashCode
-
random
ModInt random.- Specified by:
randomin interfaceElemFactory<ModInt>- Parameters:
n- such that 0 ≤ v ≤ (2n-1).- Returns:
- a random integer mod modul.
-
random
ModInt random.- Specified by:
randomin interfaceElemFactory<ModInt>- Parameters:
n- such that 0 ≤ v ≤ (2n-1).rnd- is a source for random bits.- Returns:
- a random integer mod modul.
-
parse
Parse ModInt from String.- Specified by:
parsein interfaceElemFactory<ModInt>- Parameters:
s- String.- Returns:
- ModInt from s.
-
parse
Parse ModInt from Reader.- Specified by:
parsein interfaceElemFactory<ModInt>- Parameters:
r- Reader.- Returns:
- next ModInt from r.
-
chineseRemainder
ModInt chinese remainder algorithm. This is a factory method. Assert c.modul ≥ a.modul and c.modul * a.modul = this.modul.- Specified by:
chineseRemainderin interfaceModularRingFactory<ModInt>- Parameters:
c- ModInt.ci- inverse of c.modul in ring of a.a- other ModInt.- Returns:
- S, with S mod c.modul == c and S mod a.modul == a.
-
chineseRemainder
Modular digit list chinese remainder algorithm. m1 and m2 are positive beta-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- ModInt.m2- other ModInt.- Returns:
- L list of congruences.
-
iterator
-