2018-01-15 18:31:47 +01:00
|
|
|
|
|
|
|
#ifndef __arith_h__
|
|
|
|
#define __arith_h__
|
|
|
|
|
|
|
|
namespace MultiArrayHelper
|
|
|
|
{
|
|
|
|
// OPERATIONS (STATIC)
|
|
|
|
template <typename T>
|
|
|
|
struct plus
|
|
|
|
{
|
2018-02-06 13:44:15 +01:00
|
|
|
static inline T& acc(T& target, const T& arg)
|
2018-01-15 18:31:47 +01:00
|
|
|
{
|
2018-02-06 13:44:15 +01:00
|
|
|
return target += arg;
|
2018-01-15 18:31:47 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct minus
|
|
|
|
{
|
2018-02-06 13:44:15 +01:00
|
|
|
static inline T& acc(T& target, const T& arg)
|
2018-01-15 18:31:47 +01:00
|
|
|
{
|
2018-02-06 13:44:15 +01:00
|
|
|
return target -= arg;
|
2018-01-15 18:31:47 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct multiplies
|
|
|
|
{
|
2018-02-06 13:44:15 +01:00
|
|
|
static inline T& acc(T& target, const T& arg)
|
2018-01-15 18:31:47 +01:00
|
|
|
{
|
2018-02-06 13:44:15 +01:00
|
|
|
return target *= arg;
|
2018-01-15 18:31:47 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct divides
|
|
|
|
{
|
2018-02-06 13:44:15 +01:00
|
|
|
static inline T& acc(T& target, const T& arg)
|
2018-01-15 18:31:47 +01:00
|
|
|
{
|
2018-02-06 13:44:15 +01:00
|
|
|
return target /= arg;
|
2018-01-15 18:31:47 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // end namespace MultiArrayHelper
|
|
|
|
|
|
|
|
#endif
|