LIBINT 2.9.0
OSVRR_xs_xs.h
1/*
2 * Copyright (C) 2004-2024 Edward F. Valeev
3 *
4 * This file is part of Libint library.
5 *
6 * Libint library is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser 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 library 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 Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with Libint library. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#ifndef _libint2_src_lib_libint_osvrrxsxs_h_
22#define _libint2_src_lib_libint_osvrrxsxs_h_
23
24#include <libint2.h>
25#include <libint2/cgshell_ordering.h>
26#include <util_types.h>
27
28#include <cstdlib>
29
30namespace libint2 {
31
32template <int part, int La, int Lc, bool unit_b, bool vectorize>
34 static void compute(const Libint_t* inteval, LIBINT2_REALTYPE* target,
35 const LIBINT2_REALTYPE* src0,
36 const LIBINT2_REALTYPE* src1,
37 const LIBINT2_REALTYPE* src2,
38 const LIBINT2_REALTYPE* src3,
39 const LIBINT2_REALTYPE* src4);
40};
41
49template <int La, int Lc, bool unit_b, bool vectorize>
50struct OSVRR_xs_xs<0, La, Lc, unit_b, vectorize> {
51 static void compute(const Libint_t* inteval, LIBINT2_REALTYPE* target,
52 const LIBINT2_REALTYPE* src0,
53 const LIBINT2_REALTYPE* src1,
54 const LIBINT2_REALTYPE* src2,
55 const LIBINT2_REALTYPE* src3,
56 const LIBINT2_REALTYPE* src4) {
57 // works for (ds|ps) and higher
58 assert(not(La < 2 || Lc < 1));
59
60 const unsigned int veclen = vectorize ? inteval->veclen : 1;
61
62 const unsigned int Nc = INT_NCART(Lc);
63 const unsigned int NcV = Nc * veclen;
64
65 int ax, ay, az;
66 FOR_CART(ax, ay, az, La)
67
68 int a[3];
69 a[0] = ax;
70 a[1] = ay;
71 a[2] = az;
72
73 enum XYZ { x = 0, y = 1, z = 2 };
74 // Build along x, if possible
75 XYZ xyz = z;
76 if (ay != 0) xyz = y;
77 if (ax != 0) xyz = x;
78 --a[xyz];
79
80 // redirect
81 const LIBINT2_REALTYPE *PA, *WP;
82 switch (xyz) {
83 case x:
84#if LIBINT2_DEFINED(eri, PA_x)
85 if (not unit_b) PA = inteval->PA_x;
86#endif
87 WP = inteval->WP_x;
88 break;
89 case y:
90#if LIBINT2_DEFINED(eri, PA_y)
91 if (not unit_b) PA = inteval->PA_y;
92#endif
93 WP = inteval->WP_y;
94 break;
95 case z:
96#if LIBINT2_DEFINED(eri, PA_z)
97 if (not unit_b) PA = inteval->PA_z;
98#endif
99 WP = inteval->WP_z;
100 break;
101 }
102
103 const unsigned int iam1 = INT_CARTINDEX(La - 1, a[0], a[1]);
104 const unsigned int am10c0_offset = iam1 * NcV;
105 const LIBINT2_REALTYPE* src0_ptr = unit_b ? 0 : src0 + am10c0_offset;
106 const LIBINT2_REALTYPE* src1_ptr = src1 + am10c0_offset;
107
108 // if a-2_xyz exists, include (a-2_xyz 0 | c 0)
109 if (a[xyz] > 0) {
110 --a[xyz];
111 const unsigned int iam2 = INT_CARTINDEX(La - 2, a[0], a[1]);
112 const unsigned int am20c0_offset = iam2 * NcV;
113 ++a[xyz];
114 const LIBINT2_REALTYPE* src2_ptr = src2 + am20c0_offset;
115 const LIBINT2_REALTYPE* src3_ptr = src3 + am20c0_offset;
116 const LIBINT2_REALTYPE axyz = (LIBINT2_REALTYPE)a[xyz];
117
118 unsigned int cv = 0;
119 for (unsigned int c = 0; c < Nc; ++c) {
120 for (unsigned int v = 0; v < veclen; ++v, ++cv) {
121 LIBINT2_REALTYPE value =
122 WP[v] * src1_ptr[cv] +
123 axyz * inteval->oo2z[v] *
124 (src2_ptr[cv] - inteval->roz[v] * src3_ptr[cv]);
125 if (not unit_b) value += PA[v] * src0_ptr[cv];
126 target[cv] = value;
127 }
128 }
129#if LIBINT2_FLOP_COUNT
130 inteval->nflops[0] += (unit_b ? 6 : 8) * NcV;
131#endif
132
133 } else {
134 unsigned int cv = 0;
135 for (unsigned int c = 0; c < Nc; ++c) {
136 for (unsigned int v = 0; v < veclen; ++v, ++cv) {
137 LIBINT2_REALTYPE value = WP[v] * src1_ptr[cv];
138 if (not unit_b) value += PA[v] * src0_ptr[cv];
139 target[cv] = value;
140 }
141 }
142#if LIBINT2_FLOP_COUNT
143 inteval->nflops[0] += (unit_b ? 1 : 3) * NcV;
144#endif
145 }
146
147 {
148 const unsigned int Ncm1 = INT_NCART(Lc - 1);
149 const unsigned int Ncm1V = Ncm1 * veclen;
150 const unsigned int am10cm10_offset = iam1 * Ncm1V;
151 const LIBINT2_REALTYPE* src4_ptr = src4 + am10cm10_offset;
152
153 // loop over c-1 shell and include (a-1_xyz 0 | c-1_xyz 0) to (a 0 | c 0)
154 int cx, cy, cz;
155 FOR_CART(cx, cy, cz, Lc - 1)
156
157 int c[3];
158 c[0] = cx;
159 c[1] = cy;
160 c[2] = cz;
161 ++c[xyz];
162
163 const unsigned int cc = INT_CARTINDEX(Lc, c[0], c[1]);
164 const unsigned int cc_offset = cc * veclen;
165 LIBINT2_REALTYPE* tptr = target + cc_offset;
166 const LIBINT2_REALTYPE cxyz = (LIBINT2_REALTYPE)c[xyz];
167 for (unsigned int v = 0; v < veclen; ++v) {
168 tptr[v] += cxyz * inteval->oo2ze[v] * src4_ptr[v];
169 }
170#if LIBINT2_FLOP_COUNT
171 inteval->nflops[0] += 3 * veclen;
172#endif
173 src4_ptr += veclen;
174
175 END_FOR_CART
176 }
177
178 target += NcV;
179
180 END_FOR_CART
181
183 // inteval->nflops[0] = inteval->nflops[0] + 222 * 1 * 1 * veclen;
184 }
185};
186
187// Ahlrichs' extension of OS VRR
188template <int part, int La, int Lc, bool vectorize>
190 static void compute(const Libint_t* inteval, LIBINT2_REALTYPE* target,
191 const LIBINT2_REALTYPE* src1,
192 const LIBINT2_REALTYPE* src4);
193};
194
199template <int La, int Lc, bool vectorize>
200struct OSAVRR_xs_xs<0, La, Lc, vectorize> {
201 static void compute(const Libint_t* inteval, LIBINT2_REALTYPE* target,
202 const LIBINT2_REALTYPE* src1,
203 const LIBINT2_REALTYPE* src4) {
204 // works for (ps|ps) and higher
205 assert(not(La < 1 || Lc < 1));
206
207 const unsigned int veclen = vectorize ? inteval->veclen : 1;
208
209 const unsigned int Nc = INT_NCART(Lc);
210 const unsigned int NcV = Nc * veclen;
211
212 int ax, ay, az;
213 FOR_CART(ax, ay, az, La)
214
215 int a[3];
216 a[0] = ax;
217 a[1] = ay;
218 a[2] = az;
219
220 enum XYZ { x = 0, y = 1, z = 2 };
221 // Build along x, if possible
222 XYZ xyz = z;
223 if (ay != 0) xyz = y;
224 if (ax != 0) xyz = x;
225 --a[xyz];
226
227 // redirect
228 const LIBINT2_REALTYPE* WP;
229 switch (xyz) {
230 case x:
231 WP = inteval->WP_x;
232 break;
233 case y:
234 WP = inteval->WP_y;
235 break;
236 case z:
237 WP = inteval->WP_z;
238 break;
239 }
240
241 const unsigned int iam1 = INT_CARTINDEX(La - 1, a[0], a[1]);
242 const unsigned int am10c0_offset = iam1 * NcV;
243 const LIBINT2_REALTYPE* src1_ptr = src1 + am10c0_offset;
244
245 {
246 unsigned int cv = 0;
247 for (unsigned int c = 0; c < Nc; ++c) {
248 for (unsigned int v = 0; v < veclen; ++v, ++cv) {
249 target[cv] = WP[v] * src1_ptr[cv];
250 }
251 }
252#if LIBINT2_FLOP_COUNT
253 inteval->nflops[0] += NcV;
254#endif
255 }
256
257 {
258 const unsigned int Ncm1 = INT_NCART(Lc - 1);
259 const unsigned int Ncm1V = Ncm1 * veclen;
260 const unsigned int am10cm10_offset = iam1 * Ncm1V;
261 const LIBINT2_REALTYPE* src4_ptr = src4 + am10cm10_offset;
262
263 // loop over c-1 shell and include (a-1_xyz 0 | c-1_xyz 0) to (a 0 | c 0)
264 int cx, cy, cz;
265 FOR_CART(cx, cy, cz, Lc - 1)
266
267 int c[3];
268 c[0] = cx;
269 c[1] = cy;
270 c[2] = cz;
271 ++c[xyz];
272
273 const unsigned int cc = INT_CARTINDEX(Lc, c[0], c[1]);
274 const unsigned int cc_offset = cc * veclen;
275 LIBINT2_REALTYPE* tptr = target + cc_offset;
276 const LIBINT2_REALTYPE cxyz = (LIBINT2_REALTYPE)c[xyz];
277 for (unsigned int v = 0; v < veclen; ++v) {
278 tptr[v] += cxyz * inteval->oo2ze[v] * src4_ptr[v];
279 }
280#if LIBINT2_FLOP_COUNT
281 inteval->nflops[0] += 3 * veclen;
282#endif
283 src4_ptr += veclen;
284
285 END_FOR_CART
286 }
287
288 target += NcV;
289
290 END_FOR_CART
291
293 // inteval->nflops[0] = inteval->nflops[0] + 222 * 1 * 1 * veclen;
294 }
295};
296
297}; // namespace libint2
298
299#endif // header guard
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24
static void compute(const Libint_t *inteval, LIBINT2_REALTYPE *target, const LIBINT2_REALTYPE *src1, const LIBINT2_REALTYPE *src4)
Definition OSVRR_xs_xs.h:201
Definition OSVRR_xs_xs.h:189
static void compute(const Libint_t *inteval, LIBINT2_REALTYPE *target, const LIBINT2_REALTYPE *src0, const LIBINT2_REALTYPE *src1, const LIBINT2_REALTYPE *src2, const LIBINT2_REALTYPE *src3, const LIBINT2_REALTYPE *src4)
Definition OSVRR_xs_xs.h:51
Definition OSVRR_xs_xs.h:33