1#ifndef XPED_FUNCTIONS_H_
2#define XPED_FUNCTIONS_H_
8#include <boost/rational.hpp>
18 if(r.denominator() == 1) {
52template <
typename Symmetry>
56 for(
int q = 0; q < Symmetry::Nq; ++q) {
58 ss << util::print_frac_nice(boost::rational<int>(qnum[q] - 1, 2));
59 }
else if(Symmetry::kind()[q] ==
KIND::M) {
60 if(Symmetry::IS_MODULAR[q]) {
62 if(std::abs(qnum[q]) > std::abs(qnum[q] - Symmetry::MOD_N[q])) { q_nice = q_nice - Symmetry::MOD_N[q]; }
63 ss << util::print_frac_nice(boost::rational<int>(q_nice, 2));
65 ss << util::print_frac_nice(boost::rational<int>(qnum[q], 2));
67 }
else if(Symmetry::kind()[q] ==
KIND::Z2) {
68 std::string parity = util::constFct::posmod<2>(qnum[q] == 0) ?
"evn" :
"odd";
73 if(q != Symmetry::Nq - 1) { ss <<
","; }
75 if(Symmetry::Nq == 0) { ss <<
"()"; }
79template <
typename Scalar>
82 if(q % 2) {
return Scalar(-1.); }
91template <
typename Symmetry>
92std::vector<std::pair<typename Symmetry::qType, typename Symmetry::qType>>
93split(
const typename Symmetry::qType Q,
const std::vector<typename Symmetry::qType>& ql,
const std::vector<typename Symmetry::qType> qr)
95 std::vector<std::pair<typename Symmetry::qType, typename Symmetry::qType>> vout;
96 for(std::size_t q1 = 0; q1 < ql.size(); q1++)
97 for(std::size_t q2 = 0; q2 < qr.size(); q2++) {
98 auto Qs = Symmetry::reduceSilent(ql[q1], qr[q2]);
99 if(
auto it = std::find(Qs.begin(), Qs.end(), Q) != Qs.end()) { vout.push_back({ql[q1], qr[q2]}); }
104template <
typename Symmetry>
105std::vector<std::pair<std::size_t, std::size_t>>
106split(
const typename Symmetry::qType Q,
const std::vector<typename Symmetry::qType>& ql,
const std::vector<typename Symmetry::qType> qr)
108 std::vector<std::pair<std::size_t, std::size_t>> vout;
109 for(std::size_t q1 = 0; q1 < ql.size(); q1++)
110 for(std::size_t q2 = 0; q2 < qr.size(); q2++) {
111 auto Qs = Symmetry::reduceSilent(ql[q1], qr[q2]);
112 if(
auto it = std::find(Qs.begin(), Qs.end(), Q) != Qs.end()) { vout.push_back({q1, q2}); }
132inline void initialize(
int maxJ = 1, std::string f_3j =
"", std::string f_6j =
"", std::string f_9j =
"")
138#ifdef USE_WIG_SU2_COEFFS
139 wig_table_init(2 * maxJ, 9);
140 wig_temp_init(2 * maxJ);
143#ifdef USE_FAST_WIG_SU2_COEFFS
144 fastwigxj_load(f_3j.c_str(), 3, NULL);
145 fastwigxj_load(f_6j.c_str(), 6, NULL);
146 fastwigxj_load(f_9j.c_str(), 9, NULL);
148 wig_table_init(2 * maxJ, 9);
149 wig_temp_init(2 * maxJ);
155 std::ignore = PRINT_STATS;
156#ifdef USE_WIG_SU2_COEFFS
161#ifdef USE_FAST_WIG_SU2_COEFFS
163 std::cout << std::endl;
164 fastwigxj_print_stats();
178template <
typename Symmetry>
182 for(
size_t q = 0; q < Symmetry::Nq; ++q) {
187 out[q] = qin[q] / number_cells;
189 out[q] = qin[q] * number_cells;
KIND
Definition: functions.hpp:32
@ FN
Definition: functions.hpp:38
@ Ndn
Definition: functions.hpp:41
@ M
Definition: functions.hpp:39
@ T
Definition: functions.hpp:35
@ FT
Definition: functions.hpp:36
@ N
Definition: functions.hpp:37
@ S
Definition: functions.hpp:33
@ Z2
Definition: functions.hpp:42
@ Nup
Definition: functions.hpp:40
@ Salt
Definition: functions.hpp:34
void initialize(int maxJ=1, std::string f_3j="", std::string f_6j="", std::string f_9j="")
Definition: functions.hpp:132
Scalar phase(int q)
Definition: functions.hpp:80
std::vector< std::pair< typename Symmetry::qType, typename Symmetry::qType > > split(const typename Symmetry::qType Q, const std::vector< typename Symmetry::qType > &ql, const std::vector< typename Symmetry::qType > qr)
Definition: functions.hpp:93
std::string format(qarray< Symmetry::Nq > qnum)
Definition: functions.hpp:53
void finalize(bool PRINT_STATS=false)
Definition: functions.hpp:153
std::string print_frac_nice(boost::rational< int > r)
Definition: functions.hpp:15
qarray< Symmetry::Nq > adjustQN(const qarray< Symmetry::Nq > &qin, const size_t number_cells, bool BACK=false)
Definition: functions.hpp:179
Definition: qarray.hpp:30