LIBINT 2.9.0
prefactors.h
1/*
2 * Copyright (C) 2004-2024 Edward F. Valeev
3 *
4 * This file is part of Libint compiler.
5 *
6 * Libint compiler is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Libint compiler is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Libint compiler. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#ifndef _libint2_src_bin_libint_prefactors_h_
22#define _libint2_src_bin_libint_prefactors_h_
23
24#include <bfset.h>
25#include <entity.h>
26#include <singl_stack.h>
27#include <smart_ptr.h>
28
29#include <cstring>
30
31#define CTIMEENTITIES_SINGLETONS 1
32
33namespace libint2 {
34
42 public:
43 Prefactors();
45
48
49 static const unsigned int NMAX = 200;
50 static const unsigned int np = 2;
51 static const unsigned int nfunc_per_part = 1;
52
57 std::shared_ptr<rdouble> vX_Y[np];
59 std::shared_ptr<rdouble> X_Y[np][3];
60
65 std::shared_ptr<rdouble> vY_X[np];
67 std::shared_ptr<rdouble> Y_X[np][3];
68
76 std::shared_ptr<rdouble> vXY_X[np][2];
78 std::shared_ptr<rdouble> XY_X[np][2][3];
83 std::shared_ptr<rdouble> vW_XY[np];
85 std::shared_ptr<rdouble> W_XY[np][3];
86
90 std::shared_ptr<rdouble> zeta[np][2];
94 std::shared_ptr<rdouble> zeta2[np][2];
95
101 std::shared_ptr<rdouble> alpha12[np];
103 std::shared_ptr<rdouble> rho;
105 std::shared_ptr<rdouble> one_o_2alpha12[np];
107 std::shared_ptr<rdouble> rho_o_alpha12[np];
109 std::shared_ptr<rdouble> one_o_2alphasum;
110
116 std::shared_ptr<rdouble> TwoPRepITR_vpfac0[np];
118 std::shared_ptr<rdouble> TwoPRepITR_pfac0[np][3];
120 std::shared_ptr<rdouble> TwoPRepITR_pfac1[np];
123
128 std::shared_ptr<rdouble> R12kG12VRR_vpfac0[np];
130 std::shared_ptr<rdouble> R12kG12VRR_pfac0[np][3];
132 std::shared_ptr<rdouble> R12kG12VRR_pfac1[np];
134 std::shared_ptr<rdouble> R12kG12VRR_pfac2;
136 std::shared_ptr<rdouble> R12kG12VRR_pfac3[np];
138 std::shared_ptr<rdouble> R12kG12VRR_vpfac4[np];
140 std::shared_ptr<rdouble> R12kG12VRR_pfac4[np][3];
141
146 std::shared_ptr<rdouble> Overlap00_1d[3];
147
148#if CTIMEENTITIES_SINGLETONS
150 std::shared_ptr<cdouble> N_i[NMAX];
151
152 std::shared_ptr<cdouble> Cdouble(double a);
153#endif
154
155 private:
156};
157
158extern Prefactors prefactors;
159
160namespace prefactor {
161
162template <typename T>
164 typedef SingletonStack<RTimeEntity<T>, typename RTimeEntity<T>::key_type>
166 static std::shared_ptr<ManagerType>& Manager() {
167 if (manager_ == 0) {
168 manager_ =
169 std::shared_ptr<ManagerType>(new ManagerType(&RTimeEntity<T>::key));
170 }
171 return manager_;
172 }
173 static std::shared_ptr<ManagerType> manager_;
174};
175template <typename T>
176std::shared_ptr<typename RTimeSingletons<T>::ManagerType>
178
179#if CTIMEENTITIES_SINGLETONS
180template <typename T>
183 static std::shared_ptr<ManagerType>& Manager() {
184 if (manager_ == 0) {
185 manager_ =
186 std::shared_ptr<ManagerType>(new ManagerType(&CTimeEntity<T>::value));
187 }
188 return manager_;
189 }
190 static std::shared_ptr<ManagerType> manager_;
191};
192template <typename T>
193std::shared_ptr<typename CTimeSingletons<T>::ManagerType>
195#endif
196
198template <typename T,
199 typename = typename std::enable_if<std::is_integral<T>::value>::type>
200std::shared_ptr<CTimeEntity<double> > Scalar(T a) {
201 typedef CTimeEntity<double> return_type;
202 std::shared_ptr<return_type> tmp(new return_type(a));
203#if CTIMEENTITIES_SINGLETONS
204 typedef CTimeSingletons<double> singletons_type;
205 typedef typename singletons_type::ManagerType ManagerType;
206 const typename ManagerType::value_type& result =
207 singletons_type::Manager()->find(tmp);
208 return result.second;
209#else
210 return tmp;
211#endif
212}
214inline std::shared_ptr<CTimeEntity<double> > Scalar(double a) {
215 typedef CTimeEntity<double> return_type;
216 std::shared_ptr<return_type> tmp(new return_type(a));
217#if CTIMEENTITIES_SINGLETONS
218 typedef CTimeSingletons<double> singletons_type;
219 typedef typename singletons_type::ManagerType ManagerType;
220 const typename ManagerType::value_type& result =
221 singletons_type::Manager()->find(tmp);
222 return result.second;
223#else
224 return tmp;
225#endif
226}
228// inline std::shared_ptr< RTimeEntity<double> > Scalar(const char* id) {
229// typedef double T;
230// typedef RTimeEntity<T> return_type;
231// typedef RTimeSingletons<T> singletons_type;
232// typedef singletons_type::ManagerType ManagerType;
233// std::shared_ptr<return_type> tmp(new return_type(id));
234// const ManagerType::value_type& result =
235// singletons_type::Manager()->find(tmp); return result.second;
236// }
238inline std::shared_ptr<RTimeEntity<double> > Scalar(const std::string& id) {
239 typedef double T;
240 typedef RTimeEntity<T> return_type;
241 typedef RTimeSingletons<T> singletons_type;
242 typedef singletons_type::ManagerType ManagerType;
243 std::shared_ptr<return_type> tmp(new return_type(id));
244 const ManagerType::value_type& result = singletons_type::Manager()->find(tmp);
245 return result.second;
246}
247
249template <class T>
251 public:
252 RTimeVector3(const char* id) : id_(id) {}
253 RTimeVector3(const std::string& id) : id_(id) {}
254 std::shared_ptr<RTimeEntity<T> > operator[](unsigned int xyz) {
255 return Scalar(id_ + "_" + dirchar[xyz]);
256 }
257
258 private:
259 static const char* dirchar;
260 std::string id_;
261};
262template <class T>
263const char* RTimeVector3<T>::dirchar(strdup("xyz"));
264
266template <class T>
268 public:
269 CTimeVector3(const T* val) {
270 for (int xyz = 0; xyz < 3; ++xyz) val_[xyz] = val[xyz];
271 }
272 std::shared_ptr<CTimeEntity<T> > operator[](unsigned int xyz) {
273 return Scalar(val_[xyz]);
274 }
275
276 private:
277 T val_[3];
278};
279
281#if 0 // these do not get resolved correctly by icpc 12 on OS X
282 template <class T = double> RTimeVector3<T> Vector(const char* id)
283 {
284 return RTimeVector3<T>(id);
285 }
287 template <class T = double> RTimeVector3<T> Vector(const std::string& id)
288 {
289 return RTimeVector3<T>(id);
290 }
292 template <class T = double> CTimeVector3<T> Vector(const T* a)
293 {
294 return CTimeVector3<T>(a);
295 }
296#endif
297inline RTimeVector3<double> Vector(const char* id) {
298 return RTimeVector3<double>(id);
299}
301inline CTimeVector3<double> Vector(const CGF& bf) {
302 double qn[3];
303 for (unsigned int xyz = 0; xyz < 3; ++xyz) qn[xyz] = bf.qn(xyz);
304 return CTimeVector3<double>(qn);
305}
307inline CTimeVector3<double> Vector(const OriginDerivative<3u>& dd) {
308 double d[3];
309 for (unsigned int xyz = 0; xyz < 3; ++xyz) d[xyz] = dd.d(xyz);
310 return CTimeVector3<double>(d);
311}
312
313} // namespace prefactor
314}; // namespace libint2
315
316#endif
CTimeEntity is an Entity of type T that exists at compile-time of the generated code (hence has a val...
Definition entity.h:220
Prefactors is a collection of common quantities which appear as prefactors in recurrence relations fo...
Definition prefactors.h:41
std::shared_ptr< cdouble > N_i[NMAX]
integers represented as doubles
Definition prefactors.h:150
std::shared_ptr< rdouble > one_o_2alpha12[np]
1/(2*alpha12)
Definition prefactors.h:105
std::shared_ptr< rdouble > zeta[np][2]
orbital exponents
Definition prefactors.h:90
std::shared_ptr< rdouble > vXY_X[np][2]
XY-X vectors: XY is either P or Q, X is either (A or B) or (C or D).
Definition prefactors.h:76
std::shared_ptr< rdouble > R12kG12VRR_pfac0[np][3]
cartesian components of pfac0 vector
Definition prefactors.h:130
std::shared_ptr< rdouble > XY_X[np][2][3]
cartesian components of vXY_X vector
Definition prefactors.h:78
std::shared_ptr< rdouble > X_Y[np][3]
Cartesian components of X-Y vectors.
Definition prefactors.h:59
std::shared_ptr< rdouble > W_XY[np][3]
cartesian components of W_XY vector
Definition prefactors.h:85
std::shared_ptr< rdouble > R12kG12VRR_vpfac0[np]
prefactor in front of (a-1 0|c0) is one_o_2alpha12[0] prefactor in front of (a0|c-1 0) is one_o_2alph...
Definition prefactors.h:128
std::shared_ptr< rdouble > rho
rho = zeta*eta/(zeta+eta)
Definition prefactors.h:103
std::shared_ptr< rdouble > zeta2[np][2]
squared orbital exponents
Definition prefactors.h:94
std::shared_ptr< rdouble > R12kG12VRR_pfac4[np][3]
cartesian components of pfac4 vector
Definition prefactors.h:140
std::shared_ptr< rdouble > rho_o_alpha12[np]
rho/alpha12
Definition prefactors.h:107
std::shared_ptr< rdouble > R12kG12VRR_pfac1[np]
prefactor in front of (a-1 0|c0)
Definition prefactors.h:132
std::shared_ptr< rdouble > vX_Y[np]
X-Y vectors, where X and Y are for the same particle: X_Y[0] = AB, X_Y[1] = CD, etc.
Definition prefactors.h:57
std::shared_ptr< rdouble > R12kG12VRR_pfac3[np]
prefactor in front of (|k-2|)
Definition prefactors.h:136
std::shared_ptr< rdouble > vY_X[np]
Y-X vectors, where X and Y are for the same particle: Y_X[0] = BA, Y_X[1] = DC, etc.
Definition prefactors.h:65
std::shared_ptr< rdouble > TwoPRepITR_vpfac0[np]
Prefactors for the ITR relation for TwoPRep integrals (a+1 0|c0):
Definition prefactors.h:116
std::shared_ptr< rdouble > TwoPRepITR_pfac1[np]
prefactor in front of (a0|c+1 0) = -alpha12[1]/alpha12[0]
Definition prefactors.h:120
std::shared_ptr< rdouble > Y_X[np][3]
Cartesian components of Y_X vectors.
Definition prefactors.h:67
std::shared_ptr< rdouble > vW_XY[np]
W-XY vectors: vW_XY[0] = W-P, vW_XY[1] = W-Q.
Definition prefactors.h:83
std::shared_ptr< rdouble > R12kG12VRR_vpfac4[np]
prefactor in front of (a0|k-2|c0)
Definition prefactors.h:138
std::shared_ptr< rdouble > alpha12[np]
alpha12[p] is the sum of exponents for particle p: alpha12[0] = zeta, alpha12[1] = eta.
Definition prefactors.h:101
std::shared_ptr< rdouble > Overlap00_1d[3]
Precomputed 1-d integrals.
Definition prefactors.h:146
std::shared_ptr< rdouble > TwoPRepITR_pfac0[np][3]
cartesian components of pfac0 vector
Definition prefactors.h:118
std::shared_ptr< rdouble > one_o_2alphasum
1/(2*(zeta+eta))
Definition prefactors.h:109
std::shared_ptr< rdouble > R12kG12VRR_pfac2
prefactor in front of (a0|c-1 0)
Definition prefactors.h:134
RTimeEntity is an Entity of type T that exists at runtime of the generated code (hence has no value k...
Definition entity.h:151
SingletonStack<T,KeyType> helps to implement Singleton-like objects of type T.
Definition singl_stack.h:45
auxiliary class that write expressions with compile-time cartesian vectors
Definition prefactors.h:267
auxiliary class that write expressions with runtime cartesian vectors
Definition prefactors.h:250
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24
Definition prefactors.h:181
Definition prefactors.h:163