OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
PairConditions.h
Go to the documentation of this file.
1 #ifndef PAIR_CONDITIONS_H
2 #define PAIR_CONDITIONS_H
3 
4 #include "Region/NDRegion.h"
5 
6 #include <limits>
7 
8 template<class T, unsigned Dim>
10 {
11 public:
13  template<class V>
14  bool operator()(const V &a, const V &b) const
15  {
16  return true;
17  }
18 
19  T getRange(unsigned dim) const { return std::numeric_limits<T>::max(); }
20 };
21 
22 template<class T, unsigned Dim>
24 {
25 public:
27  { }
28 
29  template<class V>
30  bool operator()(const V &a, const V &b) const
31  {
32  T sqr = 0;
33  for(unsigned int d = 0;d<Dim;++d)
34  {
35  sqr += (a[d]-b[d])*(a[d]-b[d]);
36  }
37  return sqr <= sqradius;
38  }
39 
40  //periodic version of radius condition
41  template<class V, class Vec>
42  bool operator()(const V &a, const V &b, const Vec &period) const
43  {
44  T sqr = 0;
45  //std::cout << "checking radius condition for " << a << " and " << b << std::endl;
46  for(unsigned int d = 0;d<Dim;++d)
47  {
48  //sqr += (std::fmod((a[d]-b[d]+period[d]),period[d])*std::fmod((a[d]-b[d]+period[d]),period[d]));
49  sqr += (a[d]-b[d])*(a[d]-b[d]);
50  }
51  /*
52  if (sqr > sqradius)
53  std::cout << "rejected with dist = " << sqrt(sqr) << std::endl;
54  else
55  std::cout << "accepted with dist = " << sqrt(sqr) << std::endl;
56  */
57  return sqr <= sqradius;
58  }
59 
60 
61  T getRange(unsigned d) const { return radius; }
62 private:
64 };
65 
66 template<class T, unsigned Dim>
68 {
69 public:
70  BoxCondition(T b[Dim]) : box(b)
71  { }
72 
73  template<class V>
74  bool operator()(const V &a, const V &b) const
75  {
76  for(unsigned int d = 0;d<Dim;++d)
77  {
78  T diff = a[d]-b[d];
79  if(diff > box[d] || diff < -box[d])
80  return false;
81  }
82  return true;
83  }
84 
85  T getRange(unsigned d) const { return box[d]; }
86 private:
87  T box[Dim];
88 };
89 
90 #endif
Definition: rbendmap.h:8
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Definition: ReductionLoc.h:123
T getRange(unsigned d) const
bool operator()(const V &a, const V &b) const
T getRange(unsigned dim) const
BoxCondition(T b[Dim])
T getRange(unsigned d) const
bool operator()(const V &a, const V &b, const Vec &period) const
bool operator()(const V &a, const V &b) const
bool operator()(const V &a, const V &b) const
const unsigned Dim