LIBINT  2.1.0-stable
prefactors.h
1 /*
2  * This file is a part of Libint.
3  * Copyright (C) 2004-2014 Edward F. Valeev
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see http://www.gnu.org/licenses/.
17  *
18  */
19 
20 #ifndef _libint2_src_bin_libint_prefactors_h_
21 #define _libint2_src_bin_libint_prefactors_h_
22 
23 #include <cstring>
24 #include <smart_ptr.h>
25 #include <entity.h>
26 #include <bfset.h>
27 #include <singl_stack.h>
28 
29 #define CTIMEENTITIES_SINGLETONS 1
30 
31 namespace libint2 {
32 
39  class Prefactors {
40  public:
41  Prefactors();
42  ~Prefactors();
43 
46 
47  static const unsigned int NMAX = 200;
48  static const unsigned int np = 2;
49  static const unsigned int nfunc_per_part = 1;
50 
55  SafePtr<rdouble> vX_Y[np];
57  SafePtr<rdouble> X_Y[np][3];
58 
63  SafePtr<rdouble> vY_X[np];
65  SafePtr<rdouble> Y_X[np][3];
66 
74  SafePtr<rdouble> vXY_X[np][2];
76  SafePtr<rdouble> XY_X[np][2][3];
81  SafePtr<rdouble> vW_XY[np];
83  SafePtr<rdouble> W_XY[np][3];
84 
88  SafePtr<rdouble> zeta[np][2];
92  SafePtr<rdouble> zeta2[np][2];
93 
99  SafePtr<rdouble> alpha12[np];
101  SafePtr<rdouble> rho;
103  SafePtr<rdouble> one_o_2alpha12[np];
105  SafePtr<rdouble> rho_o_alpha12[np];
107  SafePtr<rdouble> one_o_2alphasum;
108 
112  SafePtr<rdouble> TwoPRepITR_vpfac0[np];
115  SafePtr<rdouble> TwoPRepITR_pfac0[np][3];
117  SafePtr<rdouble> TwoPRepITR_pfac1[np];
120 
124  SafePtr<rdouble> R12kG12VRR_vpfac0[np];
127  SafePtr<rdouble> R12kG12VRR_pfac0[np][3];
129  SafePtr<rdouble> R12kG12VRR_pfac1[np];
131  SafePtr<rdouble> R12kG12VRR_pfac2;
133  SafePtr<rdouble> R12kG12VRR_pfac3[np];
135  SafePtr<rdouble> R12kG12VRR_vpfac4[np];
137  SafePtr<rdouble> R12kG12VRR_pfac4[np][3];
138 
142  SafePtr<rdouble> Overlap00_1d[3];
144 
145 
146 #if CTIMEENTITIES_SINGLETONS
147  SafePtr<cdouble> N_i[NMAX];
149 
150  SafePtr<cdouble> Cdouble(double a);
151 #endif
152 
153  private:
154 
155  };
156 
157  extern Prefactors prefactors;
158 
159  namespace prefactor {
160 
161  template <typename T> struct RTimeSingletons {
162  typedef SingletonStack<RTimeEntity<T>,typename RTimeEntity<T>::key_type> ManagerType;
163  static SafePtr<ManagerType>& Manager() {
164  if (manager_ == 0) {
165  manager_ = SafePtr<ManagerType>(new ManagerType(&RTimeEntity<T>::key));
166  }
167  return manager_;
168  }
169  static SafePtr<ManagerType> manager_;
170  };
171  template <typename T> SafePtr<typename RTimeSingletons<T>::ManagerType> RTimeSingletons<T>::manager_;
172 
173 #if CTIMEENTITIES_SINGLETONS
174  template <typename T> struct CTimeSingletons {
176  static SafePtr<ManagerType>& Manager() {
177  if (manager_ == 0) {
178  manager_ = SafePtr<ManagerType>(new ManagerType(&CTimeEntity<T>::value));
179  }
180  return manager_;
181  }
182  static SafePtr<ManagerType> manager_;
183  };
184  template <typename T> SafePtr<typename CTimeSingletons<T>::ManagerType> CTimeSingletons<T>::manager_;
185 #endif
186 
188  template <typename T, typename = typename std::enable_if<std::is_integral<T>::value>::type>
189  SafePtr< CTimeEntity<double> > Scalar(T a) {
190  typedef CTimeEntity<double> return_type;
191  SafePtr<return_type> tmp(new return_type(a));
192 #if CTIMEENTITIES_SINGLETONS
193  typedef CTimeSingletons<double> singletons_type;
194  typedef typename singletons_type::ManagerType ManagerType;
195  const typename ManagerType::value_type& result = singletons_type::Manager()->find(tmp);
196  return result.second;
197 #else
198  return tmp;
199 #endif
200  }
202  inline SafePtr< CTimeEntity<double> > Scalar(double a) {
203  typedef CTimeEntity<double> return_type;
204  SafePtr<return_type> tmp(new return_type(a));
205 #if CTIMEENTITIES_SINGLETONS
206  typedef CTimeSingletons<double> singletons_type;
207  typedef typename singletons_type::ManagerType ManagerType;
208  const typename ManagerType::value_type& result = singletons_type::Manager()->find(tmp);
209  return result.second;
210 #else
211  return tmp;
212 #endif
213  }
215 // inline SafePtr< RTimeEntity<double> > Scalar(const char* id) {
216 // typedef double T;
217 // typedef RTimeEntity<T> return_type;
218 // typedef RTimeSingletons<T> singletons_type;
219 // typedef singletons_type::ManagerType ManagerType;
220 // SafePtr<return_type> tmp(new return_type(id));
221 // const ManagerType::value_type& result = singletons_type::Manager()->find(tmp);
222 // return result.second;
223 // }
225  inline SafePtr< RTimeEntity<double> > Scalar(const std::string& id) {
226  typedef double T;
227  typedef RTimeEntity<T> return_type;
228  typedef RTimeSingletons<T> singletons_type;
229  typedef singletons_type::ManagerType ManagerType;
230  SafePtr<return_type> tmp(new return_type(id));
231  const ManagerType::value_type& result = singletons_type::Manager()->find(tmp);
232  return result.second;
233  }
234 
236  template <class T> class RTimeVector3 {
237  public:
238  RTimeVector3(const char* id) : id_(id) { }
239  RTimeVector3(const std::string& id) : id_(id) { }
240  SafePtr< RTimeEntity<T> > operator[](unsigned int xyz) {
241  return Scalar(id_ + "_" + dirchar[xyz]);
242  }
243  private:
244  static const char* dirchar;
245  std::string id_;
246  };
247  template <class T> const char* RTimeVector3<T>::dirchar(strdup("xyz"));
248 
250  template <class T> class CTimeVector3 {
251  public:
252  CTimeVector3(const T* val) {
253  for(int xyz=0; xyz<3; ++xyz) val_[xyz] = val[xyz];
254  }
255  SafePtr< CTimeEntity<T> > operator[](unsigned int xyz) {
256  return Scalar(val_[xyz]);
257  }
258  private:
259  T val_[3];
260  };
261 
263 #if 0 // these do not get resolved correctly by icpc 12 on OS X
264  template <class T = double> RTimeVector3<T> Vector(const char* id)
265  {
266  return RTimeVector3<T>(id);
267  }
269  template <class T = double> RTimeVector3<T> Vector(const std::string& id)
270  {
271  return RTimeVector3<T>(id);
272  }
274  template <class T = double> CTimeVector3<T> Vector(const T* a)
275  {
276  return CTimeVector3<T>(a);
277  }
278 #endif
279  inline RTimeVector3<double> Vector(const char* id)
280  {
281  return RTimeVector3<double>(id);
282  }
284  inline CTimeVector3<double> Vector(const CGF& bf)
285  {
286  double qn[3]; for(unsigned int xyz=0; xyz<3; ++xyz) qn[xyz] = bf.qn(xyz);
287  return CTimeVector3<double>(qn);
288  }
290  inline CTimeVector3<double> Vector(const OriginDerivative<3u>& dd)
291  {
292  double d[3]; for(unsigned int xyz=0; xyz<3; ++xyz) d[xyz] = dd.d(xyz);
293  return CTimeVector3<double>(d);
294  }
295 
296  }
297 };
298 
299 #endif
300 
Definition: prefactors.h:161
SafePtr< rdouble > TwoPRepITR_vpfac0[np]
Prefactors for the ITR relation for TwoPRep integrals (a+1 0|c0):
Definition: prefactors.h:113
SingletonStack<T,KeyType> helps to implement Singleton-like objects of type T.
Definition: singl_stack.h:42
SafePtr< rdouble > R12kG12VRR_pfac2
prefactor in front of (a0|c-1 0)
Definition: prefactors.h:131
SafePtr< cdouble > N_i[NMAX]
integers represented as doubles
Definition: prefactors.h:148
auxiliary class that write expressions with runtime cartesian vectors
Definition: prefactors.h:236
SafePtr< 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:55
CTimeEntity is an Entity of type T that exists at compile-time of the generated code (hence has a val...
Definition: entity.h:183
SafePtr< rdouble > Y_X[np][3]
Cartesian components of Y_X vectors.
Definition: prefactors.h:65
SafePtr< rdouble > zeta2[np][2]
squared orbital exponents
Definition: prefactors.h:92
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:23
SafePtr< rdouble > XY_X[np][2][3]
cartesian components of vXY_X vector
Definition: prefactors.h:76
Prefactors is a collection of common quantities which appear as prefactors in recurrence relations fo...
Definition: prefactors.h:39
SafePtr< rdouble > R12kG12VRR_pfac4[np][3]
cartesian components of pfac4 vector
Definition: prefactors.h:137
SafePtr< rdouble > one_o_2alpha12[np]
1/(2*alpha12)
Definition: prefactors.h:103
SafePtr< 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:125
SafePtr< rdouble > W_XY[np][3]
cartesian components of W_XY vector
Definition: prefactors.h:83
SafePtr< 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:74
SafePtr< rdouble > zeta[np][2]
orbital exponents
Definition: prefactors.h:88
unsigned int qn(unsigned int axis) const
Returns the quantum number along axis.
Definition: gauss.cc:141
RTimeEntity is an Entity of type T that exists at runtime of the generated code (hence has no value k...
Definition: entity.h:99
SafePtr< rdouble > vW_XY[np]
W-XY vectors: vW_XY[0] = W-P, vW_XY[1] = W-Q.
Definition: prefactors.h:81
const value_type & find(const SafePtr< T > &obj)
Returns the pointer to the unique instance of object obj.
Definition: singl_stack.h:79
SafePtr< rdouble > rho_o_alpha12[np]
rho/alpha12
Definition: prefactors.h:105
unsigned int d(unsigned int xyz) const
returns the number of quanta along xyz
Definition: bfset.h:125
SafePtr< rdouble > one_o_2alphasum
1/(2*(zeta+eta))
Definition: prefactors.h:107
SafePtr< rdouble > R12kG12VRR_vpfac4[np]
prefactor in front of (a0|k-2|c0)
Definition: prefactors.h:135
SafePtr< rdouble > R12kG12VRR_pfac0[np][3]
cartesian components of pfac0 vector
Definition: prefactors.h:127
auxiliary class that write expressions with compile-time cartesian vectors
Definition: prefactors.h:250
SafePtr< rdouble > R12kG12VRR_pfac1[np]
prefactor in front of (a-1 0|c0)
Definition: prefactors.h:129
SafePtr< rdouble > alpha12[np]
alpha12[p] is the sum of exponents for particle p: alpha12[0] = zeta, alpha12[1] = eta...
Definition: prefactors.h:99
Definition: prefactors.h:174
SafePtr< rdouble > Overlap00_1d[3]
Precomputed 1-d integrals.
Definition: prefactors.h:143
3D Cartesian Gaussian Function
Definition: bfset.h:320
SafePtr< rdouble > X_Y[np][3]
Cartesian components of X-Y vectors.
Definition: prefactors.h:57
SafePtr< rdouble > TwoPRepITR_pfac0[np][3]
cartesian components of pfac0 vector
Definition: prefactors.h:115
SafePtr< rdouble > TwoPRepITR_pfac1[np]
prefactor in front of (a0|c+1 0) = -alpha12[1]/alpha12[0]
Definition: prefactors.h:117
SafePtr< rdouble > R12kG12VRR_pfac3[np]
prefactor in front of (|k-2|)
Definition: prefactors.h:133
SafePtr< rdouble > rho
rho = zeta*eta/(zeta+eta)
Definition: prefactors.h:101
SafePtr< 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:63