JScience v3.3

org.jscience.mathematics.numbers
Class ModuloInteger

java.lang.Object
  extended by javolution.context.RealtimeObject
      extended by org.jscience.mathematics.numbers.Number<ModuloInteger>
          extended by org.jscience.mathematics.numbers.ModuloInteger
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<ModuloInteger>, Realtime, Immutable, 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 Matrix class to resolve modulo equations (ref. number theory).

Version:
3.0, February 13, 2006
Author:
Jean-Marie Dautelle
See Also:
Wikipedia: Modular Arithmetic, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javolution.context.RealtimeObject
RealtimeObject.Factory<T extends RealtimeObject>
 
Nested classes/interfaces inherited from interface javolution.context.Realtime
Realtime.ObjectSpace
 
Field Summary
static ModuloInteger ONE
          The modulo integer representing the multiplicative identity.
protected static XMLFormat<ModuloInteger> XML
          Holds the default XML representation for modulo integers.
static ModuloInteger ZERO
          The modulo integer representing the additive identity.
 
Method Summary
 int compareTo(ModuloInteger that)
          Compares this number with the specified number for order.
 double doubleValue()
          Returns the value of this number as a double.
 boolean equals(java.lang.Object that)
          Compares this modulo integer against the specified object independently of the current modulus.
static LargeInteger getModulus()
          Returns the local modulus for modular arithmetic or null if the arithmetic operations are non-modular (default).
 int hashCode()
          Returns the hash code for this large integer number.
 ModuloInteger inverse()
          Returns the multiplicative inverse of this object.
 boolean isLargerThan(ModuloInteger that)
          Compares the magnitude of this number with that number.
 long longValue()
          Returns the value of this number as a long.
 LargeInteger moduloValue()
          Returns the current modulo value of this number.
 boolean move(Realtime.ObjectSpace os)
          Moves this real-time object to the specified object space.
 ModuloInteger opposite()
          Returns the additive inverse of this object.
 ModuloInteger plus(ModuloInteger that)
          Returns the sum of this object with the one specified.
static void setModulus(LargeInteger modulus)
          Sets the local modulus for modular arithmetic.
 ModuloInteger times(ModuloInteger that)
          Returns the product of this object with the one specified.
 Text toText()
          Returns the text representation of the current modulo value of this number.
static ModuloInteger valueOf(java.lang.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.numbers.Number
byteValue, floatValue, intValue, isGreaterThan, isLessThan, minus, pow, shortValue
 
Methods inherited from class javolution.context.RealtimeObject
export, isLocal, moveHeap, preserve, toString, unpreserve
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

XML

protected static final XMLFormat<ModuloInteger> XML
Holds the default XML representation for modulo integers. This representation consists of a simple value attribute holding the textual representation.


ZERO

public static final ModuloInteger ZERO
The modulo integer representing the additive identity.


ONE

public static final ModuloInteger ONE
The modulo integer representing the multiplicative identity.

Method Detail

valueOf

public 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.

valueOf

public 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.

getModulus

public static LargeInteger getModulus()
Returns the local modulus for modular arithmetic or null if the arithmetic operations are non-modular (default).

Returns:
the local modulus or null if none.
See Also:
setModulus(org.jscience.mathematics.numbers.LargeInteger)

setModulus

public static void setModulus(LargeInteger modulus)
Sets the local modulus for modular arithmetic.

Parameters:
modulus - the new modulus or null to unset the modulus.
Throws:
java.lang.IllegalArgumentException - if modulus <= 0

moduloValue

public LargeInteger moduloValue()
Returns the current modulo value of this number. If the modulus is set to null 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 Text toText()
Returns the text representation of the current modulo value of this number.

Specified by:
toText in interface Realtime
Specified by:
toText in class Number<ModuloInteger>
Returns:
the representation of its modulo value.

equals

public boolean equals(java.lang.Object that)
Compares this modulo integer against the specified object independently of the current modulus.

Specified by:
equals in class Number<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 class Number<ModuloInteger>
Returns:
the hash code value.

move

public boolean move(Realtime.ObjectSpace os)
Description copied from class: Number
Moves this real-time object to the specified object space.

Specified by:
move in interface Realtime
Overrides:
move in class Number<ModuloInteger>
Parameters:
os - the object space to move this real-time object to.
Returns:
true if the move has to be propagated to external real-time references; false otherwise.

isLargerThan

public boolean isLargerThan(ModuloInteger that)
Description copied from class: Number
Compares the magnitude of this number with that number.

Specified by:
isLargerThan in class Number<ModuloInteger>
Returns:
|this| > |that|

longValue

public long longValue()
Description copied from class: Number
Returns the value of this number as a long.

Specified by:
longValue in class Number<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 a double.

Specified by:
doubleValue in class Number<ModuloInteger>
Returns:
the numeric value represented by this object after conversion to type double.

compareTo

public int compareTo(ModuloInteger that)
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 interface java.lang.Comparable<ModuloInteger>
Specified by:
compareTo in 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.

times

public ModuloInteger times(ModuloInteger that)
Description copied from interface: Ring
Returns the product of this object with the one specified.

Specified by:
times in interface GroupMultiplicative<ModuloInteger>
Specified by:
times in interface Ring<ModuloInteger>
Parameters:
that - the object multiplier.
Returns:
this ยท that.

plus

public ModuloInteger plus(ModuloInteger that)
Description copied from interface: GroupAdditive
Returns the sum of this object with the one specified.

Specified by:
plus in interface GroupAdditive<ModuloInteger>
Parameters:
that - the object to be added.
Returns:
this + that.

opposite

public ModuloInteger opposite()
Description copied from interface: GroupAdditive
Returns the additive inverse of this object. It is the object such as this.plus(this.opposite()) == ZERO, with ZERO being the additive identity.

Specified by:
opposite in interface GroupAdditive<ModuloInteger>
Returns:
-this.

inverse

public ModuloInteger inverse()
Description copied from interface: GroupMultiplicative
Returns the multiplicative inverse of this object. It it the object such as this.times(this.reciprocal()) == ONE , with ONE being the multiplicative identity.

Specified by:
inverse in interface GroupMultiplicative<ModuloInteger>
Returns:
ONE / this.

JScience v3.3

Copyright © 2006 JScience.