LIBINT 2.9.0
comp_11_g12tig12_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_cr11g12tig1211_h_
22#define _libint2_src_bin_libint_cr11g12tig1211_h_
23
24#include <gaussoper.h>
25#include <generic_rr.h>
26
27#include "task.h"
28
29namespace libint2 {
30
33template <class BFSet>
35 CR_11_G12TiG12_11<BFSet>, BFSet,
36 GenIntegralSet_11_11<BFSet, G12TiG12, mType> > {
37 public:
43 static const unsigned int max_nchildren = 1;
44
46
48 static bool directional() { return false; }
49
50 private:
52 using ParentType::target_;
53 using ParentType::RecurrenceRelation::expr_;
54 using ParentType::RecurrenceRelation::nflops_;
55
58 CR_11_G12TiG12_11(const std::shared_ptr<TargetType>&, unsigned int dir);
59 static std::string descr() { return "CR"; }
60
61#if LIBINT_ENABLE_GENERIC_CODE
63 bool has_generic(
64 const std::shared_ptr<CompilationParameters>& cparams) const override;
66 std::string generic_header() const override { return "GenericScale.h"; }
68 std::string generic_instance(
69 const std::shared_ptr<CodeContext>& context,
70 const std::shared_ptr<CodeSymbols>& args) const override;
71#endif
72};
73
74template <class F>
75CR_11_G12TiG12_11<F>::CR_11_G12TiG12_11(const std::shared_ptr<TargetType>& Tint,
76 unsigned int dir)
77 : ParentType(Tint, dir) {
78 if (dir != 0) return;
79 using namespace libint2::algebra;
80 using namespace libint2::prefactor;
81 using namespace libint2::braket;
82 // kinetic energy of which electron?
83 // const int i = target_->oper()->descr().K();
84 const R12kG12 G2(2);
85
86 F a(Tint->bra(0, 0));
87 F b(Tint->ket(0, 0));
88 F c(Tint->bra(1, 0));
89 F d(Tint->ket(1, 0));
90
91 if (target_->oper()->descr().contracted()) return;
92
93 // [G12,[T1,G12]] = [G12,[T2,G12]]
94 {
97 auto ab_G2_cd = factory.make_child(a, b, c, d, 0u, G2);
98 if (is_simple()) {
99 expr_ = Scalar("R12_2_G12_scale_to_G12T1G12") * ab_G2_cd;
100 nflops_ += 1;
101 }
102 }
103}
104
105#if LIBINT_ENABLE_GENERIC_CODE
106template <class F>
108 const std::shared_ptr<CompilationParameters>& cparams) const {
109 F sh_a(target_->bra(0, 0));
110 F sh_b(target_->ket(0, 0));
111 F sh_c(target_->bra(1, 0));
112 F sh_d(target_->ket(1, 0));
113 const unsigned int max_opt_am = cparams->max_am_opt();
114 // to generate optimized code for xxxx integral need to generate specialized
115 // code for up to (x+x)0(x+x)0 integrals
117 (sh_a.norm() > max_opt_am || sh_b.norm() > max_opt_am ||
118 sh_c.norm() > max_opt_am || sh_d.norm() > max_opt_am))
119 return true;
120 return false;
121}
122
123template <class F>
125 const std::shared_ptr<CodeContext>& context,
126 const std::shared_ptr<CodeSymbols>& args) const {
127 std::ostringstream oss;
128
129 const bool vec = (context->cparams()->max_vector_length() != 1);
130 if (vec)
131 oss << "_libint2_static_api_scale_vec_short_(";
132 else
133 oss << "_libint2_static_api_scale_short_(";
134
135 const unsigned int nargs = args->n();
136 for (unsigned int a = 0; a < nargs; a++) {
137 oss << args->symbol(a) << ",";
138 }
139
140 oss << target_->size() << "*" << (vec ? "inteval->veclen" : "1")
141 << ",inteval->R12_2_G12_scale_to_G12T1G12"
142 << (vec ? ",inteval->veclen" : "[0]") << ");";
143
144 // HACK alert ... unfortunately it's not completely possible to figure out all
145 // "precomputed" symbols from the DAG alone force R12_2_G12_scale_to_G12T1G12
146 // on the list of symbols
147 {
149 std::list<std::string> forced_symbol;
150 forced_symbol.push_back(std::string("R12_2_G12_scale_to_G12T1G12"));
151 taskmgr.current().symbols()->add(forced_symbol);
152 }
153
154 return oss.str();
155}
156#endif
157
158}; // namespace libint2
159
160#endif
Set of basis functions.
Definition bfset.h:43
Compute relation for 2-e integrals of the G12_Ti_G12 operators.
Definition comp_11_g12tig12_11.h:36
static bool directional()
This relation is not directional.
Definition comp_11_g12tig12_11.h:48
Helps GenericRecurrenceRelation to work around the compiler problem with make_child.
Definition generic_rr.h:150
Generic integral over a two-body operator with one bfs for each particle in bra and ket.
Definition integral_11_11.h:36
GenOper is a single operator described by descriptor Descr.
Definition oper.h:164
RRImpl must inherit GenericRecurrenceRelation<RRImpl>
Definition generic_rr.h:47
bool is_simple() const override
Implementation of RecurrenceRelation::is_simple()
Definition generic_rr.h:81
static std::shared_ptr< RRImpl > Instance(const std::shared_ptr< TargetType > &Tint, unsigned int dir)
Return an instance if applicable, or a null pointer otherwise.
Definition generic_rr.h:55
Manages tasks. This is a Singleton.
Definition task.h:65
void current(const std::string &task_label)
Makes this task current (must have been added already)
Definition task.cc:63
static LibraryTaskManager & Instance()
LibraryTaskManager is a Singleton.
Definition task.cc:32
these objects help to construct BraketPairs
Definition src/bin/libint/braket.h:275
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24
TrivialBFSet<T> defines static member result, which is true if T is a basis function set consisting o...
Definition bfset.h:906