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.BigInteger
characteristic()
Characteristic of this ring.ModLong
chineseRemainder(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.ModLong
copy(ModLong c)
Copy ModLong element c.ModLong
create(long c)
Create ModLong element c.ModLong
create(java.lang.String c)
Create ModLong element c.ModLong
create(java.math.BigInteger c)
Create ModLong element c.boolean
equals(java.lang.Object b)
Comparison with any other object.ModLong
fromInteger(long a)
Get a ModLong element from a long value.ModLong
fromInteger(java.math.BigInteger a)
Get a ModLong element from a BigInteger value.java.util.List<ModLong>
generators()
Get a list of the generating elements.BigInteger
getIntegerModul()
Get the module part as BigInteger.long
getLongModul()
Get the module part as long.java.math.BigInteger
getModul()
Get the module part as BigInteger.ModLong
getONE()
Get the one element.ModLong
getZERO()
Get the zero element.int
hashCode()
Hash code for this ModLongRing.boolean
isAssociative()
Query if this ring is associative.boolean
isCommutative()
Query if this ring is commutative.boolean
isField()
Query if this ring is a field.boolean
isFinite()
Is this structure finite or infinite.java.util.Iterator<ModLong>
iterator()
Get a ModLong iterator.ModLong
parse(java.io.Reader r)
Parse ModLong from Reader.ModLong
parse(java.lang.String s)
Parse ModLong from String.ModLong
random(int n)
ModLong random.ModLong
random(int n, java.util.Random rnd)
ModLong random.java.lang.String
toScript()
Get a scripting compatible string representation.java.lang.String
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
-
-
-
-
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:
getIntegerModul
in 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:
copy
in interfaceElemFactory<ModLong>
- Parameters:
c
-- Returns:
- a copy of c.
-
getZERO
public ModLong getZERO()
Get the zero element.- Specified by:
getZERO
in interfaceAbelianGroupFactory<ModLong>
- Returns:
- 0 as ModLong.
-
getONE
public ModLong getONE()
Get the one element.- Specified by:
getONE
in interfaceMonoidFactory<ModLong>
- Returns:
- 1 as ModLong.
-
generators
public java.util.List<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:
ElemFactory.generators()
-
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:
ElemFactory.isFinite()
-
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
public java.math.BigInteger characteristic()
Characteristic of this ring.- Specified by:
characteristic
in 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:
fromInteger
in interfaceElemFactory<ModLong>
- Parameters:
a
- BigInteger.- Returns:
- a ModLong.
-
fromInteger
public ModLong fromInteger(long a)
Get a ModLong element from a long value.- Specified by:
fromInteger
in interfaceElemFactory<ModLong>
- Parameters:
a
- long.- Returns:
- a ModLong.
-
toString
public java.lang.String toString()
Get the String representation.- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
toScript
public java.lang.String toScript()
Get a scripting compatible string representation.- Specified by:
toScript
in 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:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
Hash code for this ModLongRing.- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
random
public ModLong random(int n)
ModLong random.- Specified by:
random
in 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:
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
public ModLong parse(java.lang.String s)
Parse ModLong from String.- Specified by:
parse
in interfaceElemFactory<ModLong>
- Parameters:
s
- String.- Returns:
- ModLong from s.
-
parse
public ModLong parse(java.io.Reader r)
Parse ModLong from Reader.- Specified by:
parse
in 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:
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 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.
-
-