VMPS++
Loading...
Searching...
No Matches
SU2Wrappers.h
Go to the documentation of this file.
1#ifndef SU2WRAPPERS_H_
2#define SU2WRAPPERS_H_
3
4// As the default libraries for the 3nj-symbols, we use the GSL (Gnu scientific library):
5#if !defined USE_WIG_SU2_COEFFS && !defined USE_WIG_SU2_COEFFS && !defined USE_FAST_WIG_SU2_COEFFS
6#define USE_GSL_SU2_COEFFS 1
7#endif
8
10#ifdef USE_GSL_SU2_COEFFS
11#include <gsl/gsl_sf_coupling.h>
12#pragma message("Using GSL library for 3nj-symbols.")
13#endif
14
15#ifdef USE_WIG_SU2_COEFFS
16#include "wigxjpf.h"
17#pragma message("Using WIGXJPF library for 3nj-symbols.")
18#endif
19
20#ifdef USE_FAST_WIG_SU2_COEFFS
21#include "fastwigxj.h"
22#include "wigxjpf.h"
23#pragma message("Using FASTWIGXJ library for 3nj-symbols.")
24#endif
26
27#include "DmrgExternal.h"
28
71#ifdef USE_GSL_SU2_COEFFS
72inline double coupl_9j_base(const int q1, const int q2, const int q3,
73 const int q4, const int q5, const int q6,
74 const int q7, const int q8, const int q9)
75{
76 return gsl_sf_coupling_9j(q1-1, q2-1, q3-1,
77 q4-1, q5-1, q6-1,
78 q7-1, q8-1, q9-1);
79}
80
81inline double coupl_6j_base (const int q1, const int q2, const int q3,
82 const int q4, const int q5, const int q6)
83{
84 return gsl_sf_coupling_6j(q1-1, q2-1, q3-1,
85 q4-1, q5-1, q6-1);
86}
87
88inline double coupl_3j_base (const int q1 , const int q2 , const int q3,
89 const int q1_z, const int q2_z, const int q3_z)
90{
91 return gsl_sf_coupling_3j(q1-1, q2-1, q3-1,
92 q1_z, q2_z, q3_z);
93}
94#endif //USE_GSL_SU2_COEFFS
95
96#ifdef USE_WIG_SU2_COEFFS
97inline double coupl_9j_base(const int q1, const int q2, const int q3,
98 const int q4, const int q5, const int q6,
99 const int q7, const int q8, const int q9)
100{
101 return wig9jj(q1-1, q2-1, q3-1,
102 q4-1, q5-1, q6-1,
103 q7-1, q8-1, q9-1);
104}
105
106inline double coupl_6j_base (const int q1, const int q2, const int q3,
107 const int q4, const int q5, const int q6)
108{
109 return wig6jj(q1-1, q2-1, q3-1,
110 q4-1, q5-1, q6-1);
111}
112
113inline double coupl_3j_base (const int q1 , const int q2 , const int q3,
114 const int q1_z, const int q2_z, const int q3_z)
115{
116 return wig3jj(q1-1, q2-1, q3-1,
117 q1_z, q2_z, q3_z);
118}
119#endif //USE_WIG_SU2_COEFFS
120
123#ifdef USE_FAST_WIG_SU2_COEFFS
124inline double coupl_9j_base(const int q1, const int q2, const int q3,
125 const int q4, const int q5, const int q6,
126 const int q7, const int q8, const int q9)
127{
128 return fw9jja(q1-1, q2-1, q3-1,
129 q4-1, q5-1, q6-1,
130 q7-1, q8-1, q9-1);
131}
132
133inline double coupl_6j_base (const int q1, const int q2, const int q3,
134 const int q4, const int q5, const int q6)
135{
136 return fw6jja(q1-1, q2-1, q3-1,
137 q4-1, q5-1, q6-1);
138}
139
140inline double coupl_3j_base (const int q1 , const int q2 , const int q3,
141 const int q1_z, const int q2_z, const int q3_z)
142{
143 return fw3jja(q1-1, q2-1, q3-1,
144 q1_z, q2_z);
145}
146#endif //USE_FAST_WIG_SU2_COEFFS
147
148#ifdef OWN_HASH_CGC
149#ifdef _OPENMP
150assert(omp_get_max_threads() == 1 and "Hashing the cgcs is not treadsafe!");
151#endif
152
153std::unordered_map<std::array<int,9>,double > Table9j;
154std::unordered_map<std::array<int,6>,double > Table6j;
155
156double coupling_9j (const int q1, const int q2, const int q3,
157 const int q4, const int q5, const int q6,
158 const int q7, const int q8, const int q9)
159{
160 auto it = Table9j.find(std::array<int,9>{q1,q2,q3,q4,q5,q6,q7,q8,q9});
161
162 if (it != Table9j.end())
163 {
164 return Table9j[std::array<int,9>{q1,q2,q3,q4,q5,q6,q7,q8,q9}];
165 }
166 else
167 {
168 double out = coupl_9j_base(q1,q2,q3,
169 q4,q5,q6,
170 q7,q8,q9);
171 Table9j[std::array<int,9>{q1,q2,q3,q4,q5,q6,q7,q8,q9}] = out;
172 return out;
173 }
174}
175
176double coupling_6j (const int q1, const int q2, const int q3,
177 const int q4, const int q5, const int q6)
178{
179 auto it = Table6j.find(std::array<int,6>{q1,q2,q3,q4,q5,q6});
180 if (it != Table6j.end())
181 {
182 return Table6j[std::array<int,6>{q1,q2,q3,q4,q5,q6}];
183 }
184 else
185 {
186 double out = coupl_6j_base(q1,q2,q3,
187 q4,q5,q6);
188 Table6j[std::array<int,6>{q1,q2,q3,q4,q5,q6}] = out;
189 return out;
190 }
191}
192
193inline double coupling_3j (const int q1 , const int q2 , const int q3,
194 const int q1_z, const int q2_z, const int q3_z)
195{
196 return coupl_3j_base(q1 ,q2 ,q3,
197 q1_z,q2_z,q3_z);
198}
199
200#else //no OWN_HASH_CGC
201inline double coupling_9j (const int q1, const int q2, const int q3,
202 const int q4, const int q5, const int q6,
203 const int q7, const int q8, const int q9)
204{
205 return coupl_9j_base(q1,q2,q3,
206 q4,q5,q6,
207 q7,q8,q9);
208}
209
210inline double coupling_6j (const int q1, const int q2, const int q3,
211 const int q4, const int q5, const int q6)
212{
213 return coupl_6j_base(q1,q2,q3,
214 q4,q5,q6);
215}
216
217inline double coupling_3j (const int q1 , const int q2 , const int q3,
218 const int q1_z, const int q2_z, const int q3_z)
219{
220 return coupl_3j_base(q1 ,q2 ,q3,
221 q1_z,q2_z,q3_z);
222}
223
224#endif //OWN_HASH_CGC
225
226#endif
double coupl_6j_base(const int q1, const int q2, const int q3, const int q4, const int q5, const int q6)
Definition: SU2Wrappers.h:81
double coupl_3j_base(const int q1, const int q2, const int q3, const int q1_z, const int q2_z, const int q3_z)
Definition: SU2Wrappers.h:88
double coupling_9j(const int q1, const int q2, const int q3, const int q4, const int q5, const int q6, const int q7, const int q8, const int q9)
Definition: SU2Wrappers.h:201
double coupling_3j(const int q1, const int q2, const int q3, const int q1_z, const int q2_z, const int q3_z)
Definition: SU2Wrappers.h:217
double coupling_6j(const int q1, const int q2, const int q3, const int q4, const int q5, const int q6)
Definition: SU2Wrappers.h:210
double coupl_9j_base(const int q1, const int q2, const int q3, const int q4, const int q5, const int q6, const int q7, const int q8, const int q9)
Definition: SU2Wrappers.h:72