LIBINT 2.9.0
GenericGaussDeriv.impl.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_genericgaussderivimpl_h_
22#define _libint2_src_lib_libint_genericgaussderivimpl_h_
23
24#include <GenericGaussDeriv.h>
25
26namespace libint2 {
27
32template <int L,
34 bool vectorize>
36 const Libint_t* inteval, LIBINT2_REALTYPE* target,
37 const LIBINT2_REALTYPE* src0, const LIBINT2_REALTYPE* src1,
38 unsigned int
39 highdim,
40 unsigned int
41 lowdim,
42 unsigned int dir,
43 const LIBINT2_REALTYPE (
44 &two_alpha)[LIBINT2_MAX_VECLEN]
46) {
47 const unsigned int veclen = vectorize ? inteval->veclen : 1;
48 const unsigned int lveclen = lowdim * veclen;
49
50 const unsigned int N = INT_NCART(L);
51 const unsigned int Np1 = INT_NCART(L + 1);
52 const unsigned int Nm1 =
53 L > 0 ? INT_NCART(L - 1) : 0; // L == 0 case will not use Nm1
54
55 for (unsigned int h = 0, target_idx = 0; h < highdim; ++h) {
56 const unsigned int hNp1 = h * Np1;
57 const unsigned int hNm1 = h * Nm1;
58
59 int ax, ay, az;
60 FOR_CART(ax, ay, az, L)
61
62 int a[3];
63 a[0] = ax;
64 a[1] = ay;
65 a[2] = az;
66
67 // d |a) / dRi = 2 alpha a+1_i
68 ++a[dir];
69 const unsigned int iap1 = INT_CARTINDEX(L + 1, a[0], a[1]);
70 const unsigned int ap1_offset = (hNp1 + iap1) * lveclen;
71 const LIBINT2_REALTYPE* src0_ptr = src0 + ap1_offset;
72 --a[dir];
73
74 const bool have_am1 = (a[dir] > 0);
75 // d |a) / dRi -= a_i a-1_i
76 unsigned int iam1;
77 unsigned int am1_offset;
78 const LIBINT2_REALTYPE* src1_ptr;
79 if (have_am1) {
80 --a[dir];
81 iam1 = INT_CARTINDEX(L - 1, a[0], a[1]);
82 am1_offset = (hNm1 + iam1) * lveclen;
83 src1_ptr = src1 + am1_offset;
84 ++a[dir];
85 }
86 LIBINT2_REALTYPE adir_real = LIBINT2_REALTYPE(a[dir]);
87
88 if (have_am1)
89 for (unsigned int l = 0, lv = 0; l < lowdim; ++l) {
90 for (unsigned int v = 0; v < veclen; ++v, ++lv, ++target_idx) {
91 target[target_idx] =
92 two_alpha[v] * src0_ptr[lv] - adir_real * src1_ptr[lv];
93 }
94 }
95 else
96 for (unsigned int l = 0, lv = 0; l < lowdim; ++l) {
97 for (unsigned int v = 0; v < veclen; ++v, ++lv, ++target_idx) {
98 target[target_idx] = two_alpha[v] * src0_ptr[lv];
99 }
100 }
101
102#if LIBINT2_FLOP_COUNT
103 inteval->nflops[0] += (have_am1 ? 3 : 1) * lveclen;
104#endif
105
106 END_FOR_CART // end of loop over a
107 }
108}
109
110}; // namespace libint2
111
112#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 *src0, const LIBINT2_REALTYPE *src1, unsigned int highdim, unsigned int lowdim, unsigned int dir, const LIBINT2_REALTYPE(&two_alpha)[LIBINT2_MAX_VECLEN])
builds ( ... d a / d r_dir ... ) src0 = ( ... a+1 ... ) src1 = ( ... a-1 ... )
Definition GenericGaussDeriv.impl.h:35