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