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