Package edu.jas.arith
Class ModIntRing
- java.lang.Object
-
- edu.jas.arith.ModIntRing
-
- All Implemented Interfaces:
ModularRingFactory<ModInt>
,AbelianGroupFactory<ModInt>
,ElemFactory<ModInt>
,MonoidFactory<ModInt>
,RingFactory<ModInt>
,java.io.Serializable
,java.lang.Iterable<ModInt>
public final class ModIntRing extends java.lang.Object implements ModularRingFactory<ModInt>, java.lang.Iterable<ModInt>
ModIntRing factory with RingFactory interface. Effectively immutable.- Author:
- Heinz Kredel
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ModIntRing(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.ModIntRing(java.lang.Integer m)
The constructor creates a ModIntRing object from a Int integer as module part.ModIntRing(java.lang.Integer m, boolean isField)
The constructor creates a ModIntRing object from a Int integer as module part.ModIntRing(java.lang.String m)
The constructor creates a ModIntRing object from a String object as module part.ModIntRing(java.lang.String m, boolean isField)
The constructor creates a ModIntRing object from a String object as module part.ModIntRing(java.math.BigInteger m)
The constructor creates a ModIntRing object from a BigInteger converted to int as module part.ModIntRing(java.math.BigInteger m, boolean isField)
The constructor creates a ModIntRing object from a BigInteger converted to int 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.ModInt
chineseRemainder(ModInt c, ModInt ci, ModInt a)
ModInt chinese remainder algorithm.static java.util.List<ModInt>
chineseRemainder(ModInt m1, ModInt m2, java.util.List<ModInt> L1, java.util.List<ModInt> 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.ModInt
copy(ModInt c)
Copy ModInt element c.ModInt
create(int c)
Create ModInt element c.ModInt
create(java.lang.String c)
Create ModInt element c.ModInt
create(java.math.BigInteger c)
Create ModInt element c.boolean
equals(java.lang.Object b)
Comparison with any other object.ModInt
fromInteger(int a)
Get a ModInt element from a int value.ModInt
fromInteger(long a)
Get a ModInt element from a long value.ModInt
fromInteger(java.math.BigInteger a)
Get a ModInt element from a BigInteger value.java.util.List<ModInt>
generators()
Get a list of the generating elements.BigInteger
getIntegerModul()
Get the module part as BigInteger.int
getIntModul()
Get the module part as int.java.math.BigInteger
getModul()
Get the module part as BigInteger.ModInt
getONE()
Get the one element.ModInt
getZERO()
Get the zero element.int
hashCode()
Hash code for this ModIntRing.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<ModInt>
iterator()
Get a ModInt iterator.ModInt
parse(java.io.Reader r)
Parse ModInt from Reader.ModInt
parse(java.lang.String s)
Parse ModInt from String.ModInt
random(int n)
ModInt random.ModInt
random(int n, java.util.Random rnd)
ModInt 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
-
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
public ModIntRing(java.lang.Integer m)
The constructor creates a ModIntRing object from a Int integer as module part.- Parameters:
m
- Int integer.
-
ModIntRing
public ModIntRing(java.lang.Integer 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
public ModIntRing(java.math.BigInteger m)
The constructor creates a ModIntRing object from a BigInteger converted to int as module part.- Parameters:
m
- java.math.BigInteger.
-
ModIntRing
public ModIntRing(java.math.BigInteger m, boolean isField)
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
public ModIntRing(java.lang.String m)
The constructor creates a ModIntRing object from a String object as module part.- Parameters:
m
- String.
-
ModIntRing
public ModIntRing(java.lang.String m, boolean isField)
The constructor creates a ModIntRing 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.
-
getIntModul
public int getIntModul()
Get the module part as int.- Returns:
- modul.
-
getIntegerModul
public BigInteger getIntegerModul()
Get the module part as BigInteger.- Specified by:
getIntegerModul
in interfaceModularRingFactory<ModInt>
- Returns:
- modul.
-
create
public ModInt create(java.math.BigInteger c)
Create ModInt element c.- Parameters:
c
-- Returns:
- a ModInt of c.
-
create
public ModInt create(int c)
Create ModInt element c.- Parameters:
c
-- Returns:
- a ModInt of c.
-
create
public ModInt create(java.lang.String c)
Create ModInt element c.- Parameters:
c
-- Returns:
- a ModInt of c.
-
copy
public ModInt copy(ModInt c)
Copy ModInt element c.- Specified by:
copy
in interfaceElemFactory<ModInt>
- Parameters:
c
-- Returns:
- a copy of c.
-
getZERO
public ModInt getZERO()
Get the zero element.- Specified by:
getZERO
in interfaceAbelianGroupFactory<ModInt>
- Returns:
- 0 as ModInt.
-
getONE
public ModInt getONE()
Get the one element.- Specified by:
getONE
in interfaceMonoidFactory<ModInt>
- Returns:
- 1 as ModInt.
-
generators
public java.util.List<ModInt> generators()
Get a list of the generating elements.- Specified by:
generators
in interfaceElemFactory<ModInt>
- 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<ModInt>
- 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<ModInt>
- Returns:
- true.
-
isAssociative
public boolean isAssociative()
Query if this ring is associative.- Specified by:
isAssociative
in interfaceMonoidFactory<ModInt>
- Returns:
- true.
-
isField
public boolean isField()
Query if this ring is a field.- Specified by:
isField
in interfaceRingFactory<ModInt>
- Returns:
- true if module is prime, else false.
-
characteristic
public java.math.BigInteger characteristic()
Characteristic of this ring.- Specified by:
characteristic
in interfaceRingFactory<ModInt>
- Returns:
- characteristic of this ring.
-
fromInteger
public ModInt fromInteger(java.math.BigInteger a)
Get a ModInt element from a BigInteger value.- Specified by:
fromInteger
in interfaceElemFactory<ModInt>
- Parameters:
a
- BigInteger.- Returns:
- a ModInt.
-
fromInteger
public ModInt fromInteger(int a)
Get a ModInt element from a int value.- Parameters:
a
- int.- Returns:
- a ModInt.
-
fromInteger
public ModInt fromInteger(long a)
Get a ModInt element from a long value.- Specified by:
fromInteger
in interfaceElemFactory<ModInt>
- Parameters:
a
- lon.- Returns:
- a ModInt.
-
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<ModInt>
- 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 ModIntRing.- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
random
public ModInt random(int n)
ModInt random.- Specified by:
random
in interfaceElemFactory<ModInt>
- Parameters:
n
- such that 0 ≤ v ≤ (2n-1).- Returns:
- a random integer mod modul.
-
random
public ModInt random(int n, java.util.Random rnd)
ModInt random.- Specified by:
random
in interfaceElemFactory<ModInt>
- Parameters:
n
- such that 0 ≤ v ≤ (2n-1).rnd
- is a source for random bits.- Returns:
- a random integer mod modul.
-
parse
public ModInt parse(java.lang.String s)
Parse ModInt from String.- Specified by:
parse
in interfaceElemFactory<ModInt>
- Parameters:
s
- String.- Returns:
- ModInt from s.
-
parse
public ModInt parse(java.io.Reader r)
Parse ModInt from Reader.- Specified by:
parse
in interfaceElemFactory<ModInt>
- Parameters:
r
- Reader.- Returns:
- next ModInt from r.
-
chineseRemainder
public ModInt chineseRemainder(ModInt c, ModInt ci, ModInt a)
ModInt 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<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
public static java.util.List<ModInt> chineseRemainder(ModInt m1, ModInt m2, java.util.List<ModInt> L1, java.util.List<ModInt> 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
- ModInt.m2
- other ModInt.- Returns:
- L list of congruences.
-
-