21#ifndef _libint2_src_bin_libint_itr11twoprep11_h_
22#define _libint2_src_bin_libint_itr11twoprep11_h_
26#include <default_params.h>
29#include <prefactors.h>
31#include <twoprep_11_11.h>
48template <
template <
typename,
typename,
typename>
class ERI,
class BFSet,
49 int part, FunctionPosition where>
55 typedef ERI<BFSet, TwoPRep, mType> TargetType;
56 typedef TargetType ChildType;
68 static std::shared_ptr<ThisType>
Instance(
const std::shared_ptr<TargetType>&,
69 unsigned int dir = 0);
83 if (boost::is_same<BasisFunctionType, CGShell>::value)
return false;
89 unsigned int num_children()
const override {
return children_.size(); }
91 std::shared_ptr<DGVertex>
rr_target()
const override {
92 return std::static_pointer_cast<DGVertex, TargetType>(target_);
95 std::shared_ptr<DGVertex>
rr_child(
unsigned int i)
const override {
96 return std::static_pointer_cast<DGVertex, ChildType>(children_.at(i));
110 static const unsigned int max_nchildren_ = 4;
112 std::shared_ptr<TargetType> target_;
113 std::vector<std::shared_ptr<ChildType> > children_;
114 const std::shared_ptr<ChildType>& make_child(
const BFSet& A,
const BFSet& B,
117 const std::shared_ptr<ChildType>& i = ChildType::Instance(A, B, C, D, m);
118 children_.push_back(i);
119 return *(children_.end() - 1);
122 std::string generate_label()
const override {
123 typedef typename TargetType::AuxIndexType
mType;
124 static std::shared_ptr<mType> aux0(
new mType(0u));
125 std::ostringstream os;
129 os <<
"ITR Part" << part <<
" " <<
to_string(where)
130 << genintegralset_label(target_->bra(), target_->ket(), aux0,
135#if LIBINT_ENABLE_GENERIC_CODE
138 const std::shared_ptr<CompilationParameters>& cparams)
const override;
140 std::string generic_header()
const override;
142 std::string generic_instance(
143 const std::shared_ptr<CodeContext>& context,
144 const std::shared_ptr<CodeSymbols>& args)
const override;
148template <
template <
typename,
typename,
typename>
class ERI,
class F,
int part,
149 FunctionPosition where>
150std::shared_ptr<ITR_11_TwoPRep_11<ERI, F, part, where> >
152 const std::shared_ptr<TargetType>& Tint,
unsigned int dir) {
153 std::shared_ptr<ThisType> this_ptr(
new ThisType(Tint, dir));
155 if (this_ptr->num_children() != 0) {
156 this_ptr->template register_with_rrstack<ThisType>();
159 return std::shared_ptr<ThisType>();
162template <
template <
typename,
typename,
typename>
class ERI,
class F,
int part,
163 FunctionPosition where>
165 const std::shared_ptr<TargetType>& Tint,
unsigned int dir)
166 : target_(Tint), dir_(dir) {
169 F a(Tint->bra(0, 0));
170 F b(Tint->ket(0, 0));
171 F c(Tint->bra(1, 0));
172 F d(Tint->ket(1, 0));
173 if (a.contracted() || b.contracted() || c.contracted() || d.contracted())
179 const OriginDerivative<3u> dA = Tint->bra(0, 0).deriv();
180 const OriginDerivative<3u> dB = Tint->ket(0, 0).deriv();
181 const OriginDerivative<3u> dC = Tint->bra(1, 0).deriv();
182 const OriginDerivative<3u> dD = Tint->ket(1, 0).deriv();
183 const bool deriv = !dA.zero() || !dB.zero() || !dC.zero() || !dD.zero();
187 children_.reserve(max_nchildren_);
188 using namespace libint2::algebra;
189 using namespace libint2::prefactor;
190 const unsigned int m = Tint->aux()->elem(0);
191 const F& _1 = unit<F>(dir);
194 if (part == 0 && where == InBra) {
195 F a(Tint->bra(0, 0) - _1);
197 F b(Tint->ket(0, 0));
198 F c(Tint->bra(1, 0));
199 F d(Tint->ket(1, 0));
202 if (not(b.zero() && d.zero()))
return;
204 const std::shared_ptr<ChildType>& ABCD_m = make_child(a, b, c, d, m);
206 expr_ = Vector(
"TwoPRepITR_pfac0_0_0")[dir] * ABCD_m;
210 const F& cp1 = c + _1;
211 const std::shared_ptr<ChildType>& ABCp1D_m = make_child(a, b, cp1, d, m);
213 expr_ -= Scalar(
"eoz") * ABCp1D_m;
217 const F& am1 = a - _1;
219 const std::shared_ptr<ChildType>& Am1BCD_m = make_child(am1, b, c, d, m);
221 expr_ += Scalar(a[dir]) * Scalar(
"oo2z") * Am1BCD_m;
225 const F& cm1 = c - _1;
227 const std::shared_ptr<ChildType>& ABCm1D_m = make_child(a, b, cm1, d, m);
229 expr_ += Scalar(c[dir]) * Scalar(
"oo2z") * ABCm1D_m;
236 if (part == 1 && where == InBra) {
237 F a(Tint->bra(0, 0));
238 F b(Tint->ket(0, 0));
239 F c(Tint->bra(1, 0) - _1);
241 F d(Tint->ket(1, 0));
244 if (not(b.zero() && d.zero()))
return;
246 const std::shared_ptr<ChildType>& ABCD_m = make_child(a, b, c, d, m);
248 expr_ = Vector(
"TwoPRepITR_pfac0_1_0")[dir] * ABCD_m;
252 const F& ap1 = a + _1;
253 const std::shared_ptr<ChildType>& Ap1BCD_m = make_child(ap1, b, c, d, m);
255 expr_ -= Scalar(
"zoe") * Ap1BCD_m;
259 const F& cm1 = c - _1;
261 const std::shared_ptr<ChildType>& ABCm1D_m = make_child(a, b, cm1, d, m);
263 expr_ += Scalar(c[dir]) * Scalar(
"oo2e") * ABCm1D_m;
267 const F& am1 = a - _1;
269 const std::shared_ptr<ChildType>& Am1BCD_m = make_child(am1, b, c, d, m);
271 expr_ += Scalar(a[dir]) * Scalar(
"oo2e") * Am1BCD_m;
278 if (part == 0 && where == InKet) {
279 F a(Tint->bra(0, 0));
280 F b(Tint->ket(0, 0) - _1);
282 F c(Tint->bra(1, 0));
283 F d(Tint->ket(1, 0));
286 if (not(a.zero() && c.zero()))
return;
288 const std::shared_ptr<ChildType>& ABCD_m = make_child(a, b, c, d, m);
290 expr_ = Vector(
"TwoPRepITR_pfac0_0_1")[dir] * ABCD_m;
294 const F& dp1 = d + _1;
295 const std::shared_ptr<ChildType>& ABCDp1_m = make_child(a, b, c, dp1, m);
297 expr_ -= Scalar(
"eoz") * ABCDp1_m;
301 const F& bm1 = b - _1;
303 const std::shared_ptr<ChildType>& ABm1CD_m = make_child(a, bm1, c, d, m);
305 expr_ += Scalar(b[dir]) * Scalar(
"oo2z") * ABm1CD_m;
309 const F& dm1 = d - _1;
311 const std::shared_ptr<ChildType>& ABCDm1_m = make_child(a, b, c, dm1, m);
313 expr_ += Scalar(d[dir]) * Scalar(
"oo2z") * ABCDm1_m;
320 if (part == 1 && where == InKet) {
321 F a(Tint->bra(0, 0));
322 F b(Tint->ket(0, 0));
323 F c(Tint->bra(1, 0));
324 F d(Tint->ket(1, 0) - _1);
328 if (not(a.zero() && c.zero()))
return;
330 const std::shared_ptr<ChildType>& ABCD_m = make_child(a, b, c, d, m);
332 expr_ = Vector(
"TwoPRepITR_pfac0_1_1")[dir] * ABCD_m;
336 const F& bp1 = b + _1;
337 const std::shared_ptr<ChildType>& ABp1CD_m = make_child(a, bp1, c, d, m);
339 expr_ -= Scalar(
"zoe") * ABp1CD_m;
343 const F& dm1 = d - _1;
345 const std::shared_ptr<ChildType>& ABCDm1_m = make_child(a, b, c, dm1, m);
347 expr_ += Scalar(d[dir]) * Scalar(
"oo2e") * ABCDm1_m;
351 const F& bm1 = b - _1;
353 const std::shared_ptr<ChildType>& ABm1CD_m = make_child(a, bm1, c, d, m);
355 expr_ += Scalar(b[dir]) * Scalar(
"oo2e") * ABm1CD_m;
363#if LIBINT_ENABLE_GENERIC_CODE
364template <
template <
typename,
typename,
typename>
class ERI,
class F,
int part,
365 FunctionPosition where>
367 const std::shared_ptr<CompilationParameters>& cparams)
const {
370 F sh_a(target_->bra(0, 0));
371 F sh_b(target_->ket(0, 0));
372 F sh_c(target_->bra(1, 0));
373 F sh_d(target_->ket(1, 0));
374 const unsigned int max_opt_am = cparams->max_am_opt();
378 if (sh_b.zero() && sh_d.zero() &&
379 (sh_a.norm() > std::max(2 * max_opt_am, 1u) ||
380 sh_c.norm() > std::max(2 * max_opt_am, 1u)) &&
381 (sh_a.norm() > 1u && sh_c.norm() > 1u)) {
382 const bool ITR_xs_xs_Part1_implemented =
385 return ITR_xs_xs_Part1_implemented;
389 if (sh_a.zero() && sh_c.zero() &&
390 (sh_b.norm() > std::max(2 * max_opt_am, 1u) ||
391 sh_d.norm() > std::max(2 * max_opt_am, 1u)) &&
392 (sh_b.norm() > 1u && sh_d.norm() > 1u)) {
393 const bool ITR_sx_sx_implemented =
false;
394 return ITR_sx_sx_implemented;
399template <
template <
typename,
typename,
typename>
class ERI,
class F,
int part,
400 FunctionPosition where>
402 F sh_a(target_->bra(0, 0));
403 F sh_b(target_->ket(0, 0));
404 F sh_c(target_->bra(1, 0));
405 F sh_d(target_->ket(1, 0));
406 const bool xsxs = sh_b.zero() && sh_d.zero();
407 const bool sxsx = sh_a.zero() && sh_c.zero();
417 return std::string(
"ITR_xs_xs.h");
419 if (xsxs)
return std::string(
"ITR_xs_xs_deriv.h");
420 if (sxsx)
return std::string(
"ITR_sx_sx_deriv.h");
425template <
template <
typename,
typename,
typename>
class ERI,
class F,
int part,
426 FunctionPosition where>
428 const std::shared_ptr<CodeContext>& context,
429 const std::shared_ptr<CodeSymbols>& args)
const {
430 std::ostringstream oss;
431 F sh_a(target_->bra(0, 0));
432 F sh_b(target_->ket(0, 0));
433 F sh_c(target_->bra(1, 0));
434 F sh_d(target_->ket(1, 0));
435 const bool xsxs = sh_b.zero() && sh_d.zero();
436 const bool sxsx = sh_a.zero() && sh_c.zero();
445 oss <<
"using namespace libint2;" << std::endl;
450 oss <<
"libint2::ITR_xs_xs<" << part <<
"," << sh_a.norm() <<
","
451 << sh_c.norm() <<
",true,";
454 oss <<
"libint2::ITR_xs_xs<" << part <<
"," << sh_b.norm() <<
","
455 << sh_d.norm() <<
",false,";
457 oss << ((context->cparams()->max_vector_length() == 1) ?
"false" :
"true");
458 oss <<
">::compute(inteval";
460 const unsigned int nargs = args->n();
461 for (
unsigned int a = 0; a < nargs; a++) {
462 oss <<
"," << args->symbol(a);
AlgebraicOperator is an algebraic operator that acts on objects of type T.
Definition algebra.h:47
Set of basis functions.
Definition bfset.h:43
ITR (Interelectron Transfer Relation) for 2-e ERI.
Definition itr_11_twoprep_11.h:50
std::shared_ptr< DGVertex > rr_target() const override
Implementation of RecurrenceRelation::rr_target()
Definition itr_11_twoprep_11.h:91
bool is_simple() const override
Implementation of RecurrenceRelation::is_simple()
Definition itr_11_twoprep_11.h:99
unsigned int num_children() const override
Implementation of RecurrenceRelation::num_children()
Definition itr_11_twoprep_11.h:89
int partindex_direction() const
overrides RecurrenceRelation::partindex_direction()
Definition itr_11_twoprep_11.h:73
static std::shared_ptr< ThisType > Instance(const std::shared_ptr< TargetType > &, unsigned int dir=0)
Use Instance() to obtain an instance of RR.
Definition itr_11_twoprep_11.h:151
static bool directional()
Default directionality.
Definition itr_11_twoprep_11.h:82
RecurrenceRelation::ExprType ExprType
The type of expressions in which RecurrenceRelations result.
Definition itr_11_twoprep_11.h:58
std::shared_ptr< DGVertex > rr_child(unsigned int i) const override
Implementation of RecurrenceRelation::rr_child()
Definition itr_11_twoprep_11.h:95
Represents cartesian derivatives of atom-centered basis functions.
Definition bfset.h:101
bool zero() const
norm() == 0
Definition bfset.h:158
RecurrenceRelation describes all recurrence relations.
Definition rr.h:97
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24
bool exists(const IncableBFSet &A)
Return true if A is valid.
Definition bfset.h:96
DefaultQuantumNumbers< unsignedint, 1 >::Result mType
mType is the type that describes the auxiliary index of standard 2-body repulsion integrals
Definition quanta.h:395
std::string to_string(const T &x)
Converts x to its string representation.
Definition entity.h:121
TrivialBFSet<T> defines static member result, which is true if T is a basis function set consisting o...
Definition bfset.h:906