Package org.jscience.mathematics.number
Class ModuloInteger
- All Implemented Interfaces:
Serializable
,Comparable<ModuloInteger>
,javolution.lang.Immutable
,javolution.lang.Realtime
,javolution.lang.ValueType
,javolution.xml.XMLSerializable
,Field<ModuloInteger>
,GroupAdditive<ModuloInteger>
,GroupMultiplicative<ModuloInteger>
,Ring<ModuloInteger>
,Structure<ModuloInteger>
This class represents a modulo integer. It can be used in conjonction
with the Matrix
class to resolve modulo equations (ref. number theory).
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ModuloInteger
The modulo integer representing the multiplicative identity.static final ModuloInteger
The modulo integer representing the additive identity. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(ModuloInteger that) Compares this number with the specified number for order.copy()
Returns a copy of this numberallocated
by the calling thread (possibly on the stack).double
Returns the value of this number as adouble
.boolean
Compares this modulo integer against the specified object independently of the current modulus.static LargeInteger
Returns thelocal
modulus for modular arithmetic ornull
if the arithmetic operations are non-modular (default).int
hashCode()
Returns the hash code for this large integer number.inverse()
Returns the multiplicative inverse of this object.boolean
isLargerThan
(ModuloInteger that) Compares the magnitude of this number with that number.long
Returns the value of this number as along
.Returns the current modulo value of this number.opposite()
Returns the additive inverse of this object.plus
(ModuloInteger that) Returns the sum of this object with the one specified.static void
setModulus
(LargeInteger modulus) Sets thelocal
modulus for modular arithmetic.times
(ModuloInteger that) Returns the product of this object with the one specified.javolution.text.Text
toText()
Returns the text representation of the current modulo value of this number.static ModuloInteger
valueOf
(CharSequence chars) Returns the modulo integer for the specified character sequence in decimal number.static ModuloInteger
valueOf
(LargeInteger value) Returns the modulo integer having the specified value (independently of the current modulo).Methods inherited from class org.jscience.mathematics.number.Number
byteValue, floatValue, intValue, isGreaterThan, isLessThan, minus, pow, shortValue, toString
-
Field Details
-
ZERO
The modulo integer representing the additive identity. -
ONE
The modulo integer representing the multiplicative identity.
-
-
Method Details
-
valueOf
Returns the modulo integer having the specified value (independently of the current modulo).- Parameters:
value
- the modulo integer intrinsic value.- Returns:
- the corresponding modulo number.
-
valueOf
Returns the modulo integer for the specified character sequence in decimal number.- Parameters:
chars
- the character sequence.- Returns:
- the corresponding modulo number.
-
getModulus
Returns thelocal
modulus for modular arithmetic ornull
if the arithmetic operations are non-modular (default).- Returns:
- the local modulus or
null
if none. - See Also:
-
setModulus
Sets thelocal
modulus for modular arithmetic.- Parameters:
modulus
- the new modulus ornull
to unset the modulus.- Throws:
IllegalArgumentException
- ifmodulus <= 0
-
moduloValue
Returns the current modulo value of this number. If the modulus isset
tonull
the intrinsic value (the creation value) is returned.- Returns:
- the positive number equals to this number modulo modulus or this modulo creation value.
-
toText
public javolution.text.Text toText()Returns the text representation of the current modulo value of this number.- Specified by:
toText
in interfacejavolution.lang.Realtime
- Specified by:
toText
in classNumber<ModuloInteger>
- Returns:
- the representation of its modulo value.
-
equals
Compares this modulo integer against the specified object independently of the current modulus.- Specified by:
equals
in classNumber<ModuloInteger>
- Parameters:
that
- the object to compare with.- Returns:
true
if that is a modulo number with the same intrinsic value;false
otherwise.
-
hashCode
public int hashCode()Returns the hash code for this large integer number.- Specified by:
hashCode
in classNumber<ModuloInteger>
- Returns:
- the hash code value.
-
isLargerThan
Description copied from class:Number
Compares the magnitude of this number with that number.- Specified by:
isLargerThan
in classNumber<ModuloInteger>
- Returns:
|this| > |that|
-
longValue
public long longValue()Description copied from class:Number
Returns the value of this number as along
.- Specified by:
longValue
in classNumber<ModuloInteger>
- Returns:
- the numeric value represented by this object after conversion
to type
long
.
-
doubleValue
public double doubleValue()Description copied from class:Number
Returns the value of this number as adouble
.- Specified by:
doubleValue
in classNumber<ModuloInteger>
- Returns:
- the numeric value represented by this object after conversion
to type
double
.
-
compareTo
Description copied from class:Number
Compares this number with the specified number for order. Returns a negative integer, zero, or a positive integer as this number is less than, equal to, or greater than the specified number. Implementation must ensure that this method is consistent with equals(x.compareTo(y)==0) == (x.equals(y))
,- Specified by:
compareTo
in interfaceComparable<ModuloInteger>
- Specified by:
compareTo
in classNumber<ModuloInteger>
- Parameters:
that
- the number to be compared.- Returns:
- a negative integer, zero, or a positive integer as this number is less than, equal to, or greater than the specified number.
-
times
Description copied from interface:Ring
Returns the product of this object with the one specified.- Specified by:
times
in interfaceGroupMultiplicative<ModuloInteger>
- Specified by:
times
in interfaceRing<ModuloInteger>
- Parameters:
that
- the object multiplier.- Returns:
this ยท that
.
-
plus
Description copied from interface:GroupAdditive
Returns the sum of this object with the one specified.- Specified by:
plus
in interfaceGroupAdditive<ModuloInteger>
- Parameters:
that
- the object to be added.- Returns:
this + that
.
-
opposite
Description copied from interface:GroupAdditive
Returns the additive inverse of this object. It is the object such asthis.plus(this.opposite()) == ZERO
, withZERO
being the additive identity.- Specified by:
opposite
in interfaceGroupAdditive<ModuloInteger>
- Returns:
-this
.
-
inverse
Description copied from interface:GroupMultiplicative
Returns the multiplicative inverse of this object. It it the object such asthis.times(this.inverse()) == ONE
, withONE
being the multiplicative identity.- Specified by:
inverse
in interfaceGroupMultiplicative<ModuloInteger>
- Returns:
ONE / this
.
-
copy
Description copied from class:Number
Returns a copy of this numberallocated
by the calling thread (possibly on the stack).- Specified by:
copy
in interfacejavolution.lang.ValueType
- Specified by:
copy
in classNumber<ModuloInteger>
- Returns:
- an identical and independant copy of this number.
-