Class ModInteger
java.lang.Object
edu.jas.arith.ModInteger
- All Implemented Interfaces:
Modular, AbelianGroupElem<ModInteger>, Element<ModInteger>, GcdRingElem<ModInteger>, MonoidElem<ModInteger>, RingElem<ModInteger>, Serializable, Comparable<ModInteger>
ModInteger class with GcdRingElem interface. Objects of this class are
immutable. The SAC2 static methods are also provided.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal ModIntegerRingModIntegerRing reference.final BigIntegerValue part of the element data structure. -
Constructor Summary
ConstructorsConstructorDescriptionThe constructor creates a 0 ModInteger object from a given ModIntegerRing.ModInteger(ModIntegerRing m, long a) The constructor creates a ModInteger object from a ModIntegerRing and a long value part.ModInteger(ModIntegerRing m, String s) The constructor creates a ModInteger object from a ModIntegerRing and a String value part.The constructor creates a ModInteger object from a ModIntegerRing and a value part. -
Method Summary
Modifier and TypeMethodDescriptionabs()ModInteger absolute value.longReturns the number of bits in the representation of this ModInteger, including a sign bit.intModInteger comparison.copy()Clone this.divide(ModInteger S) ModInteger divide.egcd(ModInteger S) ModInteger extended greatest common divisor.booleanComparison with any other object.factory()Get the corresponding element factory.gcd(ModInteger S) ModInteger greatest common divisor.Return a BigInteger from this Element.getModul()Get the module part.Return a symmetric BigInteger from this Element.Get the symmetric value part.getVal()Get the value part.inthashCode()Hash code for this ModInteger.hegcd(ModInteger S) ModInteger half extended greatest common divisor.inverse()ModInteger inverse.booleanisONE()Is ModInteger number one.booleanisUnit()Is ModInteger number a unit.booleanisZERO()Is ModInteger number zero.static ModIntegerMIABS(ModInteger A) ModInteger absolute value.static intMICOMP(ModInteger A, ModInteger B) ModInteger comparison.static ModIntegerMIDIF(ModInteger A, ModInteger B) ModInteger subtraction.static ModIntegerMIINV(ModInteger A) ModInteger inverse.static ModIntegerMINEG(ModInteger A) ModInteger negative.static ModIntegerMIPROD(ModInteger A, ModInteger B) ModInteger product.static ModIntegerMIQ(ModInteger A, ModInteger B) ModInteger quotient.static ModIntegerMIREM(ModInteger A, ModInteger B) ModInteger remainder.static intMISIGN(ModInteger A) ModInteger signum.static ModIntegerMISUM(ModInteger A, ModInteger B) ModInteger summation.ModInteger multiply.negate()ModInteger negative.Quotient and remainder by division of this by S.ModInteger remainder.intsignum()ModInteger signum.ModInteger subtraction.sum(ModInteger S) ModInteger summation.toScript()Get a scripting compatible string representation.Get a scripting compatible string representation of the factory.toString()Get the String representation.Methods inherited from interface MonoidElem
leftDivide, leftRemainder, power, rightDivide, rightRemainder, twosidedDivide, twosidedRemainder
-
Field Details
-
ring
ModIntegerRing reference. -
val
Value part of the element data structure.
-
-
Constructor Details
-
ModInteger
The constructor creates a ModInteger object from a ModIntegerRing and a value part.- Parameters:
m- ModIntegerRing.a- math.BigInteger.
-
ModInteger
The constructor creates a ModInteger object from a ModIntegerRing and a long value part.- Parameters:
m- ModIntegerRing.a- long.
-
ModInteger
The constructor creates a ModInteger object from a ModIntegerRing and a String value part.- Parameters:
m- ModIntegerRing.s- String.
-
ModInteger
The constructor creates a 0 ModInteger object from a given ModIntegerRing.- Parameters:
m- ModIntegerRing.
-
-
Method Details
-
getVal
-
getModul
-
factory
Get the corresponding element factory.- Specified by:
factoryin interfaceElement<ModInteger>- Returns:
- factory for this Element.
- See Also:
-
getSymmetricVal
Get the symmetric value part.- Returns:
- val with -modul/2 ≤ val < modul/2.
-
getInteger
Return a BigInteger from this Element.- Specified by:
getIntegerin interfaceModular- Returns:
- a BigInteger of this.
-
getSymmetricInteger
Return a symmetric BigInteger from this Element.- Specified by:
getSymmetricIntegerin interfaceModular- Returns:
- a symmetric BigInteger of this.
-
copy
Clone this.- Specified by:
copyin interfaceElement<ModInteger>- Returns:
- Creates and returns a copy of this Element.
- See Also:
-
isZERO
public boolean isZERO()Is ModInteger number zero.- Specified by:
isZEROin interfaceAbelianGroupElem<ModInteger>- Returns:
- If this is 0 then true is returned, else false.
- See Also:
-
isONE
public boolean isONE()Is ModInteger number one.- Specified by:
isONEin interfaceMonoidElem<ModInteger>- Returns:
- If this is 1 then true is returned, else false.
- See Also:
-
isUnit
public boolean isUnit()Is ModInteger number a unit.- Specified by:
isUnitin interfaceMonoidElem<ModInteger>- Returns:
- If this is a unit then true is returned, else false.
- See Also:
-
toString
-
toScript
Get a scripting compatible string representation.- Specified by:
toScriptin interfaceElement<ModInteger>- Returns:
- script compatible representation for this Element.
- See Also:
-
toScriptFactory
Get a scripting compatible string representation of the factory.- Specified by:
toScriptFactoryin interfaceElement<ModInteger>- Returns:
- script compatible representation for this ElemFactory.
- See Also:
-
compareTo
ModInteger comparison.- Specified by:
compareToin interfaceComparable<ModInteger>- Specified by:
compareToin interfaceElement<ModInteger>- Parameters:
b- ModInteger.- Returns:
- sign(this-b).
-
MICOMP
ModInteger comparison.- Parameters:
A- ModInteger.B- ModInteger.- Returns:
- sign(this-b).
-
equals
-
hashCode
public int hashCode()Hash code for this ModInteger.- Specified by:
hashCodein interfaceElement<ModInteger>- Overrides:
hashCodein classObject- Returns:
- the hashCode.
- See Also:
-
abs
ModInteger absolute value.- Specified by:
absin interfaceAbelianGroupElem<ModInteger>- Returns:
- the absolute value of this.
- See Also:
-
MIABS
ModInteger absolute value.- Parameters:
A- ModInteger.- Returns:
- the absolute value of A.
-
negate
ModInteger negative.- Specified by:
negatein interfaceAbelianGroupElem<ModInteger>- Returns:
- -this.
- See Also:
-
MINEG
ModInteger negative.- Parameters:
A- ModInteger.- Returns:
- -A.
-
signum
public int signum()ModInteger signum.- Specified by:
signumin interfaceAbelianGroupElem<ModInteger>- Returns:
- signum(this).
- See Also:
-
MISIGN
ModInteger signum.- Parameters:
A- ModInteger- Returns:
- signum(A).
-
subtract
ModInteger subtraction.- Specified by:
subtractin interfaceAbelianGroupElem<ModInteger>- Parameters:
S- ModInteger.- Returns:
- this-S.
-
MIDIF
ModInteger subtraction.- Parameters:
A- ModInteger.B- ModInteger.- Returns:
- A-B.
-
divide
ModInteger divide.- Specified by:
dividein interfaceMonoidElem<ModInteger>- Parameters:
S- ModInteger.- Returns:
- this/S.
-
MIQ
ModInteger quotient.- Parameters:
A- ModInteger.B- ModInteger.- Returns:
- A/B.
-
inverse
ModInteger inverse.- Specified by:
inversein interfaceMonoidElem<ModInteger>- Returns:
- S with S=1/this if defined.
- Throws:
NotInvertibleException- if the element is not invertible.- See Also:
-
MIINV
ModInteger inverse.- Parameters:
A- is a non-zero integer.- Returns:
- S with S=1/A if defined.
- See Also:
-
remainder
ModInteger remainder.- Specified by:
remainderin interfaceMonoidElem<ModInteger>- Parameters:
S- ModInteger.- Returns:
- remainder(this,S).
-
MIREM
ModInteger remainder.- Parameters:
A- ModInteger.B- ModInteger.- Returns:
- A - (A/B)*B.
-
quotientRemainder
Quotient and remainder by division of this by S.- Specified by:
quotientRemainderin interfaceMonoidElem<ModInteger>- Parameters:
S- a modular integer- Returns:
- [this/S, this - (this/S)*S].
-
multiply
ModInteger multiply.- Specified by:
multiplyin interfaceMonoidElem<ModInteger>- Parameters:
S- ModInteger.- Returns:
- this*S.
-
MIPROD
ModInteger product.- Parameters:
A- ModInteger.B- ModInteger.- Returns:
- A*B.
-
sum
ModInteger summation.- Specified by:
sumin interfaceAbelianGroupElem<ModInteger>- Parameters:
S- ModInteger.- Returns:
- this+S.
-
MISUM
ModInteger summation.- Parameters:
A- ModInteger.B- ModInteger.- Returns:
- A+B.
-
gcd
ModInteger greatest common divisor.- Specified by:
gcdin interfaceRingElem<ModInteger>- Parameters:
S- ModInteger.- Returns:
- gcd(this,S).
-
hegcd
ModInteger half extended greatest common divisor.- Parameters:
S- ModInteger.- Returns:
- [ gcd(this,S), a ] with a*this + b*S = gcd(this,S) for some b.
-
egcd
ModInteger extended greatest common divisor.- Specified by:
egcdin interfaceRingElem<ModInteger>- Parameters:
S- ModInteger.- Returns:
- [ gcd(this,S), a, b ] with a*this + b*S = gcd(this,S).
-
bitLength
public long bitLength()Returns the number of bits in the representation of this ModInteger, including a sign bit. For positive ModIntegers, this is equivalent toval.bitLength().)- Returns:
- number of bits in the representation of this ModInteger, including a sign bit.
-