Package org.apfloat.jscience
Class ModuloApintField
- java.lang.Object
-
- java.lang.Number
-
- org.jscience.mathematics.number.Number<T>
-
- org.apfloat.jscience.AbstractField<ModuloApintField,org.apfloat.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,org.apfloat.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(org.apfloat.Apint value)Constructs a new integer field object with the specified value.
-
Method Summary
Modifier and Type Method Description ModuloApintFieldcopy()Returns a copy of this object.static org.apfloat.ApintgetModulus()Returns the modulus ornullif modulo reduction is not done.ModuloApintFieldinverse()Returns the multiplicative inverse of this object.ModuloApintFieldopposite()Returns the additive inverse of this object.ModuloApintFieldplus(ModuloApintField that)Returns the sum of this object with the one specified.static org.apfloat.Apintreduce(org.apfloat.Apint value)Reduce the value with the current modulus.static voidsetModulus(org.apfloat.Apint modulus)Sets the modulus.ModuloApintFieldtimes(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
-
-
-
-
Method Detail
-
getModulus
public static org.apfloat.Apint getModulus()
Returns the modulus ornullif modulo reduction is not done. The modulus can be set in a thread-specific way usingLocalContext.- Returns:
- The local modulus or
nullif modulo reduction is not done. - See Also:
setModulus(org.apfloat.Apint)
-
setModulus
public static void setModulus(org.apfloat.Apint modulus)
Sets the modulus. The modulus can be set in a thread-specific way usingLocalContext.- Parameters:
modulus- The modulus ornullif modulo reduction is not done.- Throws:
IllegalArgumentException- Ifmodulusis not positive.
-
reduce
public static org.apfloat.Apint reduce(org.apfloat.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:AbstractFieldReturns the sum of this object with the one specified.- Specified by:
plusin interfaceorg.jscience.mathematics.structure.GroupAdditive<ModuloApintField>- Specified by:
plusin classAbstractField<ModuloApintField,org.apfloat.Apint>- Parameters:
that- The addend.- Returns:
this + that
-
opposite
public ModuloApintField opposite()
Description copied from class:AbstractFieldReturns the additive inverse of this object.- Specified by:
oppositein interfaceorg.jscience.mathematics.structure.GroupAdditive<ModuloApintField>- Specified by:
oppositein classAbstractField<ModuloApintField,org.apfloat.Apint>- Returns:
-this
-
times
public ModuloApintField times(ModuloApintField that)
Description copied from class:AbstractFieldReturns the product of this object with the one specified.- Specified by:
timesin interfaceorg.jscience.mathematics.structure.GroupMultiplicative<ModuloApintField>- Specified by:
timesin interfaceorg.jscience.mathematics.structure.Ring<ModuloApintField>- Specified by:
timesin classAbstractField<ModuloApintField,org.apfloat.Apint>- Parameters:
that- The multiplicand.- Returns:
this * that
-
inverse
public ModuloApintField inverse() throws ArithmeticException
Description copied from class:AbstractFieldReturns the multiplicative inverse of this object.- Specified by:
inversein interfaceorg.jscience.mathematics.structure.GroupMultiplicative<ModuloApintField>- Specified by:
inversein classAbstractField<ModuloApintField,org.apfloat.Apint>- Returns:
1 / this- Throws:
ArithmeticException- If the divisor is zero.
-
copy
public ModuloApintField copy()
Description copied from class:AbstractFieldReturns a copy of this object.- Specified by:
copyin interfacejavolution.lang.ValueType- Specified by:
copyin classAbstractField<ModuloApintField,org.apfloat.Apint>- Returns:
- A copy of this object.
-
-