DGtal 1.4.0
|
implements basic functions on modular arithmetic. More...
#include <DGtal/arithmetic/ModuloComputer.h>
Public Types | |
typedef TInteger | Integer |
typedef NumberTraits< Integer >::ParamType | IntegerParamType |
typedef NumberTraits< TInteger >::UnsignedVersion | UnsignedInteger |
typedef NumberTraits< UnsignedInteger >::ParamType | UnsignedIntegerParamType |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::CInteger< Integer >)) | |
ModuloComputer (UnsignedIntegerParamType m) | |
void | increment (UnsignedInteger &i) const |
void | decrement (UnsignedInteger &i) const |
UnsignedInteger | next (UnsignedIntegerParamType i) const |
UnsignedInteger | previous (UnsignedIntegerParamType i) const |
UnsignedInteger | cast (IntegerParamType i) const |
bool | less (UnsignedIntegerParamType i, UnsignedIntegerParamType j) const |
UnsignedInteger | posDiff (UnsignedIntegerParamType j, UnsignedIntegerParamType i) const |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
Protected Member Functions | |
ModuloComputer () | |
Private Member Functions | |
ModuloComputer (const ModuloComputer &other) | |
ModuloComputer & | operator= (const ModuloComputer &other) |
Private Attributes | |
UnsignedInteger | k |
implements basic functions on modular arithmetic.
Description of template class 'ModuloComputer'
TInteger | type of integer. |
Example:
Definition at line 79 of file ModuloComputer.h.
typedef TInteger DGtal::ModuloComputer< TInteger >::Integer |
Definition at line 82 of file ModuloComputer.h.
typedef NumberTraits<Integer>::ParamType DGtal::ModuloComputer< TInteger >::IntegerParamType |
Definition at line 83 of file ModuloComputer.h.
typedef NumberTraits<TInteger>::UnsignedVersion DGtal::ModuloComputer< TInteger >::UnsignedInteger |
Definition at line 85 of file ModuloComputer.h.
typedef NumberTraits<UnsignedInteger>::ParamType DGtal::ModuloComputer< TInteger >::UnsignedIntegerParamType |
Definition at line 86 of file ModuloComputer.h.
DGtal::ModuloComputer< TInteger >::ModuloComputer | ( | UnsignedIntegerParamType | m | ) |
Initializes the modulo computer with the value [m].
m | any non-zero integer. |
|
protected |
Constructor. Forbidden by default (protected to avoid g++ warnings).
|
private |
Copy constructor.
other | the object to clone. Forbidden by default. |
DGtal::ModuloComputer< TInteger >::BOOST_CONCEPT_ASSERT | ( | (concepts::CInteger< Integer >) | ) |
UnsignedInteger DGtal::ModuloComputer< TInteger >::cast | ( | IntegerParamType | i | ) | const |
i | any integer value. |
Referenced by testModuloComputer().
void DGtal::ModuloComputer< TInteger >::decrement | ( | UnsignedInteger & | i | ) | const |
Decrement the value [i] modulo.
i | any value between 0 and [k] (excluded). |
void DGtal::ModuloComputer< TInteger >::increment | ( | UnsignedInteger & | i | ) | const |
Increment the value [i] modulo.
i | any value between 0 and [k] (excluded). |
Referenced by testModuloComputer().
bool DGtal::ModuloComputer< TInteger >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
bool DGtal::ModuloComputer< TInteger >::less | ( | UnsignedIntegerParamType | i, |
UnsignedIntegerParamType | j ) const |
Less comparator modulo. Be careful, modulo comparisons have no sense when the absolute difference of the values are around k / 2.
i | any value between 0 and [k] (excluded). |
j | any value between 0 and [k] (excluded). |
UnsignedInteger DGtal::ModuloComputer< TInteger >::next | ( | UnsignedIntegerParamType | i | ) | const |
i | any value between 0 and [k] (excluded). |
|
private |
Assignment.
other | the object to copy. |
UnsignedInteger DGtal::ModuloComputer< TInteger >::posDiff | ( | UnsignedIntegerParamType | j, |
UnsignedIntegerParamType | i ) const |
Performs j - i modulo, assuming less(i,j) is true.
j | any value between 0 and [k] (excluded). |
i | any value between 0 and [k] (excluded). |
UnsignedInteger DGtal::ModuloComputer< TInteger >::previous | ( | UnsignedIntegerParamType | i | ) | const |
i | any value between 0 and [k] (excluded). |
void DGtal::ModuloComputer< TInteger >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
|
private |
Modulo of all computations.
Definition at line 164 of file ModuloComputer.h.