Class ModLong
java.lang.Object
edu.jas.arith.ModLong
- All Implemented Interfaces:
Modular, AbelianGroupElem<ModLong>, Element<ModLong>, GcdRingElem<ModLong>, MonoidElem<ModLong>, RingElem<ModLong>, Serializable, Comparable<ModLong>
ModLong class with RingElem interface. Objects of this class are immutable.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal ModLongRingModLongRing reference.final longValue part of the element data structure. -
Constructor Summary
ConstructorsConstructorDescriptionThe constructor creates a 0 ModLong object from a given ModLongRing.ModLong(ModLongRing m, long a) The constructor creates a ModLong object from a ModLongRing and a long value part.ModLong(ModLongRing m, Long a) The constructor creates a ModLong object from a ModLongRing and a Long value part.ModLong(ModLongRing m, String s) The constructor creates a ModLong object from a ModLongRing and a String value part.ModLong(ModLongRing m, BigInteger a) The constructor creates a ModLong object from a ModLongRing and a value part. -
Method Summary
Modifier and TypeMethodDescriptionabs()ModLong absolute value.longReturns the number of bits in the representation of this ModLong, including a sign bit.intModLong comparison.copy()Clone this.ModLong divide.ModLong[]ModInteger extended greatest common divisor.booleanComparison with any other object.factory()Get the corresponding element factory.longgcd(long T, long S) Long greatest common divisor.ModInteger greatest common divisor.Return a BigInteger from this Element.longgetModul()Get the module part.Return a symmetric BigInteger from this Element.longGet the symmetric value part.longgetVal()Get the value part.inthashCode()Hash code for this ModLong.long[]hegcd(long T, long S) Long half extended greatest common divisor.inverse()ModLong inverse.booleanisONE()Is ModLong number one.booleanisUnit()Is ModLong number a unit.booleanisZERO()Is ModLong number zero.longmodInverse(long T, long m) Long modular inverse.ModLong multiply.negate()ModLong negative.ModLong remainder.intsignum()ModLong signum.ModLong subtraction.ModLong 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, quotientRemainder, rightDivide, rightRemainder, twosidedDivide, twosidedRemainder
-
Field Details
-
ring
ModLongRing reference. -
val
public final long valValue part of the element data structure.
-
-
Constructor Details
-
ModLong
The constructor creates a ModLong object from a ModLongRing and a value part.- Parameters:
m- ModLongRing.a- math.BigInteger.
-
ModLong
The constructor creates a ModLong object from a ModLongRing and a long value part.- Parameters:
m- ModLongRing.a- long.
-
ModLong
The constructor creates a ModLong object from a ModLongRing and a Long value part.- Parameters:
m- ModLongRing.a- Long.
-
ModLong
The constructor creates a ModLong object from a ModLongRing and a String value part.- Parameters:
m- ModLongRing.s- String.
-
ModLong
The constructor creates a 0 ModLong object from a given ModLongRing.- Parameters:
m- ModLongRing.
-
-
Method Details
-
getVal
public long getVal()Get the value part.- Returns:
- val.
-
getModul
public long getModul()Get the module part.- Returns:
- modul.
-
factory
Get the corresponding element factory. -
getSymmetricVal
public long 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
-
isZERO
public boolean isZERO()Is ModLong number zero.- Specified by:
isZEROin interfaceAbelianGroupElem<ModLong>- Returns:
- If this is 0 then true is returned, else false.
- See Also:
-
isONE
public boolean isONE()Is ModLong number one.- Specified by:
isONEin interfaceMonoidElem<ModLong>- Returns:
- If this is 1 then true is returned, else false.
- See Also:
-
isUnit
public boolean isUnit()Is ModLong number a unit.- Specified by:
isUnitin interfaceMonoidElem<ModLong>- Returns:
- If this is a unit then true is returned, else false.
- See Also:
-
toString
-
toScript
-
toScriptFactory
Get a scripting compatible string representation of the factory.- Specified by:
toScriptFactoryin interfaceElement<ModLong>- Returns:
- script compatible representation for this ElemFactory.
- See Also:
-
compareTo
-
equals
-
hashCode
-
abs
ModLong absolute value.- Specified by:
absin interfaceAbelianGroupElem<ModLong>- Returns:
- the absolute value of this.
- See Also:
-
negate
ModLong negative.- Specified by:
negatein interfaceAbelianGroupElem<ModLong>- Returns:
- -this.
- See Also:
-
signum
public int signum()ModLong signum.- Specified by:
signumin interfaceAbelianGroupElem<ModLong>- Returns:
- signum(this).
- See Also:
-
subtract
ModLong subtraction.- Specified by:
subtractin interfaceAbelianGroupElem<ModLong>- Parameters:
S- ModLong.- Returns:
- this-S.
-
divide
ModLong divide.- Specified by:
dividein interfaceMonoidElem<ModLong>- Parameters:
S- ModLong.- Returns:
- this/S.
-
inverse
ModLong inverse.- Specified by:
inversein interfaceMonoidElem<ModLong>- Returns:
- S with S=1/this if defined.
- Throws:
NotInvertibleException- if the element is not invertible.- See Also:
-
remainder
ModLong remainder.- Specified by:
remainderin interfaceMonoidElem<ModLong>- Parameters:
S- ModLong.- Returns:
- remainder(this,S).
-
multiply
ModLong multiply.- Specified by:
multiplyin interfaceMonoidElem<ModLong>- Parameters:
S- ModLong.- Returns:
- this*S.
-
sum
ModLong summation.- Specified by:
sumin interfaceAbelianGroupElem<ModLong>- Parameters:
S- ModLong.- Returns:
- this+S.
-
gcd
-
egcd
-
gcd
public long gcd(long T, long S) Long greatest common divisor.- Parameters:
T- long.S- long.- Returns:
- gcd(T,S).
-
hegcd
public long[] hegcd(long T, long S) Long half extended greatest common divisor.- Parameters:
T- long.S- long.- Returns:
- [ gcd(T,S), a ] with a*T + b*S = gcd(T,S).
-
modInverse
public long modInverse(long T, long m) Long modular inverse.- Parameters:
T- long.m- long.- Returns:
- a with with a*T = 1 mod m.
-
bitLength
public long bitLength()Returns the number of bits in the representation of this ModLong, including a sign bit.- Returns:
- number of bits in the representation of this ModLong, including a sign bit.
-