1 #include "simint/boys/boys.h"
2 #include "simint/ostei/gen/ostei_generated.h"
3 #include "simint/vectorization/vectorization.h"
4 #include <math.h>
5 #include <string.h>
6 
7 
ostei_h_p_d_s(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__h_p_d_s)8 int ostei_h_p_d_s(struct simint_multi_shellpair const P,
9                   struct simint_multi_shellpair const Q,
10                   double screen_tol,
11                   double * const restrict work,
12                   double * const restrict INT__h_p_d_s)
13 {
14 
15     SIMINT_ASSUME_ALIGN_DBL(work);
16     SIMINT_ASSUME_ALIGN_DBL(INT__h_p_d_s);
17     int ab, cd, abcd;
18     int istart, jstart;
19     int iprimcd, nprim_icd, icd;
20     const int check_screen = (screen_tol > 0.0);
21     int i, j;
22     int n;
23     int not_screened;
24     int real_abcd;
25     int iket;
26 
27     // partition workspace
28     double * const INT__h_s_d_s = work + (SIMINT_NSHELL_SIMD * 0);
29     double * const INT__i_s_d_s = work + (SIMINT_NSHELL_SIMD * 126);
30     SIMINT_DBLTYPE * const primwork = (SIMINT_DBLTYPE *)(work + SIMINT_NSHELL_SIMD*294);
31     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_s = primwork + 0;
32     SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_s_s = primwork + 9;
33     SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_s_s = primwork + 33;
34     SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_s_s = primwork + 75;
35     SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_s_s = primwork + 135;
36     SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_p_s = primwork + 210;
37     SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_s_s = primwork + 300;
38     SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_p_s = primwork + 384;
39     SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_d_s = primwork + 510;
40     SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_s_s = primwork + 636;
41     SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_p_s = primwork + 720;
42     SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_d_s = primwork + 888;
43     double * const hrrwork = (double *)(primwork + 1056);
44 
45 
46     // Create constants
47     const SIMINT_DBLTYPE const_1 = SIMINT_DBLSET1(1);
48     const SIMINT_DBLTYPE const_2 = SIMINT_DBLSET1(2);
49     const SIMINT_DBLTYPE const_3 = SIMINT_DBLSET1(3);
50     const SIMINT_DBLTYPE const_4 = SIMINT_DBLSET1(4);
51     const SIMINT_DBLTYPE const_5 = SIMINT_DBLSET1(5);
52     const SIMINT_DBLTYPE const_6 = SIMINT_DBLSET1(6);
53     const SIMINT_DBLTYPE one_half = SIMINT_DBLSET1(0.5);
54 
55 
56     ////////////////////////////////////////
57     // Loop over shells and primitives
58     ////////////////////////////////////////
59 
60     real_abcd = 0;
61     istart = 0;
62     for(ab = 0; ab < P.nshell12_clip; ++ab)
63     {
64         const int iend = istart + P.nprim12[ab];
65 
66         cd = 0;
67         jstart = 0;
68 
69         for(cd = 0; cd < Q.nshell12_clip; cd += SIMINT_NSHELL_SIMD)
70         {
71             const int nshellbatch = ((cd + SIMINT_NSHELL_SIMD) > Q.nshell12_clip) ? Q.nshell12_clip - cd : SIMINT_NSHELL_SIMD;
72             int jend = jstart;
73             for(i = 0; i < nshellbatch; i++)
74                 jend += Q.nprim12[cd+i];
75 
76             // Clear the beginning of the workspace (where we are accumulating integrals)
77             memset(work, 0, SIMINT_NSHELL_SIMD * 294 * sizeof(double));
78             abcd = 0;
79 
80 
81             for(i = istart; i < iend; ++i)
82             {
83                 SIMINT_DBLTYPE bra_screen_max;  // only used if check_screen
84 
85                 if(check_screen)
86                 {
87                     // Skip this whole thing if always insignificant
88                     if((P.screen[i] * Q.screen_max) < screen_tol)
89                         continue;
90                     bra_screen_max = SIMINT_DBLSET1(P.screen[i]);
91                 }
92 
93                 icd = 0;
94                 iprimcd = 0;
95                 nprim_icd = Q.nprim12[cd];
96                 double * restrict PRIM_PTR_INT__h_s_d_s = INT__h_s_d_s + abcd * 126;
97                 double * restrict PRIM_PTR_INT__i_s_d_s = INT__i_s_d_s + abcd * 168;
98 
99 
100 
101                 // Load these one per loop over i
102                 const SIMINT_DBLTYPE P_alpha = SIMINT_DBLSET1(P.alpha[i]);
103                 const SIMINT_DBLTYPE P_prefac = SIMINT_DBLSET1(P.prefac[i]);
104                 const SIMINT_DBLTYPE Pxyz[3] = { SIMINT_DBLSET1(P.x[i]), SIMINT_DBLSET1(P.y[i]), SIMINT_DBLSET1(P.z[i]) };
105 
106                 const SIMINT_DBLTYPE P_PA[3] = { SIMINT_DBLSET1(P.PA_x[i]), SIMINT_DBLSET1(P.PA_y[i]), SIMINT_DBLSET1(P.PA_z[i]) };
107 
108                 for(j = jstart; j < jend; j += SIMINT_SIMD_LEN)
109                 {
110                     // calculate the shell offsets
111                     // these are the offset from the shell pointed to by cd
112                     // for each element
113                     int shelloffsets[SIMINT_SIMD_LEN] = {0};
114                     int lastoffset = 0;
115                     const int nlane = ( ((j + SIMINT_SIMD_LEN) < jend) ? SIMINT_SIMD_LEN : (jend - j));
116 
117                     if((iprimcd + SIMINT_SIMD_LEN) >= nprim_icd)
118                     {
119                         // Handle if the first element of the vector is a new shell
120                         if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
121                         {
122                             nprim_icd += Q.nprim12[cd + (++icd)];
123                             PRIM_PTR_INT__h_s_d_s += 126;
124                             PRIM_PTR_INT__i_s_d_s += 168;
125                         }
126                         iprimcd++;
127                         for(n = 1; n < SIMINT_SIMD_LEN; ++n)
128                         {
129                             if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
130                             {
131                                 shelloffsets[n] = shelloffsets[n-1] + 1;
132                                 lastoffset++;
133                                 nprim_icd += Q.nprim12[cd + (++icd)];
134                             }
135                             else
136                                 shelloffsets[n] = shelloffsets[n-1];
137                             iprimcd++;
138                         }
139                     }
140                     else
141                         iprimcd += SIMINT_SIMD_LEN;
142 
143                     // Do we have to compute this vector (or has it been screened out)?
144                     // (not_screened != 0 means we have to do this vector)
145                     if(check_screen)
146                     {
147                         const double vmax = vector_max(SIMINT_MUL(bra_screen_max, SIMINT_DBLLOAD(Q.screen, j)));
148                         if(vmax < screen_tol)
149                         {
150                             PRIM_PTR_INT__h_s_d_s += lastoffset*126;
151                             PRIM_PTR_INT__i_s_d_s += lastoffset*168;
152                             continue;
153                         }
154                     }
155 
156                     const SIMINT_DBLTYPE Q_alpha = SIMINT_DBLLOAD(Q.alpha, j);
157                     const SIMINT_DBLTYPE PQalpha_mul = SIMINT_MUL(P_alpha, Q_alpha);
158                     const SIMINT_DBLTYPE PQalpha_sum = SIMINT_ADD(P_alpha, Q_alpha);
159                     const SIMINT_DBLTYPE one_over_PQalpha_sum = SIMINT_DIV(const_1, PQalpha_sum);
160 
161 
162                     /* construct R2 = (Px - Qx)**2 + (Py - Qy)**2 + (Pz -Qz)**2 */
163                     SIMINT_DBLTYPE PQ[3];
164                     PQ[0] = SIMINT_SUB(Pxyz[0], SIMINT_DBLLOAD(Q.x, j));
165                     PQ[1] = SIMINT_SUB(Pxyz[1], SIMINT_DBLLOAD(Q.y, j));
166                     PQ[2] = SIMINT_SUB(Pxyz[2], SIMINT_DBLLOAD(Q.z, j));
167                     SIMINT_DBLTYPE R2 = SIMINT_MUL(PQ[0], PQ[0]);
168                     R2 = SIMINT_FMADD(PQ[1], PQ[1], R2);
169                     R2 = SIMINT_FMADD(PQ[2], PQ[2], R2);
170 
171                     const SIMINT_DBLTYPE alpha = SIMINT_MUL(PQalpha_mul, one_over_PQalpha_sum); // alpha from MEST
172                     const SIMINT_DBLTYPE one_over_p = SIMINT_DIV(const_1, P_alpha);
173                     const SIMINT_DBLTYPE one_over_q = SIMINT_DIV(const_1, Q_alpha);
174                     const SIMINT_DBLTYPE one_over_2p = SIMINT_MUL(one_half, one_over_p);
175                     const SIMINT_DBLTYPE one_over_2q = SIMINT_MUL(one_half, one_over_q);
176                     const SIMINT_DBLTYPE one_over_2pq = SIMINT_MUL(one_half, one_over_PQalpha_sum);
177                     const SIMINT_DBLTYPE Q_PA[3] = { SIMINT_DBLLOAD(Q.PA_x, j), SIMINT_DBLLOAD(Q.PA_y, j), SIMINT_DBLLOAD(Q.PA_z, j) };
178 
179                     // NOTE: Minus sign!
180                     const SIMINT_DBLTYPE a_over_p = SIMINT_MUL(SIMINT_NEG(alpha), one_over_p);
181                     SIMINT_DBLTYPE aop_PQ[3];
182                     aop_PQ[0] = SIMINT_MUL(a_over_p, PQ[0]);
183                     aop_PQ[1] = SIMINT_MUL(a_over_p, PQ[1]);
184                     aop_PQ[2] = SIMINT_MUL(a_over_p, PQ[2]);
185 
186                     SIMINT_DBLTYPE a_over_q = SIMINT_MUL(alpha, one_over_q);
187                     SIMINT_DBLTYPE aoq_PQ[3];
188                     aoq_PQ[0] = SIMINT_MUL(a_over_q, PQ[0]);
189                     aoq_PQ[1] = SIMINT_MUL(a_over_q, PQ[1]);
190                     aoq_PQ[2] = SIMINT_MUL(a_over_q, PQ[2]);
191                     // Put a minus sign here so we don't have to in RR routines
192                     a_over_q = SIMINT_NEG(a_over_q);
193 
194 
195                     //////////////////////////////////////////////
196                     // Fjt function section
197                     // Maximum v value: 8
198                     //////////////////////////////////////////////
199                     // The parameter to the Fjt function
200                     const SIMINT_DBLTYPE F_x = SIMINT_MUL(R2, alpha);
201 
202 
203                     const SIMINT_DBLTYPE Q_prefac = mask_load(nlane, Q.prefac + j);
204 
205 
206                     boys_F_split(PRIM_INT__s_s_s_s, F_x, 8);
207                     SIMINT_DBLTYPE prefac = SIMINT_SQRT(one_over_PQalpha_sum);
208                     prefac = SIMINT_MUL(SIMINT_MUL(P_prefac, Q_prefac), prefac);
209                     for(n = 0; n <= 8; n++)
210                         PRIM_INT__s_s_s_s[n] = SIMINT_MUL(PRIM_INT__s_s_s_s[n], prefac);
211 
212                     //////////////////////////////////////////////
213                     // Primitive integrals: Vertical recurrance
214                     //////////////////////////////////////////////
215 
216                     const SIMINT_DBLTYPE vrr_const_1_over_2p = one_over_2p;
217                     const SIMINT_DBLTYPE vrr_const_2_over_2p = SIMINT_MUL(const_2, one_over_2p);
218                     const SIMINT_DBLTYPE vrr_const_3_over_2p = SIMINT_MUL(const_3, one_over_2p);
219                     const SIMINT_DBLTYPE vrr_const_4_over_2p = SIMINT_MUL(const_4, one_over_2p);
220                     const SIMINT_DBLTYPE vrr_const_5_over_2p = SIMINT_MUL(const_5, one_over_2p);
221                     const SIMINT_DBLTYPE vrr_const_1_over_2q = one_over_2q;
222                     const SIMINT_DBLTYPE vrr_const_1_over_2pq = one_over_2pq;
223                     const SIMINT_DBLTYPE vrr_const_2_over_2pq = SIMINT_MUL(const_2, one_over_2pq);
224                     const SIMINT_DBLTYPE vrr_const_3_over_2pq = SIMINT_MUL(const_3, one_over_2pq);
225                     const SIMINT_DBLTYPE vrr_const_4_over_2pq = SIMINT_MUL(const_4, one_over_2pq);
226                     const SIMINT_DBLTYPE vrr_const_5_over_2pq = SIMINT_MUL(const_5, one_over_2pq);
227                     const SIMINT_DBLTYPE vrr_const_6_over_2pq = SIMINT_MUL(const_6, one_over_2pq);
228 
229 
230 
231                     // Forming PRIM_INT__p_s_s_s[8 * 3];
232                     for(n = 0; n < 8; ++n)  // loop over orders of auxiliary function
233                     {
234 
235                         PRIM_INT__p_s_s_s[n * 3 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
236                         PRIM_INT__p_s_s_s[n * 3 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_s_s[n * 3 + 0]);
237 
238                         PRIM_INT__p_s_s_s[n * 3 + 1] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
239                         PRIM_INT__p_s_s_s[n * 3 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_s_s[n * 3 + 1]);
240 
241                         PRIM_INT__p_s_s_s[n * 3 + 2] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
242                         PRIM_INT__p_s_s_s[n * 3 + 2] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_s_s[n * 3 + 2]);
243 
244                     }
245 
246 
247 
248                     // Forming PRIM_INT__d_s_s_s[7 * 6];
249                     for(n = 0; n < 7; ++n)  // loop over orders of auxiliary function
250                     {
251 
252                         PRIM_INT__d_s_s_s[n * 6 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__p_s_s_s[n * 3 + 0]);
253                         PRIM_INT__d_s_s_s[n * 6 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_s_s[n * 6 + 0]);
254                         PRIM_INT__d_s_s_s[n * 6 + 0] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__d_s_s_s[n * 6 + 0]);
255 
256                         PRIM_INT__d_s_s_s[n * 6 + 1] = SIMINT_MUL(P_PA[1], PRIM_INT__p_s_s_s[n * 3 + 0]);
257                         PRIM_INT__d_s_s_s[n * 6 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_s_s[n * 6 + 1]);
258 
259                         PRIM_INT__d_s_s_s[n * 6 + 3] = SIMINT_MUL(P_PA[1], PRIM_INT__p_s_s_s[n * 3 + 1]);
260                         PRIM_INT__d_s_s_s[n * 6 + 3] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__d_s_s_s[n * 6 + 3]);
261                         PRIM_INT__d_s_s_s[n * 6 + 3] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__d_s_s_s[n * 6 + 3]);
262 
263                         PRIM_INT__d_s_s_s[n * 6 + 5] = SIMINT_MUL(P_PA[2], PRIM_INT__p_s_s_s[n * 3 + 2]);
264                         PRIM_INT__d_s_s_s[n * 6 + 5] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__d_s_s_s[n * 6 + 5]);
265                         PRIM_INT__d_s_s_s[n * 6 + 5] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__d_s_s_s[n * 6 + 5]);
266 
267                     }
268 
269 
270 
271                     // Forming PRIM_INT__f_s_s_s[6 * 10];
272                     for(n = 0; n < 6; ++n)  // loop over orders of auxiliary function
273                     {
274 
275                         PRIM_INT__f_s_s_s[n * 10 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__d_s_s_s[n * 6 + 0]);
276                         PRIM_INT__f_s_s_s[n * 10 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__f_s_s_s[n * 10 + 0]);
277                         PRIM_INT__f_s_s_s[n * 10 + 0] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__p_s_s_s[n * 3 + 0]), PRIM_INT__f_s_s_s[n * 10 + 0]);
278 
279                         PRIM_INT__f_s_s_s[n * 10 + 1] = SIMINT_MUL(P_PA[1], PRIM_INT__d_s_s_s[n * 6 + 0]);
280                         PRIM_INT__f_s_s_s[n * 10 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__f_s_s_s[n * 10 + 1]);
281 
282                         PRIM_INT__f_s_s_s[n * 10 + 2] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 0]);
283                         PRIM_INT__f_s_s_s[n * 10 + 2] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__f_s_s_s[n * 10 + 2]);
284 
285                         PRIM_INT__f_s_s_s[n * 10 + 3] = SIMINT_MUL(P_PA[0], PRIM_INT__d_s_s_s[n * 6 + 3]);
286                         PRIM_INT__f_s_s_s[n * 10 + 3] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__f_s_s_s[n * 10 + 3]);
287 
288                         PRIM_INT__f_s_s_s[n * 10 + 4] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 1]);
289                         PRIM_INT__f_s_s_s[n * 10 + 4] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 1], PRIM_INT__f_s_s_s[n * 10 + 4]);
290 
291                         PRIM_INT__f_s_s_s[n * 10 + 5] = SIMINT_MUL(P_PA[0], PRIM_INT__d_s_s_s[n * 6 + 5]);
292                         PRIM_INT__f_s_s_s[n * 10 + 5] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__f_s_s_s[n * 10 + 5]);
293 
294                         PRIM_INT__f_s_s_s[n * 10 + 6] = SIMINT_MUL(P_PA[1], PRIM_INT__d_s_s_s[n * 6 + 3]);
295                         PRIM_INT__f_s_s_s[n * 10 + 6] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__f_s_s_s[n * 10 + 6]);
296                         PRIM_INT__f_s_s_s[n * 10 + 6] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__p_s_s_s[n * 3 + 1]), PRIM_INT__f_s_s_s[n * 10 + 6]);
297 
298                         PRIM_INT__f_s_s_s[n * 10 + 7] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 3]);
299                         PRIM_INT__f_s_s_s[n * 10 + 7] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__f_s_s_s[n * 10 + 7]);
300 
301                         PRIM_INT__f_s_s_s[n * 10 + 8] = SIMINT_MUL(P_PA[1], PRIM_INT__d_s_s_s[n * 6 + 5]);
302                         PRIM_INT__f_s_s_s[n * 10 + 8] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__f_s_s_s[n * 10 + 8]);
303 
304                         PRIM_INT__f_s_s_s[n * 10 + 9] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 5]);
305                         PRIM_INT__f_s_s_s[n * 10 + 9] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__f_s_s_s[n * 10 + 9]);
306                         PRIM_INT__f_s_s_s[n * 10 + 9] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__p_s_s_s[n * 3 + 2]), PRIM_INT__f_s_s_s[n * 10 + 9]);
307 
308                     }
309 
310 
311                     VRR_I_g_s_s_s(
312                             PRIM_INT__g_s_s_s,
313                             PRIM_INT__f_s_s_s,
314                             PRIM_INT__d_s_s_s,
315                             P_PA,
316                             a_over_p,
317                             aop_PQ,
318                             one_over_2p,
319                             5);
320 
321 
322                     VRR_I_h_s_s_s(
323                             PRIM_INT__h_s_s_s,
324                             PRIM_INT__g_s_s_s,
325                             PRIM_INT__f_s_s_s,
326                             P_PA,
327                             a_over_p,
328                             aop_PQ,
329                             one_over_2p,
330                             4);
331 
332 
333                     ostei_general_vrr_K(5, 0, 1, 0, 2,
334                             one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
335                             PRIM_INT__h_s_s_s, NULL, NULL, PRIM_INT__g_s_s_s, NULL, PRIM_INT__h_s_p_s);
336 
337 
338                     VRR_K_g_s_p_s(
339                             PRIM_INT__g_s_p_s,
340                             PRIM_INT__g_s_s_s,
341                             PRIM_INT__f_s_s_s,
342                             Q_PA,
343                             aoq_PQ,
344                             one_over_2pq,
345                             2);
346 
347 
348                     ostei_general_vrr_K(5, 0, 2, 0, 1,
349                             one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
350                             PRIM_INT__h_s_p_s, PRIM_INT__h_s_s_s, NULL, PRIM_INT__g_s_p_s, NULL, PRIM_INT__h_s_d_s);
351 
352 
353                     ostei_general_vrr1_I(6, 3,
354                             one_over_2p, a_over_p, aop_PQ, P_PA,
355                             PRIM_INT__h_s_s_s, PRIM_INT__g_s_s_s, PRIM_INT__i_s_s_s);
356 
357 
358                     ostei_general_vrr_K(6, 0, 1, 0, 2,
359                             one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
360                             PRIM_INT__i_s_s_s, NULL, NULL, PRIM_INT__h_s_s_s, NULL, PRIM_INT__i_s_p_s);
361 
362 
363                     ostei_general_vrr_K(6, 0, 2, 0, 1,
364                             one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
365                             PRIM_INT__i_s_p_s, PRIM_INT__i_s_s_s, NULL, PRIM_INT__h_s_p_s, NULL, PRIM_INT__i_s_d_s);
366 
367 
368 
369 
370                     ////////////////////////////////////
371                     // Accumulate contracted integrals
372                     ////////////////////////////////////
373                     if(lastoffset == 0)
374                     {
375                         contract_all(126, PRIM_INT__h_s_d_s, PRIM_PTR_INT__h_s_d_s);
376                         contract_all(168, PRIM_INT__i_s_d_s, PRIM_PTR_INT__i_s_d_s);
377                     }
378                     else
379                     {
380                         contract(126, shelloffsets, PRIM_INT__h_s_d_s, PRIM_PTR_INT__h_s_d_s);
381                         contract(168, shelloffsets, PRIM_INT__i_s_d_s, PRIM_PTR_INT__i_s_d_s);
382                         PRIM_PTR_INT__h_s_d_s += lastoffset*126;
383                         PRIM_PTR_INT__i_s_d_s += lastoffset*168;
384                     }
385 
386                 }  // close loop over j
387             }  // close loop over i
388 
389             //Advance to the next batch
390             jstart = SIMINT_SIMD_ROUND(jend);
391 
392             //////////////////////////////////////////////
393             // Contracted integrals: Horizontal recurrance
394             //////////////////////////////////////////////
395 
396 
397             const double hAB[3] = { P.AB_x[ab], P.AB_y[ab], P.AB_z[ab] };
398 
399 
400             for(abcd = 0; abcd < nshellbatch; ++abcd, ++real_abcd)
401             {
402 
403                 // set up HRR pointers
404                 double const * restrict HRR_INT__h_s_d_s = INT__h_s_d_s + abcd * 126;
405                 double const * restrict HRR_INT__i_s_d_s = INT__i_s_d_s + abcd * 168;
406                 double * restrict HRR_INT__h_p_d_s = INT__h_p_d_s + real_abcd * 378;
407 
408                 // form INT__h_p_d_s
409                 ostei_general_hrr_J(5, 1, 2, 0, hAB, HRR_INT__i_s_d_s, HRR_INT__h_s_d_s, HRR_INT__h_p_d_s);
410 
411 
412             }  // close HRR loop
413 
414 
415         }   // close loop cdbatch
416 
417         istart = iend;
418     }  // close loop over ab
419 
420     return P.nshell12_clip * Q.nshell12_clip;
421 }
422 
ostei_p_h_d_s(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__p_h_d_s)423 int ostei_p_h_d_s(struct simint_multi_shellpair const P,
424                   struct simint_multi_shellpair const Q,
425                   double screen_tol,
426                   double * const restrict work,
427                   double * const restrict INT__p_h_d_s)
428 {
429     double P_AB[3*P.nshell12];
430     struct simint_multi_shellpair P_tmp = P;
431     P_tmp.PA_x = P.PB_x;  P_tmp.PA_y = P.PB_y;  P_tmp.PA_z = P.PB_z;
432     P_tmp.PB_x = P.PA_x;  P_tmp.PB_y = P.PA_y;  P_tmp.PB_z = P.PA_z;
433     P_tmp.AB_x = P_AB;
434     P_tmp.AB_y = P_AB + P.nshell12;
435     P_tmp.AB_z = P_AB + 2*P.nshell12;
436 
437     for(int i = 0; i < P.nshell12; i++)
438     {
439         P_tmp.AB_x[i] = -P.AB_x[i];
440         P_tmp.AB_y[i] = -P.AB_y[i];
441         P_tmp.AB_z[i] = -P.AB_z[i];
442     }
443 
444     int ret = ostei_h_p_d_s(P_tmp, Q, screen_tol, work, INT__p_h_d_s);
445     double buffer[378] SIMINT_ALIGN_ARRAY_DBL;
446 
447     for(int q = 0; q < ret; q++)
448     {
449         int idx = 0;
450         for(int a = 0; a < 3; ++a)
451         for(int b = 0; b < 21; ++b)
452         for(int c = 0; c < 6; ++c)
453         for(int d = 0; d < 1; ++d)
454             buffer[idx++] = INT__p_h_d_s[q*378+b*18+a*6+c*1+d];
455 
456         memcpy(INT__p_h_d_s+q*378, buffer, 378*sizeof(double));
457     }
458 
459     return ret;
460 }
461 
ostei_h_p_s_d(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__h_p_s_d)462 int ostei_h_p_s_d(struct simint_multi_shellpair const P,
463                   struct simint_multi_shellpair const Q,
464                   double screen_tol,
465                   double * const restrict work,
466                   double * const restrict INT__h_p_s_d)
467 {
468     double Q_AB[3*Q.nshell12];
469     struct simint_multi_shellpair Q_tmp = Q;
470     Q_tmp.PA_x = Q.PB_x;  Q_tmp.PA_y = Q.PB_y;  Q_tmp.PA_z = Q.PB_z;
471     Q_tmp.PB_x = Q.PA_x;  Q_tmp.PB_y = Q.PA_y;  Q_tmp.PB_z = Q.PA_z;
472     Q_tmp.AB_x = Q_AB;
473     Q_tmp.AB_y = Q_AB + Q.nshell12;
474     Q_tmp.AB_z = Q_AB + 2*Q.nshell12;
475 
476     for(int i = 0; i < Q.nshell12; i++)
477     {
478         Q_tmp.AB_x[i] = -Q.AB_x[i];
479         Q_tmp.AB_y[i] = -Q.AB_y[i];
480         Q_tmp.AB_z[i] = -Q.AB_z[i];
481     }
482 
483     int ret = ostei_h_p_d_s(P, Q_tmp, screen_tol, work, INT__h_p_s_d);
484     double buffer[378] SIMINT_ALIGN_ARRAY_DBL;
485 
486     for(int q = 0; q < ret; q++)
487     {
488         int idx = 0;
489         for(int a = 0; a < 21; ++a)
490         for(int b = 0; b < 3; ++b)
491         for(int c = 0; c < 1; ++c)
492         for(int d = 0; d < 6; ++d)
493             buffer[idx++] = INT__h_p_s_d[q*378+a*18+b*6+d*1+c];
494 
495         memcpy(INT__h_p_s_d+q*378, buffer, 378*sizeof(double));
496     }
497 
498     return ret;
499 }
500 
ostei_p_h_s_d(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__p_h_s_d)501 int ostei_p_h_s_d(struct simint_multi_shellpair const P,
502                   struct simint_multi_shellpair const Q,
503                   double screen_tol,
504                   double * const restrict work,
505                   double * const restrict INT__p_h_s_d)
506 {
507     double P_AB[3*P.nshell12];
508     struct simint_multi_shellpair P_tmp = P;
509     P_tmp.PA_x = P.PB_x;  P_tmp.PA_y = P.PB_y;  P_tmp.PA_z = P.PB_z;
510     P_tmp.PB_x = P.PA_x;  P_tmp.PB_y = P.PA_y;  P_tmp.PB_z = P.PA_z;
511     P_tmp.AB_x = P_AB;
512     P_tmp.AB_y = P_AB + P.nshell12;
513     P_tmp.AB_z = P_AB + 2*P.nshell12;
514 
515     for(int i = 0; i < P.nshell12; i++)
516     {
517         P_tmp.AB_x[i] = -P.AB_x[i];
518         P_tmp.AB_y[i] = -P.AB_y[i];
519         P_tmp.AB_z[i] = -P.AB_z[i];
520     }
521 
522     double Q_AB[3*Q.nshell12];
523     struct simint_multi_shellpair Q_tmp = Q;
524     Q_tmp.PA_x = Q.PB_x;  Q_tmp.PA_y = Q.PB_y;  Q_tmp.PA_z = Q.PB_z;
525     Q_tmp.PB_x = Q.PA_x;  Q_tmp.PB_y = Q.PA_y;  Q_tmp.PB_z = Q.PA_z;
526     Q_tmp.AB_x = Q_AB;
527     Q_tmp.AB_y = Q_AB + Q.nshell12;
528     Q_tmp.AB_z = Q_AB + 2*Q.nshell12;
529 
530     for(int i = 0; i < Q.nshell12; i++)
531     {
532         Q_tmp.AB_x[i] = -Q.AB_x[i];
533         Q_tmp.AB_y[i] = -Q.AB_y[i];
534         Q_tmp.AB_z[i] = -Q.AB_z[i];
535     }
536 
537     int ret = ostei_h_p_d_s(P_tmp, Q_tmp, screen_tol, work, INT__p_h_s_d);
538     double buffer[378] SIMINT_ALIGN_ARRAY_DBL;
539 
540     for(int q = 0; q < ret; q++)
541     {
542         int idx = 0;
543         for(int a = 0; a < 3; ++a)
544         for(int b = 0; b < 21; ++b)
545         for(int c = 0; c < 1; ++c)
546         for(int d = 0; d < 6; ++d)
547             buffer[idx++] = INT__p_h_s_d[q*378+b*18+a*6+d*1+c];
548 
549         memcpy(INT__p_h_s_d+q*378, buffer, 378*sizeof(double));
550     }
551 
552     return ret;
553 }
554 
555