Class documentation of Concepts

Loading...
Searching...
No Matches
symmetry.hh
Go to the documentation of this file.
1
7#ifndef symmetry_hh
8#define symmetry_hh
9
10#include "basics/typedefs.hh"
11#include "topology.hh"
12
13namespace concepts
14{
18 template<class T>
19 class Symmetry {
20 public:
23
26 };
27
35 template<>
36 class Symmetry<Edge> {
37 public:
39 Symmetry(const Z2 value) : value_(value) {};
41 Symmetry(const Symmetry<Edge>& other) {value_ = other.value_; };
43 void operator= (const Symmetry<Edge>& other) {this->value_ = other.value_; };
45 friend Symmetry<Edge> operator* (const Symmetry<Edge> & i, const Symmetry<Edge> & j)
46 {
47 return Symmetry<Edge>(i.value_ ^ j.value_);
48 }
51 {
52 if (this->value_ == 1)
53 return 1.0-x;
54 return x;
55 };
58 {
59 return evaluate(x);
60 }
61
62 protected:
63 Z2 value_;
64 };
65
75 template<>
76 class Symmetry<Quad> {
77 public:
79 Symmetry(const std::array<Z2, 3> value) : value_(value) {} ;
81 Symmetry(const Z2 ix, const Z2 iy, const Z2 ip)
82 {
83 value_[0] = ix;
84 value_[1] = iy;
85 value_[2] = ip;
86 };
88 Symmetry(const Symmetry<Quad>& other) {value_ = other.value_; };
90 void operator= (const Symmetry<Quad>& other) {this->value_ = other.value_; };
93 {
94 // Sy o Sp = Sp o Sx
95 // Sx o Sp = Sp o Sy
96 // Sy o Sx = Sx o Sy -> symmetries Sx and Sy can commute
97 Z2 ix = i.value_[0];
98 Z2 iy = i.value_[1];
99 Z2 ip = i.value_[2];
100 Z2 jx = j.value_[0];
101 Z2 jy = j.value_[1];
102 Z2 jp = j.value_[2];
103 if (jp == 1)
104 std::swap(ix,iy);
105 // in this case, it would return Symmetry(iy^jx, ix^jy, ip^jp);
106 return Symmetry(ix^jx, iy^jy, ip^jp);
107 }
110 {
111 Real x = p[0], y = p[1];
112 // Presence of the symmetry S_x
113 if (value_[0])
114 x = 1.0 - x;
115 // Presence of the symmetry S_y
116 if (value_[1])
117 y = 1.0 - y;
118 // Presence of the symmetry S_p
119 if (value_[2])
120 std::swap(x,y);
121 return Real2d(x,y);
122 };
125 {
126 Real x = p[0], y = p[1];
127 // Presence of the symmetry S_p
128 if (value_[2])
129 std::swap(x,y);
130 // Presence of the symmetry S_y
131 if (value_[1])
132 y = 1.0 - y;
133 // Presence of the symmetry S_x
134 if (value_[0])
135 x = 1.0 - x;
136 return Real2d(x,y);
137 };
138 protected:
139 std::array<Z2, 3> value_;
140 };
141
142
156 Real3d evaluatepermutation(const Real3d p, const int index);
157
158}
159
160#endif // symmetry_hh
Real evaluateInverse(const Real x)
Evaluation of the inverse.
Definition symmetry.hh:57
Symmetry(const Symmetry< Edge > &other)
Copy constructor.
Definition symmetry.hh:41
Symmetry(const Z2 value)
Constructor with given value.
Definition symmetry.hh:39
Real evaluate(const Real x)
Evaluation.
Definition symmetry.hh:50
Symmetry(const Z2 ix, const Z2 iy, const Z2 ip)
Constructor with given indexes.
Definition symmetry.hh:81
Symmetry(const std::array< Z2, 3 > value)
Constructor with given value.
Definition symmetry.hh:79
Real2d evaluate(const Real2d p)
Evaluation.
Definition symmetry.hh:109
Real2d evaluateInverse(const Real2d p)
Evaluation of the inverse.
Definition symmetry.hh:124
friend Symmetry< Quad > operator*(const Symmetry< Quad > &i, const Symmetry< Quad > &j)
Composition operator.
Definition symmetry.hh:92
Symmetry(const Symmetry< Quad > &other)
Copy constructor.
Definition symmetry.hh:88
~Symmetry()
Default destructor.
Symmetry()
Default constructor with no argument given.
double Real
Definition typedefs.hh:39
Real3d evaluatepermutation(const Real3d p, const int index)
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320