Package edu.jas.arith
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.boolean
Comparison 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.long
Get the module part as long.getModul()
Get the module part as BigInteger.getONE()
Get the one element.getZERO()
Get the zero element.int
hashCode()
Hash code for this ModLongRing.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 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 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
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
Get the module part as BigInteger.- Returns:
- modul.
-
getLongModul
public long getLongModul()Get the module part as long.- Returns:
- modul.
-
getIntegerModul
Get the module part as BigInteger.- Specified by:
getIntegerModul
in interfaceModularRingFactory<ModLong>
- Returns:
- modul.
-
create
Create ModLong element c.- Parameters:
c
-- Returns:
- a ModLong of c.
-
create
Create ModLong element c.- Parameters:
c
-- Returns:
- a ModLong of c.
-
create
Create ModLong element c.- Parameters:
c
-- Returns:
- a ModLong of c.
-
copy
Copy ModLong element c.- Specified by:
copy
in interfaceElemFactory<ModLong>
- Parameters:
c
-- Returns:
- a copy of c.
-
getZERO
Get the zero element.- Specified by:
getZERO
in interfaceAbelianGroupFactory<ModLong>
- Returns:
- 0 as ModLong.
-
getONE
Get the one element.- Specified by:
getONE
in interfaceMonoidFactory<ModLong>
- Returns:
- 1 as ModLong.
-
generators
Get a list of the generating elements.- Specified by:
generators
in interfaceElemFactory<ModLong>
- 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<ModLong>
- 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<ModLong>
- Returns:
- true.
-
isAssociative
public boolean isAssociative()Query if this ring is associative.- Specified by:
isAssociative
in interfaceMonoidFactory<ModLong>
- Returns:
- true.
-
isField
public boolean isField()Query if this ring is a field.- Specified by:
isField
in interfaceRingFactory<ModLong>
- Returns:
- true if module is prime, else false.
-
characteristic
Characteristic of this ring.- Specified by:
characteristic
in interfaceRingFactory<ModLong>
- Returns:
- characteristic of this ring.
-
fromInteger
Get a ModLong element from a BigInteger value.- Specified by:
fromInteger
in interfaceElemFactory<ModLong>
- Parameters:
a
- BigInteger.- Returns:
- a ModLong.
-
fromInteger
Get a ModLong element from a long value.- Specified by:
fromInteger
in interfaceElemFactory<ModLong>
- Parameters:
a
- long.- Returns:
- a ModLong.
-
toString
Get the String representation. -
toScript
Get a scripting compatible string representation.- Specified by:
toScript
in interfaceElemFactory<ModLong>
- Returns:
- script compatible representation for this ElemFactory.
- See Also:
-
equals
Comparison with any other object. -
hashCode
public int hashCode()Hash code for this ModLongRing. -
random
ModLong random.- Specified by:
random
in interfaceElemFactory<ModLong>
- Parameters:
n
- such that 0 ≤ v ≤ (2n-1).- Returns:
- a random integer mod modul.
-
random
ModLong random.- Specified by:
random
in 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:
parse
in interfaceElemFactory<ModLong>
- Parameters:
s
- String.- Returns:
- ModLong from s.
-
parse
Parse ModLong from Reader.- Specified by:
parse
in 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:
chineseRemainder
in 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
Get a ModLong iterator.
-