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>,java.io.Serializable,java.lang.Iterable<ModLong>
public final class ModLongRing extends java.lang.Object implements ModularRingFactory<ModLong>, java.lang.Iterable<ModLong>
ModLongRing factory with RingFactory interface. Effectively immutable.- Author:
- Heinz Kredel
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description 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.ModLongRing(java.lang.Long m)The constructor creates a ModLongRing object from a Long integer as module part.ModLongRing(java.lang.Long m, boolean isField)The constructor creates a ModLongRing object from a Long integer as module part.ModLongRing(java.lang.String m)The constructor creates a ModLongRing object from a String object as module part.ModLongRing(java.lang.String m, boolean isField)The constructor creates a ModLongRing object from a String object as module part.ModLongRing(java.math.BigInteger m)The constructor creates a ModLongRing object from a BigInteger converted to long as module part.ModLongRing(java.math.BigInteger m, boolean isField)The constructor creates a ModLongRing object from a BigInteger converted to long 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.ModLongchineseRemainder(ModLong c, ModLong ci, ModLong a)ModLong chinese remainder algorithm.static java.util.List<ModLong>chineseRemainder(ModLong m1, ModLong m2, java.util.List<ModLong> L1, java.util.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.ModLongcopy(ModLong c)Copy ModLong element c.ModLongcreate(long c)Create ModLong element c.ModLongcreate(java.lang.String c)Create ModLong element c.ModLongcreate(java.math.BigInteger c)Create ModLong element c.booleanequals(java.lang.Object b)Comparison with any other object.ModLongfromInteger(long a)Get a ModLong element from a long value.ModLongfromInteger(java.math.BigInteger a)Get a ModLong element from a BigInteger value.java.util.List<ModLong>generators()Get a list of the generating elements.BigIntegergetIntegerModul()Get the module part as BigInteger.longgetLongModul()Get the module part as long.java.math.BigIntegergetModul()Get the module part as BigInteger.ModLonggetONE()Get the one element.ModLonggetZERO()Get the zero element.inthashCode()Hash code for this ModLongRing.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<ModLong>iterator()Get a ModLong iterator.ModLongparse(java.io.Reader r)Parse ModLong from Reader.ModLongparse(java.lang.String s)Parse ModLong from String.ModLongrandom(int n)ModLong random.ModLongrandom(int n, java.util.Random rnd)ModLong 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
-
-
-
-
Constructor Detail
-
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
public ModLongRing(java.lang.Long m)
The constructor creates a ModLongRing object from a Long integer as module part.- Parameters:
m- Long integer.
-
ModLongRing
public ModLongRing(java.lang.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
public ModLongRing(java.math.BigInteger m)
The constructor creates a ModLongRing object from a BigInteger converted to long as module part.- Parameters:
m- java.math.BigInteger.
-
ModLongRing
public ModLongRing(java.math.BigInteger m, boolean isField)
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
public ModLongRing(java.lang.String m)
The constructor creates a ModLongRing object from a String object as module part.- Parameters:
m- String.
-
ModLongRing
public ModLongRing(java.lang.String m, boolean isField)
The constructor creates a ModLongRing 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 as BigInteger.- Returns:
- modul.
-
getLongModul
public long getLongModul()
Get the module part as long.- Returns:
- modul.
-
getIntegerModul
public BigInteger getIntegerModul()
Get the module part as BigInteger.- Specified by:
getIntegerModulin interfaceModularRingFactory<ModLong>- Returns:
- modul.
-
create
public ModLong create(java.math.BigInteger c)
Create ModLong element c.- Parameters:
c-- Returns:
- a ModLong of c.
-
create
public ModLong create(long c)
Create ModLong element c.- Parameters:
c-- Returns:
- a ModLong of c.
-
create
public ModLong create(java.lang.String c)
Create ModLong element c.- Parameters:
c-- Returns:
- a ModLong of c.
-
copy
public ModLong copy(ModLong c)
Copy ModLong element c.- Specified by:
copyin interfaceElemFactory<ModLong>- Parameters:
c-- Returns:
- a copy of c.
-
getZERO
public ModLong getZERO()
Get the zero element.- Specified by:
getZEROin interfaceAbelianGroupFactory<ModLong>- Returns:
- 0 as ModLong.
-
getONE
public ModLong getONE()
Get the one element.- Specified by:
getONEin interfaceMonoidFactory<ModLong>- Returns:
- 1 as ModLong.
-
generators
public java.util.List<ModLong> generators()
Get a list of the generating elements.- Specified by:
generatorsin interfaceElemFactory<ModLong>- 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<ModLong>- 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<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
public java.math.BigInteger characteristic()
Characteristic of this ring.- Specified by:
characteristicin interfaceRingFactory<ModLong>- Returns:
- characteristic of this ring.
-
fromInteger
public ModLong fromInteger(java.math.BigInteger a)
Get a ModLong element from a BigInteger value.- Specified by:
fromIntegerin interfaceElemFactory<ModLong>- Parameters:
a- BigInteger.- Returns:
- a ModLong.
-
fromInteger
public ModLong fromInteger(long a)
Get a ModLong element from a long value.- Specified by:
fromIntegerin interfaceElemFactory<ModLong>- Parameters:
a- long.- Returns:
- a ModLong.
-
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<ModLong>- 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 ModLongRing.- Overrides:
hashCodein classjava.lang.Object- See Also:
Object.hashCode()
-
random
public ModLong random(int n)
ModLong random.- Specified by:
randomin interfaceElemFactory<ModLong>- Parameters:
n- such that 0 ≤ v ≤ (2n-1).- Returns:
- a random integer mod modul.
-
random
public ModLong random(int n, java.util.Random rnd)
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
public ModLong parse(java.lang.String s)
Parse ModLong from String.- Specified by:
parsein interfaceElemFactory<ModLong>- Parameters:
s- String.- Returns:
- ModLong from s.
-
parse
public ModLong parse(java.io.Reader r)
Parse ModLong from Reader.- Specified by:
parsein interfaceElemFactory<ModLong>- Parameters:
r- Reader.- Returns:
- next ModLong from r.
-
chineseRemainder
public ModLong chineseRemainder(ModLong c, ModLong ci, ModLong a)
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 java.util.List<ModLong> chineseRemainder(ModLong m1, ModLong m2, java.util.List<ModLong> L1, java.util.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.
-
-