Package org.jscience.mathematics.number
Class ModuloInteger
- java.lang.Object
- 
- java.lang.Number
- 
- org.jscience.mathematics.number.Number<ModuloInteger>
- 
- org.jscience.mathematics.number.ModuloInteger
 
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Comparable<ModuloInteger>,- javolution.lang.Immutable,- javolution.lang.Realtime,- javolution.lang.ValueType,- javolution.xml.XMLSerializable,- Field<ModuloInteger>,- GroupAdditive<ModuloInteger>,- GroupMultiplicative<ModuloInteger>,- Ring<ModuloInteger>,- Structure<ModuloInteger>
 
 public final class ModuloInteger extends Number<ModuloInteger> implements Field<ModuloInteger> This class represents a modulo integer. It can be used in conjonction with the Matrixclass to resolve modulo equations (ref. number theory).- Version:
- 3.0, February 13, 2006
- Author:
- Jean-Marie Dautelle
- See Also:
- Wikipedia: Modular Arithmetic, Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description static ModuloIntegerONEThe modulo integer representing the multiplicative identity.static ModuloIntegerZEROThe modulo integer representing the additive identity.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(ModuloInteger that)Compares this number with the specified number for order.ModuloIntegercopy()Returns a copy of this numberallocatedby the calling thread (possibly on the stack).doubledoubleValue()Returns the value of this number as adouble.booleanequals(java.lang.Object that)Compares this modulo integer against the specified object independently of the current modulus.static LargeIntegergetModulus()Returns thelocalmodulus for modular arithmetic ornullif the arithmetic operations are non-modular (default).inthashCode()Returns the hash code for this large integer number.ModuloIntegerinverse()Returns the multiplicative inverse of this object.booleanisLargerThan(ModuloInteger that)Compares the magnitude of this number with that number.longlongValue()Returns the value of this number as along.LargeIntegermoduloValue()Returns the current modulo value of this number.ModuloIntegeropposite()Returns the additive inverse of this object.ModuloIntegerplus(ModuloInteger that)Returns the sum of this object with the one specified.static voidsetModulus(LargeInteger modulus)Sets thelocalmodulus for modular arithmetic.ModuloIntegertimes(ModuloInteger that)Returns the product of this object with the one specified.javolution.text.TexttoText()Returns the text representation of the current modulo value of this number.static ModuloIntegervalueOf(java.lang.CharSequence chars)Returns the modulo integer for the specified character sequence in decimal number.static ModuloIntegervalueOf(LargeInteger value)Returns the modulo integer having the specified value (independently of the current modulo).- 
Methods inherited from class org.jscience.mathematics.number.NumberbyteValue, floatValue, intValue, isGreaterThan, isLessThan, minus, pow, shortValue, toString
 
- 
 
- 
- 
- 
Field Detail- 
ZEROpublic static final ModuloInteger ZERO The modulo integer representing the additive identity.
 - 
ONEpublic static final ModuloInteger ONE The modulo integer representing the multiplicative identity.
 
- 
 - 
Method Detail- 
valueOfpublic static ModuloInteger valueOf(LargeInteger value) 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.
 
 - 
valueOfpublic static ModuloInteger valueOf(java.lang.CharSequence chars) Returns the modulo integer for the specified character sequence in decimal number.- Parameters:
- chars- the character sequence.
- Returns:
- the corresponding modulo number.
 
 - 
getModuluspublic static LargeInteger getModulus() Returns thelocalmodulus for modular arithmetic ornullif the arithmetic operations are non-modular (default).- Returns:
- the local modulus or nullif none.
- See Also:
- setModulus(org.jscience.mathematics.number.LargeInteger)
 
 - 
setModuluspublic static void setModulus(LargeInteger modulus) Sets thelocalmodulus for modular arithmetic.- Parameters:
- modulus- the new modulus or- nullto unset the modulus.
- Throws:
- java.lang.IllegalArgumentException- if- modulus <= 0
 
 - 
moduloValuepublic LargeInteger moduloValue() Returns the current modulo value of this number. If the modulus issettonullthe intrinsic value (the creation value) is returned.- Returns:
- the positive number equals to this number modulo modulus or this modulo creation value.
 
 - 
toTextpublic javolution.text.Text toText() Returns the text representation of the current modulo value of this number.- Specified by:
- toTextin interface- javolution.lang.Realtime
- Specified by:
- toTextin class- Number<ModuloInteger>
- Returns:
- the representation of its modulo value.
 
 - 
equalspublic boolean equals(java.lang.Object that) Compares this modulo integer against the specified object independently of the current modulus.- Specified by:
- equalsin class- Number<ModuloInteger>
- Parameters:
- that- the object to compare with.
- Returns:
- trueif that is a modulo number with the same intrinsic value;- falseotherwise.
 
 - 
hashCodepublic int hashCode() Returns the hash code for this large integer number.- Specified by:
- hashCodein class- Number<ModuloInteger>
- Returns:
- the hash code value.
 
 - 
isLargerThanpublic boolean isLargerThan(ModuloInteger that) Description copied from class:NumberCompares the magnitude of this number with that number.- Specified by:
- isLargerThanin class- Number<ModuloInteger>
- Returns:
- |this| > |that|
 
 - 
longValuepublic long longValue() Description copied from class:NumberReturns the value of this number as along.- Specified by:
- longValuein class- Number<ModuloInteger>
- Returns:
- the numeric value represented by this object after conversion
          to type long.
 
 - 
doubleValuepublic double doubleValue() Description copied from class:NumberReturns the value of this number as adouble.- Specified by:
- doubleValuein class- Number<ModuloInteger>
- Returns:
- the numeric value represented by this object after conversion
          to type double.
 
 - 
compareTopublic int compareTo(ModuloInteger that) Description copied from class:NumberCompares 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:
- compareToin interface- java.lang.Comparable<ModuloInteger>
- Specified by:
- compareToin class- Number<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.
 
 - 
timespublic ModuloInteger times(ModuloInteger that) Description copied from interface:RingReturns the product of this object with the one specified.- Specified by:
- timesin interface- GroupMultiplicative<ModuloInteger>
- Specified by:
- timesin interface- Ring<ModuloInteger>
- Parameters:
- that- the object multiplier.
- Returns:
- this ยท that.
 
 - 
pluspublic ModuloInteger plus(ModuloInteger that) Description copied from interface:GroupAdditiveReturns the sum of this object with the one specified.- Specified by:
- plusin interface- GroupAdditive<ModuloInteger>
- Parameters:
- that- the object to be added.
- Returns:
- this + that.
 
 - 
oppositepublic ModuloInteger opposite() Description copied from interface:GroupAdditiveReturns the additive inverse of this object. It is the object such asthis.plus(this.opposite()) == ZERO, withZERObeing the additive identity.- Specified by:
- oppositein interface- GroupAdditive<ModuloInteger>
- Returns:
- -this.
 
 - 
inversepublic ModuloInteger inverse() Description copied from interface:GroupMultiplicativeReturns the multiplicative inverse of this object. It it the object such asthis.times(this.inverse()) == ONE, withONEbeing the multiplicative identity.- Specified by:
- inversein interface- GroupMultiplicative<ModuloInteger>
- Returns:
- ONE / this.
 
 - 
copypublic ModuloInteger copy() Description copied from class:NumberReturns a copy of this numberallocatedby the calling thread (possibly on the stack).- Specified by:
- copyin interface- javolution.lang.ValueType
- Specified by:
- copyin class- Number<ModuloInteger>
- Returns:
- an identical and independant copy of this number.
 
 
- 
 
-