HOPS
HOPS class reference
MHO_CompoundReductions.hh
Go to the documentation of this file.
1 #ifndef MHO_CompoundReductions_HH__
2 #define MHO_CompoundReductions_HH__
3 
13 #include <complex>
14 #include <cstddef>
15 
16 namespace hops
17 {
18 
22 template< typename XValueType > struct MHO_SumIdentity
23 {
30  static XValueType value() { return 0.0; };
31 };
32 
33 //specializations for common types
37 template<> struct MHO_SumIdentity< bool >
38 {
45  static inline bool value() { return false; };
46 };
47 
51 template<> struct MHO_SumIdentity< int >
52 {
59  static inline int value() { return 0; };
60 };
61 
65 template<> struct MHO_SumIdentity< short >
66 {
73  static inline short value() { return 0; };
74 };
75 
79 template<> struct MHO_SumIdentity< unsigned int >
80 {
87  static inline unsigned int value() { return 0; };
88 };
89 
93 template<> struct MHO_SumIdentity< std::size_t >
94 {
101  static inline std::size_t value() { return 0; };
102 };
103 
107 template<> struct MHO_SumIdentity< float >
108 {
115  static inline float value() { return 0.0; };
116 };
117 
121 template<> struct MHO_SumIdentity< double >
122 {
129  static inline double value() { return 0.0; };
130 };
131 
135 template<> struct MHO_SumIdentity< long double >
136 {
143  static inline long double value() { return 0.0; };
144 };
145 
149 template<> struct MHO_SumIdentity< std::complex< float > >
150 {
157  static inline std::complex< float > value() { return std::complex< float >(0.0, 0.0); };
158 };
159 
163 template<> struct MHO_SumIdentity< std::complex< double > >
164 {
171  static inline std::complex< double > value() { return std::complex< double >(0.0, 0.0); };
172 };
173 
177 template<> struct MHO_SumIdentity< std::complex< long double > >
178 {
185  static inline std::complex< long double > value() { return std::complex< long double >(0.0, 0.0); };
186 };
187 
191 template< typename XValueType > struct MHO_MultiplyIdentity
192 {
199  static XValueType value() { return 0.0; };
200 };
201 
202 //specializations for common types
206 template<> struct MHO_MultiplyIdentity< bool >
207 {
214  static inline bool value() { return true; };
215 };
216 
220 template<> struct MHO_MultiplyIdentity< int >
221 {
228  static inline int value() { return 1; };
229 };
230 
234 template<> struct MHO_MultiplyIdentity< short >
235 {
242  static inline short value() { return 1; };
243 };
244 
248 template<> struct MHO_MultiplyIdentity< unsigned int >
249 {
256  static inline unsigned int value() { return 1; };
257 };
258 
262 template<> struct MHO_MultiplyIdentity< std::size_t >
263 {
270  static inline std::size_t value() { return 1; };
271 };
272 
276 template<> struct MHO_MultiplyIdentity< float >
277 {
284  static inline float value() { return 1.0; };
285 };
286 
290 template<> struct MHO_MultiplyIdentity< double >
291 {
298  static inline double value() { return 1.0; };
299 };
300 
301 template<> struct MHO_MultiplyIdentity< long double >
302 {
309  static inline long double value() { return 1.0; };
310 };
311 
312 template<> struct MHO_MultiplyIdentity< std::complex< float > >
313 {
314  static inline std::complex< float > value() { return std::complex< float >(1.0, 0.0); };
315 };
316 
317 template<> struct MHO_MultiplyIdentity< std::complex< double > >
318 {
319  static inline std::complex< double > value() { return std::complex< double >(1.0, 0.0); };
320 };
321 
322 template<> struct MHO_MultiplyIdentity< std::complex< long double > >
323 {
324  static inline std::complex< long double > value() { return std::complex< long double >(1.0, 0.0); };
325 };
326 
327 //struct which implements operator as compound summation
328 template< typename XValueType > struct MHO_CompoundSum
329 {
330  inline void operator()(XValueType& a, const XValueType& b) { a += b; }
331 
333 };
334 
335 //struct which implements operator as compound multiplication
336 template< typename XValueType > struct MHO_CompoundMultiply
337 {
338  void operator()(XValueType& a, const XValueType& b) { a *= b; }
339 
341 };
342 
343 
344 }//end of namespace
345 
346 
347 #endif
Definition: MHO_ChannelLabeler.hh:17
Definition: MHO_CompoundReductions.hh:337
void operator()(XValueType &a, const XValueType &b)
Definition: MHO_CompoundReductions.hh:338
const XValueType identity
Definition: MHO_CompoundReductions.hh:340
Definition: MHO_CompoundReductions.hh:329
void operator()(XValueType &a, const XValueType &b)
Definition: MHO_CompoundReductions.hh:330
const XValueType identity
Definition: MHO_CompoundReductions.hh:332
static bool value()
Returns the identity for the multiplication operation.
Definition: MHO_CompoundReductions.hh:214
static double value()
Returns the identity for the multiplication operation.
Definition: MHO_CompoundReductions.hh:298
static float value()
Returns the identity for the multiplication operation.
Definition: MHO_CompoundReductions.hh:284
static int value()
Returns the identity for the multiplication operation.
Definition: MHO_CompoundReductions.hh:228
static long double value()
Returns the identity for the multiplication operation.
Definition: MHO_CompoundReductions.hh:309
static short value()
Returns the identity for the multiplication operation.
Definition: MHO_CompoundReductions.hh:242
static std::complex< double > value()
Definition: MHO_CompoundReductions.hh:319
static std::complex< float > value()
Definition: MHO_CompoundReductions.hh:314
static std::complex< long double > value()
Definition: MHO_CompoundReductions.hh:324
static std::size_t value()
Returns the identity for the multiplication operation.
Definition: MHO_CompoundReductions.hh:270
static unsigned int value()
Returns the identity for the multiplication operation.
Definition: MHO_CompoundReductions.hh:256
Class MHO_MultiplyIdentity.
Definition: MHO_CompoundReductions.hh:192
static XValueType value()
Returns the identity for the multiplication operation.
Definition: MHO_CompoundReductions.hh:199
static bool value()
Returns the identity for the sum operation.
Definition: MHO_CompoundReductions.hh:45
static double value()
Returns the identity for the sum operation.
Definition: MHO_CompoundReductions.hh:129
static float value()
Returns the identity for the sum operation.
Definition: MHO_CompoundReductions.hh:115
static int value()
Returns the identity for the sum operation.
Definition: MHO_CompoundReductions.hh:59
static long double value()
Returns the identity for the sum operation.
Definition: MHO_CompoundReductions.hh:143
static short value()
Returns the identity for the sum operation.
Definition: MHO_CompoundReductions.hh:73
static std::complex< double > value()
Copies non-active dimension values into index.
Definition: MHO_CompoundReductions.hh:171
static std::complex< float > value()
Copies non-active dimension values into index.
Definition: MHO_CompoundReductions.hh:157
static std::complex< long double > value()
Copies non-active dimension values into index.
Definition: MHO_CompoundReductions.hh:185
static std::size_t value()
Returns the identity for the sum operation.
Definition: MHO_CompoundReductions.hh:101
static unsigned int value()
Returns the identity for the sum operation.
Definition: MHO_CompoundReductions.hh:87
Class MHO_SumIdentity.
Definition: MHO_CompoundReductions.hh:23
static XValueType value()
Returns the identity for the sum operation.
Definition: MHO_CompoundReductions.hh:30