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