AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
This class is a wrapper around an int and encapsulates modular arithmetic with a given modulus. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/slam/ModularInt.hpp>
Public Member Functions | |
ModularInt (int val=0, int modulusVal=SizePolicy::DEFAULT_VALUE) | |
ModularInt (const ModularInt &mi) | |
ModularInt copy constructor. More... | |
ModularInt & | operator= (const ModularInt &mi) |
ModularInt copy assignment operator. More... | |
operator int () const | |
Implicit cast of a ModularInt to an int. More... | |
int | modulus () const |
ModularInt arithmetic operations | |
Arithmetic operations on a ModularInt conform to modular arithmetic. I.e. after an arithmetic operation, the value of a ModularInt is always in the range [0, modulus()-1). | |
ModularInt & | operator++ () |
const ModularInt | operator++ (int) |
ModularInt & | operator-- () |
const ModularInt | operator-- (int) |
ModularInt & | operator+= (int val) |
Addition assignment operator. More... | |
ModularInt & | operator-= (int val) |
Subtraction assignment operator. More... | |
ModularInt & | operator*= (int val) |
Multiplication assignment operator. More... | |
ModularInt equality operations | |
| |
template<typename OtherSizePolicy > | |
bool | operator== (const ModularInt< OtherSizePolicy > &mi) const |
Equality comparison operator. More... | |
template<typename OtherSizePolicy > | |
bool | operator!= (const ModularInt< OtherSizePolicy > &mi) const |
Inequality comparison operator. More... | |
This class is a wrapper around an int and encapsulates modular arithmetic with a given modulus.
It can be useful when we are iterating circularly through the elements in a relation (e.g. consecutive edges around a polygon). The class invariant is that 0 <= val < modulus(), where val is the wrapped integer. The modulus is controlled by a SizePolicy which allows it to be given at compile time or at runtime.
|
inline |
References axom::slam::ModularInt< SizePolicy >::modulus(), and SLIC_ASSERT.
|
inline |
ModularInt copy constructor.
mi | other ModularInt |
References axom::slam::ModularInt< SizePolicy >::modulus(), and SLIC_ASSERT.
|
inline |
ModularInt copy assignment operator.
mi | other ModularInt |
|
inline |
Implicit cast of a ModularInt to an int.
|
inline |
|
inline |
Pre-increment operator
|
inline |
Post-increment operator
References axom::slam::ModularInt< SizePolicy >::modulus().
|
inline |
Pre-decrement operator
|
inline |
Post-decrement operator
References axom::slam::ModularInt< SizePolicy >::modulus().
|
inline |
Addition assignment operator.
|
inline |
Subtraction assignment operator.
|
inline |
Multiplication assignment operator.
|
inline |
Equality comparison operator.
mi | Other ModularInt |
References axom::slam::ModularInt< SizePolicy >::modulus().
|
inline |
Inequality comparison operator.
References axom::slam::ModularInt< SizePolicy >::operator==().