LIBINT  2.6.0
r1dotr2g12_11_11.h
1 /*
2  * Copyright (C) 2004-2019 Edward F. Valeev
3  *
4  * This file is part of Libint.
5  *
6  * Libint 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 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. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef _libint2_src_bin_libint_r1dotr2g121111_h_
22 #define _libint2_src_bin_libint_r1dotr2g121111_h_
23 
24 #include <integral.h>
25 #include <integral_11_11.h>
26 
27 using namespace std;
28 
29 namespace libint2 {
30 
35  typedef GenIntegralSet_11_11<CGShell,R1dotR1_G12,EmptySet> R1dotR1G12_11_11_sq;
36  typedef GenIntegralSet_11_11<CGF,R1dotR1_G12,EmptySet> R1dotR1G12_11_11_int;
41 
42 #if 0
43  template <class BFS> class R1dotR2G12_11_11 :
44  public GenIntegralSet< R1dotR2_G12, IncableBFSet, typename DefaultTwoPBraket<BFS>::Result, typename DefaultTwoPBraket<BFS>::Result, EmptySet >
45  {
46  public:
47  typedef BFS BasisFunctionType;
48  typedef R1dotR2_G12 OperType;
49  typedef typename DefaultTwoPBraket<BFS>::Result BraType;
50  typedef typename DefaultTwoPBraket<BFS>::Result KetType;
51  typedef EmptySet AuxIndexType;
52  typedef R1dotR2G12_11_11<BFS> this_type;
53 
60 
61  typedef typename parent_type::key_type key_type;
64 
65  /* This "constructor" takes basis function sets, in Mulliken ordering.
66  Returns a pointer to a unique instance, a la Singleton
67  */
68  static const SafePtr<R1dotR2G12_11_11> Instance(const BFS& bra0, const BFS& ket0, const BFS& bra1, const BFS& ket1);
70  static const SafePtr<R1dotR2G12_11_11> Instance(const BraType& bra, const KetType& ket, const AuxIndexType& aux);
72 
74  bool operator==(const this_type&) const;
75 #if OVERLOAD_GENINTEGRALSET_LABEL
76  const std::string& label() const;
78 #endif
79 
80  private:
81  // This constructor is also private and not implemented since all Integral's are Singletons. Use Instance instead.
82  R1dotR2G12_11_11(const BraType& bra, const KetType& ket, const AuxIndexType& aux);
83 
84  // This is used to manage GenIntegralSet objects as singletons
85  static SingletonManagerType singl_manager_;
86 
88  bool this_precomputed() const;
89 #if OVERLOAD_GENINTEGRALSET_LABEL
90  mutable std::string label_;
91 #endif
92 
93  };
94 
95 #if USE_INT_KEY_TO_HASH
96  template <class BFS>
99 #else
100 # error "USE_INT_KEY_TO_HASH must be set"
101 #endif
102 
103  template <class BFS>
104  R1dotR2G12_11_11<BFS>::R1dotR2G12_11_11(const BraType& bra, const KetType& ket, const AuxIndexType& aux) :
105  parent_type(R1dotR2_G12(),bra, ket, aux)
106  {
107  if (bra.num_members(0) != 1)
108  throw std::runtime_error("R1dotR2G12_11_11<BFS>::R1dotR2G12_11_11(bra,ket) -- number of BFSs in bra for particle 0 must be 1");
109  if (bra.num_members(1) != 1)
110  throw std::runtime_error("R1dotR2G12_11_11<BFS>::R1dotR2G12_11_11(bra,ket) -- number of BFSs in bra for particle 1 must be 1");
111  if (ket.num_members(0) != 1)
112  throw std::runtime_error("R1dotR2G12_11_11<BFS>::R1dotR2G12_11_11(bra,ket) -- number of BFSs in ket for particle 0 must be 1");
113  if (ket.num_members(1) != 1)
114  throw std::runtime_error("R1dotR2G12_11_11<BFS>::R1dotR2G12_11_11(bra,ket) -- number of BFSs in ket for particle 1 must be 1");
115 #if DEBUG
116  std::cout << "R1dotR2G12_11_11: constructed " << this->label() << std::endl;
117 #endif
118  }
119 
120  template <class BFS>
121  R1dotR2G12_11_11<BFS>::~R1dotR2G12_11_11()
122  {
123 #if DEBUG
124  std::cout << "R1dotR2G12_11_11: destructed " << this->label() << std::endl;
125 #endif
126  }
127 
128  template <class BFS>
129  const SafePtr< R1dotR2G12_11_11<BFS> >
130  R1dotR2G12_11_11<BFS>::Instance(const BraType& bra, const KetType& ket, const AuxIndexType& aux)
131  {
132  typedef typename SingletonManagerType::value_type map_value_type;
133  key_type key = compute_key(OperType(),bra,ket,aux);
134  const map_value_type& val = singl_manager_.find(key);
135  if (!val.second) {
136  SafePtr<R1dotR2G12_11_11> this_int(new R1dotR2G12_11_11<BFS>(bra,ket,aux));
137  // Use singl_manager_ to make sure this is a new object of this type
138  const typename SingletonManagerType::value_type& val = singl_manager_.find(this_int);
139  val.second->instid_ = val.first;
140  return val.second;
141  }
142  return val.second;
143  }
144 
145  template <class BFS>
146  const SafePtr< R1dotR2G12_11_11<BFS> >
147  R1dotR2G12_11_11<BFS>::Instance(const BFS& bra0, const BFS& ket0, const BFS& bra1, const BFS& ket1)
148  {
149 #if USE_BRAKET_H
150  typedef BFS BFSRef;
151  BFSRef bra0_ref(bra0);
152  BFSRef bra1_ref(bra1);
153  BFSRef ket0_ref(ket0);
154  BFSRef ket1_ref(ket1);
155 #else
156  typedef SafePtr<BFS> BFSRef;
157  BFSRef bra0_ref(new BFS(bra0));
158  BFSRef bra1_ref(new BFS(bra1));
159  BFSRef ket0_ref(new BFS(ket0));
160  BFSRef ket1_ref(new BFS(ket1));
161 #endif
162  vector<BFSRef> vbra0; vbra0.push_back(bra0_ref);
163  vector<BFSRef> vbra1; vbra1.push_back(bra1_ref);
164  vector<BFSRef> vket0; vket0.push_back(ket0_ref);
165  vector<BFSRef> vket1; vket1.push_back(ket1_ref);
166  vector< vector<BFSRef> > vvbra; vvbra.push_back(vbra0); vvbra.push_back(vbra1);
167  vector< vector<BFSRef> > vvket; vvket.push_back(vket0); vvket.push_back(vket1);
168  BraType bra(vvbra);
169  KetType ket(vvket);
170  AuxIndexType aux(vector<int>(0));
171  return Instance(bra,ket,aux);
172  }
173 
174  template <class BFS>
175  bool
177  {
178  return parent_type::PtrComp::equiv(static_cast<const parent_type*>(this),a);
179  }
180 
181 #if OVERLOAD_GENINTEGRALSET_LABEL
182  template <class BFS>
183  const std::string&
185  {
186  if (label_.empty()) {
187  ostringstream os;
188  os << "(" << parent_type::bra_.member(0,0)->label() << " "
189  << parent_type::ket_.member(0,0)->label()
190  << " | r_1.r_2 * G12 | "
191  << parent_type::bra_.member(1,0)->label() << " "
192  << parent_type::ket_.member(1,0)->label() << ")";
193  label_ = os.str();
194  }
195  return label_;
196  };
197 #endif
198 
199  template <class BFS>
200  bool
202  {
203  return false;
204  }
205 
207  typedef R1dotR2G12_11_11<CGShell> R1dotR2G12_11_11_sq;
208  typedef R1dotR2G12_11_11<CGF> R1dotR2G12_11_11_int;
209 #endif
210 
211 };
212 
213 #endif
214 
GenIntegralSet< OperType, IncableBFSet, BraType, KetType, AuxIndexType > parent_type
This is the immediate parent.
Definition: r1dotr2g12_11_11.h:57
SingletonStack<T,KeyType> helps to implement Singleton-like objects of type T.
Definition: singl_stack.h:43
unsigned int num_members(unsigned int p) const
Returns the number of BFS for particle p.
Definition: braket.h:75
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:24
GenIntegralSet is a set of integrals over functions derived from BFS.
Definition: integral.h:91
SingletonStack< R1dotR2G12_11_11, key_type > SingletonManagerType
This the type of the object that manages GenIntegralSet's as Singletons.
Definition: r1dotr2g12_11_11.h:63
Generic integral over a two-body operator with one bfs for each particle in bra and ket.
Definition: integral_11_11.h:33
QuantumNumbersA<T,N> is a set of N quantum numbers of type T implemented in terms of a C-style array.
Definition: quanta.h:200
PtrEquiv<T> provides a set of comparison functions named 'equiv' which take as arguments a mix of ref...
Definition: equiv.h:36
Definition: integral_decl.h:42
PtrEquiv< this_type > PtrComp
This class provides comparison operations on pointers.
Definition: r1dotr2g12_11_11.h:59
GenIntegralSet_11_11< CGShell, R1dotR2_G12, EmptySet > R1dotR2G12_11_11_sq
the following typedefs are useful
Definition: r1dotr2g12_11_11.h:39
R1dotR2G12_11_11< typename BFS::iter_type > iter_type
R1dotR2G12_11_11 is a set of these subobjects.
Definition: r1dotr2g12_11_11.h:55
R1dotR1G12_11_11< CGShell > R1dotR1G12_11_11_sq
the following typedefs are useful
Definition: r1dotr1g12_11_11.h:199
const std::string & label() const
Specialization of GenIntegralSet::label()
Definition: r1dotr2g12_11_11.h:184
ArrayBraket is a lightweight implementation of Braket concept.
Definition: braket.h:38
bool operator==(const this_type &) const
Comparison operator.
Definition: r1dotr2g12_11_11.h:176