Package org.apfloat.jscience
Class ModuloApintField
- java.lang.Object
-
- java.lang.Number
-
- org.jscience.mathematics.number.Number<T>
-
- org.apfloat.jscience.AbstractField<ModuloApintField,Apint>
-
- org.apfloat.jscience.ModuloApintField
-
- All Implemented Interfaces:
Serializable
,Comparable<ModuloApintField>
,javolution.lang.Immutable
,javolution.lang.Realtime
,javolution.lang.ValueType
,javolution.xml.XMLSerializable
,org.jscience.mathematics.structure.Field<ModuloApintField>
,org.jscience.mathematics.structure.GroupAdditive<ModuloApintField>
,org.jscience.mathematics.structure.GroupMultiplicative<ModuloApintField>
,org.jscience.mathematics.structure.Ring<ModuloApintField>
,org.jscience.mathematics.structure.Structure<ModuloApintField>
public class ModuloApintField extends AbstractField<ModuloApintField,Apint>
This class represents an arbitrary precision modulo integer. The modulus must be set withsetModulus(Apint)
; otherwise the modulo reduction is not done.- Since:
- 1.8.0
- Version:
- 1.8.0
- Author:
- Mikko Tommila
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ModuloApintField(Apint value)
Constructs a new integer field object with the specified value.
-
Method Summary
Modifier and Type Method Description ModuloApintField
copy()
Returns a copy of this object.static Apint
getModulus()
Returns the modulus ornull
if modulo reduction is not done.ModuloApintField
inverse()
Returns the multiplicative inverse of this object.ModuloApintField
opposite()
Returns the additive inverse of this object.ModuloApintField
plus(ModuloApintField that)
Returns the sum of this object with the one specified.static Apint
reduce(Apint value)
Reduce the value with the current modulus.static void
setModulus(Apint modulus)
Sets the modulus.ModuloApintField
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
-
-
-
-
Constructor Detail
-
ModuloApintField
public ModuloApintField(Apint value)
Constructs a new integer field object with the specified value.- Parameters:
value
- The value.
-
-
Method Detail
-
getModulus
public static Apint 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(org.apfloat.Apint)
-
setModulus
public static void setModulus(Apint modulus)
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
public static Apint reduce(Apint value)
Reduce the value with the current modulus.- Parameters:
value
- The value.- Returns:
- The value mod the current modulus.
-
plus
public ModuloApintField plus(ModuloApintField that)
Description copied from class:AbstractField
Returns the sum of this object with the one specified.- Specified by:
plus
in interfaceorg.jscience.mathematics.structure.GroupAdditive<ModuloApintField>
- Specified by:
plus
in classAbstractField<ModuloApintField,Apint>
- Parameters:
that
- The addend.- Returns:
this + that
-
opposite
public ModuloApintField opposite()
Description copied from class:AbstractField
Returns the additive inverse of this object.- Specified by:
opposite
in interfaceorg.jscience.mathematics.structure.GroupAdditive<ModuloApintField>
- Specified by:
opposite
in classAbstractField<ModuloApintField,Apint>
- Returns:
-this
-
times
public ModuloApintField times(ModuloApintField that)
Description copied from class:AbstractField
Returns the product of this object with the one specified.- Specified by:
times
in interfaceorg.jscience.mathematics.structure.GroupMultiplicative<ModuloApintField>
- Specified by:
times
in interfaceorg.jscience.mathematics.structure.Ring<ModuloApintField>
- Specified by:
times
in classAbstractField<ModuloApintField,Apint>
- Parameters:
that
- The multiplicand.- Returns:
this * that
-
inverse
public ModuloApintField inverse() throws ArithmeticException
Description copied from class:AbstractField
Returns the multiplicative inverse of this object.- Specified by:
inverse
in interfaceorg.jscience.mathematics.structure.GroupMultiplicative<ModuloApintField>
- Specified by:
inverse
in classAbstractField<ModuloApintField,Apint>
- Returns:
1 / this
- Throws:
ArithmeticException
- If the divisor is zero.
-
copy
public ModuloApintField copy()
Description copied from class:AbstractField
Returns a copy of this object.- Specified by:
copy
in interfacejavolution.lang.ValueType
- Specified by:
copy
in classAbstractField<ModuloApintField,Apint>
- Returns:
- A copy of this object.
-
-