SUNphi  1.0
Arithmetic.hpp File Reference

Defines several template version of simple arithmetic operations. More...

Go to the source code of this file.

Functions

template<typename T >
SUNphi::safeModulo (const T &val, const T &mod)
 
template<typename T >
SUNphi::sqr (const T &x)
 Square of a number.
 
template<typename T >
SUNphi::sign (const T &x)
 Sign of a number, +1 0 or -1.
 
template<typename I1 , typename I2 >
auto SUNphi::greatestCommonDivisor (const I1 &_a, const I2 &_b)
 Return greatest common divisor between a and b. More...
 
template<typename I1 , typename I2 >
auto SUNphi::leastCommonMultiple (const I1 &a, const I2 &b)
 Return least common multiple between a and b.
 

Detailed Description

Defines several template version of simple arithmetic operations.

Definition in file Arithmetic.hpp.

Function Documentation

template<typename I1 , typename I2 >
auto SUNphi::greatestCommonDivisor ( const I1 &  _a,
const I2 &  _b 
)

Return greatest common divisor between a and b.

Inner type to be used

Cast to I of _a

Cast to I of _b

Store temporarily a

Definition at line 71 of file Arithmetic.hpp.

template<typename T >
T SUNphi::safeModulo ( const T &  val,
const T &  mod 
)

Modulo operator, based on remainder operator %

Valid on negative and positive numbers

Example:

safeModulo(5,3); // 2
safeModulo(-2,3); // 1
safeModulo(-3,3); // 0

Remainder

Parameters
valValue of which to take the modulo
modModulo

Definition at line 26 of file Arithmetic.hpp.