Xped
Loading...
Searching...
No Matches
SymBase.hpp
Go to the documentation of this file.
1#ifndef SYM_BASE_H_
2#define SYM_BASE_H_
3
4#include <cmath>
5#include <set>
6#include <unordered_set>
7
8namespace Xped::Sym {
9template <typename Derived>
10struct SymTraits;
11
12template <typename Derived>
13struct SymBase
14{
17
18 static std::vector<qType> reduceSilent(const qType& ql, const qType& qr) { return Derived::basis_combine(ql, qr); }
19
20 static std::vector<qType> reduceSilent(const std::vector<qType>& ql, const qType& qr)
21 {
22 std::vector<qType> vout;
23 for(const auto& q : ql) {
24 for(const auto& qmerge : Derived::basis_combine(q, qr)) { vout.push_back(qmerge); }
25 }
26 return vout;
27 }
28
29 static std::set<qType> reduceSilent(const std::vector<qType>& ql, const std::vector<qType>& qr)
30 {
31 std::set<qType> vout;
32 for(const auto& q : ql) {
33 for(const auto& p : qr) {
34 for(const auto& qmerge : Derived::basis_combine(q, p)) { vout.insert(qmerge); }
35 }
36 }
37 return vout;
38 }
39
40 static std::vector<qType> reduceSilent(const qType& ql, const qType& qm, const qType& qr)
41 {
42 auto qtmp = Derived::basis_combine(ql, qm);
43 return reduceSilent(qtmp, qr);
44 }
45
46 static std::set<qType> reduceSilent(const std::set<qType>& ql, const std::vector<qType>& qr)
47 {
48 std::set<qType> out;
49 for(const auto q : ql) {
50 for(const auto& p : qr) {
51 for(const auto qp : Derived::basis_combine(q, p)) { out.insert(qp); }
52 }
53 }
54 return out;
55 }
56
57 static std::set<qType> reduceSilent(const std::unordered_set<qType>& ql, const std::vector<qType>& qr)
58 {
59 std::set<qType> out;
60 for(const auto q : ql) {
61 for(const auto& p : qr) {
62 for(const auto qp : Derived::basis_combine(q, p)) { out.insert(qp); }
63 }
64 }
65 return out;
66 }
67
68 static Scalar coeff_FS(const qType& q)
69 {
70 return std::signbit(Derived::coeff_recouple(q, Derived::conj(q), q, q, Derived::qvacuum(), Derived::qvacuum())) ? Scalar(-1) : Scalar(1.);
71 }
72
73 static Scalar coeff_turn(const qType& ql, const qType& qr, const qType& qf)
74 {
75 return std::sqrt(Derived::degeneracy(qr)) * Derived::coeff_recouple(ql, qr, Derived::conj(qr), ql, qf, Derived::qvacuum());
76 }
77
78 template <std::size_t M>
79 static bool compare(const std::array<qType, M>& q1, const std::array<qType, M>& q2)
80 {
81 for(std::size_t m = 0; m < M; m++) {
82 if(q1[m] > q2[m]) {
83 return false;
84 } else if(q1[m] < q2[m]) {
85 return true;
86 }
87 }
88 return false;
89 }
90
91 static bool compare(const qType& q1, const qType& q2) { return q1 < q2; }
92
93 static bool triangle(const qType& q1, const qType& q2, const qType& q3)
94 {
95 auto q12 = reduceSilent(q1, q2);
96 for(const auto& q : q12) {
97 if(q == q3) { return true; }
98 }
99 return false;
100 }
101};
102
103} // namespace Xped::Sym
104#endif
Definition: CombSym.hpp:8
@ M
Definition: functions.hpp:39
Definition: SymBase.hpp:14
static std::vector< qType > reduceSilent(const qType &ql, const qType &qr)
Definition: SymBase.hpp:18
static std::vector< qType > reduceSilent(const qType &ql, const qType &qm, const qType &qr)
Definition: SymBase.hpp:40
static Scalar coeff_FS(const qType &q)
Definition: SymBase.hpp:68
SymTraits< Derived >::qType qType
Definition: SymBase.hpp:15
static bool triangle(const qType &q1, const qType &q2, const qType &q3)
Definition: SymBase.hpp:93
static std::set< qType > reduceSilent(const std::set< qType > &ql, const std::vector< qType > &qr)
Definition: SymBase.hpp:46
static std::set< qType > reduceSilent(const std::vector< qType > &ql, const std::vector< qType > &qr)
Definition: SymBase.hpp:29
static bool compare(const qType &q1, const qType &q2)
Definition: SymBase.hpp:91
static std::vector< qType > reduceSilent(const std::vector< qType > &ql, const qType &qr)
Definition: SymBase.hpp:20
SymTraits< Derived >::Scalar Scalar
Definition: SymBase.hpp:16
static Scalar coeff_turn(const qType &ql, const qType &qr, const qType &qf)
Definition: SymBase.hpp:73
static bool compare(const std::array< qType, M > &q1, const std::array< qType, M > &q2)
Definition: SymBase.hpp:79
static std::set< qType > reduceSilent(const std::unordered_set< qType > &ql, const std::vector< qType > &qr)
Definition: SymBase.hpp:57
Definition: SymBase.hpp:10