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