Package org.apfloat.jscience
Class ModuloApintField
- All Implemented Interfaces:
Serializable
,Comparable<ModuloApintField>
,Immutable
,Realtime
,ValueType
,XMLSerializable
,Field<ModuloApintField>
,GroupAdditive<ModuloApintField>
,GroupMultiplicative<ModuloApintField>
,Ring<ModuloApintField>
,Structure<ModuloApintField>
This class represents an arbitrary precision modulo integer.
The modulus must be set with
setModulus(Apint)
; otherwise
the modulo reduction is not done.- Since:
- 1.8.0
- Version:
- 1.8.0
- Author:
- Mikko Tommila
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionModuloApintField
(Apint value) Constructs a new integer field object with the specified value. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Returns a copy of this object.static Apint
Returns the modulus ornull
if modulo reduction is not done.inverse()
Returns the multiplicative inverse of this object.opposite()
Returns the additive inverse of this object.plus
(ModuloApintField that) Returns the sum of this object with the one specified.static Apint
Reduce the value with the current modulus.static void
setModulus
(Apint modulus) Sets the modulus.times
(ModuloApintField that) Returns the product of this object with the one specified.Methods inherited from class org.apfloat.jscience.AbstractField
compareTo, doubleValue, equals, hashCode, isLargerThan, longValue, toText, value
Methods inherited from class org.jscience.mathematics.number.Number
byteValue, floatValue, intValue, isGreaterThan, isLessThan, minus, pow, shortValue, toString
-
Constructor Details
-
ModuloApintField
Constructs a new integer field object with the specified value.- Parameters:
value
- The value.
-
-
Method Details
-
getModulus
Returns the modulus ornull
if modulo reduction is not done. The modulus can be set in a thread-specific way usingLocalContext
.- Returns:
- The local modulus or
null
if modulo reduction is not done. - See Also:
-
setModulus
Sets the modulus. The modulus can be set in a thread-specific way usingLocalContext
.- Parameters:
modulus
- The modulus ornull
if modulo reduction is not done.- Throws:
IllegalArgumentException
- Ifmodulus
is not positive.
-
reduce
-
plus
Description copied from class:AbstractField
Returns the sum of this object with the one specified.- Specified by:
plus
in interfaceGroupAdditive<ModuloApintField>
- Specified by:
plus
in classAbstractField<ModuloApintField,
Apint> - Parameters:
that
- The addend.- Returns:
this + that
-
opposite
Description copied from class:AbstractField
Returns the additive inverse of this object.- Specified by:
opposite
in interfaceGroupAdditive<ModuloApintField>
- Specified by:
opposite
in classAbstractField<ModuloApintField,
Apint> - Returns:
-this
-
times
Description copied from class:AbstractField
Returns the product of this object with the one specified.- Specified by:
times
in interfaceGroupMultiplicative<ModuloApintField>
- Specified by:
times
in interfaceRing<ModuloApintField>
- Specified by:
times
in classAbstractField<ModuloApintField,
Apint> - Parameters:
that
- The multiplicand.- Returns:
this * that
-
inverse
Description copied from class:AbstractField
Returns the multiplicative inverse of this object.- Specified by:
inverse
in interfaceGroupMultiplicative<ModuloApintField>
- Specified by:
inverse
in classAbstractField<ModuloApintField,
Apint> - Returns:
1 / this
- Throws:
ArithmeticException
- If the divisor is zero.
-
copy
Description copied from class:AbstractField
Returns a copy of this object.- Specified by:
copy
in interfaceValueType
- Specified by:
copy
in classAbstractField<ModuloApintField,
Apint> - Returns:
- A copy of this object.
-