LIBINT  2.6.0
r1dotr1g12_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_r1dotr1g121111_h_
22 #define _libint2_src_bin_libint_r1dotr1g121111_h_
23 
24 #include <integral.h>
25 
26 using namespace std;
27 
28 namespace libint2 {
29 
30 #if 0
31 
35  template <class BFS> class R1dotR1G12_11_11 :
36  public GenIntegralSet< R1dotR1_G12, IncableBFSet, typename DefaultTwoPBraket<BFS>::Result, typename DefaultTwoPBraket<BFS>::Result, EmptySet >
37  {
38  public:
39  typedef BFS BasisFunctionType;
40  typedef R1dotR1_G12 OperType;
41  typedef typename DefaultTwoPBraket<BFS>::Result BraType;
42  typedef typename DefaultTwoPBraket<BFS>::Result KetType;
43  typedef EmptySet AuxIndexType;
44  typedef R1dotR1G12_11_11<BFS> this_type;
45 
52 
53  typedef typename parent_type::key_type key_type;
56 
57  /* This "constructor" takes basis function sets, in Mulliken ordering.
58  Returns a pointer to a unique instance, a la Singleton
59  */
60  static const SafePtr<R1dotR1G12_11_11> Instance(const BFS& bra0, const BFS& ket0, const BFS& bra1, const BFS& ket1);
62  static const SafePtr<R1dotR1G12_11_11> Instance(const BraType& bra, const KetType& ket, const AuxIndexType& aux);
64 
66  bool operator==(const this_type&) const;
67 #if OVERLOAD_GENINTEGRALSET_LABEL
68  const std::string& label() const;
70 #endif
71 
72  private:
73  // This constructor is also private and not implemented since all Integral's are Singletons. Use Instance instead.
74  R1dotR1G12_11_11(const BraType& bra, const KetType& ket, const AuxIndexType& aux);
75 
76  // This is used to manage GenIntegralSet objects as singletons
77  static SingletonManagerType singl_manager_;
78 
80  bool this_precomputed() const;
81 #if OVERLOAD_GENINTEGRALSET_LABEL
82  mutable std::string label_;
83 #endif
84 
85  };
86 
87 #if USE_INT_KEY_TO_HASH
88  template <class BFS>
91 #else
92 # error "USE_INT_KEY_TO_HASH must be set"
93 #endif
94 
95  template <class BFS>
96  R1dotR1G12_11_11<BFS>::R1dotR1G12_11_11(const BraType& bra, const KetType& ket, const AuxIndexType& aux) :
97  parent_type(R1dotR1_G12(),bra, ket, aux)
98  {
99  if (bra.num_members(0) != 1)
100  throw std::runtime_error("R1dotR1G12_11_11<BFS>::R1dotR1G12_11_11(bra,ket) -- number of BFSs in bra for particle 0 must be 1");
101  if (bra.num_members(1) != 1)
102  throw std::runtime_error("R1dotR1G12_11_11<BFS>::R1dotR1G12_11_11(bra,ket) -- number of BFSs in bra for particle 1 must be 1");
103  if (ket.num_members(0) != 1)
104  throw std::runtime_error("R1dotR1G12_11_11<BFS>::R1dotR1G12_11_11(bra,ket) -- number of BFSs in ket for particle 0 must be 1");
105  if (ket.num_members(1) != 1)
106  throw std::runtime_error("R1dotR1G12_11_11<BFS>::R1dotR1G12_11_11(bra,ket) -- number of BFSs in ket for particle 1 must be 1");
107 #if DEBUG
108  std::cout << "R1dotR1G12_11_11: constructed " << this->label() << std::endl;
109 #endif
110  }
111 
112  template <class BFS>
113  R1dotR1G12_11_11<BFS>::~R1dotR1G12_11_11()
114  {
115 #if DEBUG
116  std::cout << "R1dotR1G12_11_11: destructed " << this->label() << std::endl;
117 #endif
118  }
119 
120  template <class BFS>
121  const SafePtr< R1dotR1G12_11_11<BFS> >
122  R1dotR1G12_11_11<BFS>::Instance(const BraType& bra, const KetType& ket, const AuxIndexType& aux)
123  {
124  typedef typename SingletonManagerType::value_type map_value_type;
125  key_type key = compute_key(OperType(),bra,ket,aux);
126  const map_value_type& val = singl_manager_.find(key);
127  if (!val.second) {
128  SafePtr<R1dotR1G12_11_11> this_int(new R1dotR1G12_11_11<BFS>(bra,ket,aux));
129  // Use singl_manager_ to make sure this is a new object of this type
130  const typename SingletonManagerType::value_type& val = singl_manager_.find(this_int);
131  val.second->instid_ = val.first;
132  return val.second;
133  }
134  return val.second;
135  }
136 
137  template <class BFS>
138  const SafePtr< R1dotR1G12_11_11<BFS> >
139  R1dotR1G12_11_11<BFS>::Instance(const BFS& bra0, const BFS& ket0, const BFS& bra1, const BFS& ket1)
140  {
141 #if USE_BRAKET_H
142  typedef BFS BFSRef;
143  BFSRef bra0_ref(bra0);
144  BFSRef bra1_ref(bra1);
145  BFSRef ket0_ref(ket0);
146  BFSRef ket1_ref(ket1);
147 #else
148  typedef SafePtr<BFS> BFSRef;
149  BFSRef bra0_ref(new BFS(bra0));
150  BFSRef bra1_ref(new BFS(bra1));
151  BFSRef ket0_ref(new BFS(ket0));
152  BFSRef ket1_ref(new BFS(ket1));
153 #endif
154  vector<BFSRef> vbra0; vbra0.push_back(bra0_ref);
155  vector<BFSRef> vbra1; vbra1.push_back(bra1_ref);
156  vector<BFSRef> vket0; vket0.push_back(ket0_ref);
157  vector<BFSRef> vket1; vket1.push_back(ket1_ref);
158  vector< vector<BFSRef> > vvbra; vvbra.push_back(vbra0); vvbra.push_back(vbra1);
159  vector< vector<BFSRef> > vvket; vvket.push_back(vket0); vvket.push_back(vket1);
160  BraType bra(vvbra);
161  KetType ket(vvket);
162  AuxIndexType aux(vector<int>(0));
163  return Instance(bra,ket,aux);
164  }
165 
166  template <class BFS>
167  bool
169  {
170  return parent_type::PtrComp::equiv(static_cast<const parent_type*>(this),a);
171  }
172 
173 #if OVERLOAD_GENINTEGRALSET_LABEL
174  template <class BFS>
175  const std::string&
177  {
178  if (label_.empty()) {
179  ostringstream os;
180  os << "(" << parent_type::bra_.member(0,0)->label() << " "
181  << parent_type::ket_.member(0,0)->label()
182  << " | r_1^2 * G12 | "
183  << parent_type::bra_.member(1,0)->label() << " "
184  << parent_type::ket_.member(1,0)->label() << ")";
185  label_ = os.str();
186  }
187  return label_;
188  };
189 #endif
190 
191  template <class BFS>
192  bool
194  {
195  return false;
196  }
197 
201 #endif
202 };
203 
204 #endif
205 
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
R1dotR1G12_11_11 – integral over R1dotR1_G12 operator with one bfs for each particle in bra and ket.
Definition: integral_decl.h:40
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
const std::string & label() const
Specialization of GenIntegralSet::label()
Definition: r1dotr1g12_11_11.h:176
PtrEquiv< this_type > PtrComp
This class provides comparison operations on pointers.
Definition: r1dotr1g12_11_11.h:51
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
SingletonStack< R1dotR1G12_11_11, key_type > SingletonManagerType
This the type of the object that manages GenIntegralSet's as Singletons.
Definition: r1dotr1g12_11_11.h:55
PtrEquiv<T> provides a set of comparison functions named 'equiv' which take as arguments a mix of ref...
Definition: equiv.h:36
bool operator==(const this_type &) const
Comparison operator.
Definition: r1dotr1g12_11_11.h:168
GenIntegralSet< OperType, IncableBFSet, BraType, KetType, AuxIndexType > parent_type
This is the immediate parent.
Definition: r1dotr1g12_11_11.h:49
R1dotR1G12_11_11< CGShell > R1dotR1G12_11_11_sq
the following typedefs are useful
Definition: r1dotr1g12_11_11.h:199
ArrayBraket is a lightweight implementation of Braket concept.
Definition: braket.h:38
R1dotR1G12_11_11< typename BFS::iter_type > iter_type
R1dotR1G12_11_11 is a set of these subobjects.
Definition: r1dotr1g12_11_11.h:47
DefaultQuantumNumbers< int, 0 >::Result EmptySet
EmptySet is the type that describes null set of auxiliary indices.
Definition: quanta.h:407