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_k_g_s_s(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__k_g_s_s)8 int ostei_k_g_s_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__k_g_s_s)
13 {
14 
15     SIMINT_ASSUME_ALIGN_DBL(work);
16     SIMINT_ASSUME_ALIGN_DBL(INT__k_g_s_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__k_s_s_s = work + (SIMINT_NSHELL_SIMD * 0);
29     double * const INT__l_s_s_s = work + (SIMINT_NSHELL_SIMD * 36);
30     double * const INT__m_s_s_s = work + (SIMINT_NSHELL_SIMD * 81);
31     double * const INT__n_s_s_s = work + (SIMINT_NSHELL_SIMD * 136);
32     double * const INT__o_s_s_s = work + (SIMINT_NSHELL_SIMD * 202);
33     SIMINT_DBLTYPE * const primwork = (SIMINT_DBLTYPE *)(work + SIMINT_NSHELL_SIMD*280);
34     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_s = primwork + 0;
35     SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_s_s = primwork + 12;
36     SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_s_s = primwork + 45;
37     SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_s_s = primwork + 105;
38     SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_s_s = primwork + 195;
39     SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_s_s = primwork + 315;
40     SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_s_s = primwork + 462;
41     SIMINT_DBLTYPE * const restrict PRIM_INT__k_s_s_s = primwork + 630;
42     SIMINT_DBLTYPE * const restrict PRIM_INT__l_s_s_s = primwork + 810;
43     SIMINT_DBLTYPE * const restrict PRIM_INT__m_s_s_s = primwork + 990;
44     SIMINT_DBLTYPE * const restrict PRIM_INT__n_s_s_s = primwork + 1155;
45     SIMINT_DBLTYPE * const restrict PRIM_INT__o_s_s_s = primwork + 1287;
46     double * const hrrwork = (double *)(primwork + 1365);
47     double * const HRR_INT__k_p_s_s = hrrwork + 0;
48     double * const HRR_INT__k_d_s_s = hrrwork + 108;
49     double * const HRR_INT__k_f_s_s = hrrwork + 324;
50     double * const HRR_INT__l_p_s_s = hrrwork + 684;
51     double * const HRR_INT__l_d_s_s = hrrwork + 819;
52     double * const HRR_INT__l_f_s_s = hrrwork + 1089;
53     double * const HRR_INT__m_p_s_s = hrrwork + 1539;
54     double * const HRR_INT__m_d_s_s = hrrwork + 1704;
55     double * const HRR_INT__n_p_s_s = hrrwork + 2034;
56 
57 
58     // Create constants
59     const SIMINT_DBLTYPE const_1 = SIMINT_DBLSET1(1);
60     const SIMINT_DBLTYPE const_10 = SIMINT_DBLSET1(10);
61     const SIMINT_DBLTYPE const_2 = SIMINT_DBLSET1(2);
62     const SIMINT_DBLTYPE const_3 = SIMINT_DBLSET1(3);
63     const SIMINT_DBLTYPE const_4 = SIMINT_DBLSET1(4);
64     const SIMINT_DBLTYPE const_5 = SIMINT_DBLSET1(5);
65     const SIMINT_DBLTYPE const_6 = SIMINT_DBLSET1(6);
66     const SIMINT_DBLTYPE const_7 = SIMINT_DBLSET1(7);
67     const SIMINT_DBLTYPE const_8 = SIMINT_DBLSET1(8);
68     const SIMINT_DBLTYPE const_9 = SIMINT_DBLSET1(9);
69     const SIMINT_DBLTYPE one_half = SIMINT_DBLSET1(0.5);
70 
71 
72     ////////////////////////////////////////
73     // Loop over shells and primitives
74     ////////////////////////////////////////
75 
76     real_abcd = 0;
77     istart = 0;
78     for(ab = 0; ab < P.nshell12_clip; ++ab)
79     {
80         const int iend = istart + P.nprim12[ab];
81 
82         cd = 0;
83         jstart = 0;
84 
85         for(cd = 0; cd < Q.nshell12_clip; cd += SIMINT_NSHELL_SIMD)
86         {
87             const int nshellbatch = ((cd + SIMINT_NSHELL_SIMD) > Q.nshell12_clip) ? Q.nshell12_clip - cd : SIMINT_NSHELL_SIMD;
88             int jend = jstart;
89             for(i = 0; i < nshellbatch; i++)
90                 jend += Q.nprim12[cd+i];
91 
92             // Clear the beginning of the workspace (where we are accumulating integrals)
93             memset(work, 0, SIMINT_NSHELL_SIMD * 280 * sizeof(double));
94             abcd = 0;
95 
96 
97             for(i = istart; i < iend; ++i)
98             {
99                 SIMINT_DBLTYPE bra_screen_max;  // only used if check_screen
100 
101                 if(check_screen)
102                 {
103                     // Skip this whole thing if always insignificant
104                     if((P.screen[i] * Q.screen_max) < screen_tol)
105                         continue;
106                     bra_screen_max = SIMINT_DBLSET1(P.screen[i]);
107                 }
108 
109                 icd = 0;
110                 iprimcd = 0;
111                 nprim_icd = Q.nprim12[cd];
112                 double * restrict PRIM_PTR_INT__k_s_s_s = INT__k_s_s_s + abcd * 36;
113                 double * restrict PRIM_PTR_INT__l_s_s_s = INT__l_s_s_s + abcd * 45;
114                 double * restrict PRIM_PTR_INT__m_s_s_s = INT__m_s_s_s + abcd * 55;
115                 double * restrict PRIM_PTR_INT__n_s_s_s = INT__n_s_s_s + abcd * 66;
116                 double * restrict PRIM_PTR_INT__o_s_s_s = INT__o_s_s_s + abcd * 78;
117 
118 
119 
120                 // Load these one per loop over i
121                 const SIMINT_DBLTYPE P_alpha = SIMINT_DBLSET1(P.alpha[i]);
122                 const SIMINT_DBLTYPE P_prefac = SIMINT_DBLSET1(P.prefac[i]);
123                 const SIMINT_DBLTYPE Pxyz[3] = { SIMINT_DBLSET1(P.x[i]), SIMINT_DBLSET1(P.y[i]), SIMINT_DBLSET1(P.z[i]) };
124 
125                 const SIMINT_DBLTYPE P_PA[3] = { SIMINT_DBLSET1(P.PA_x[i]), SIMINT_DBLSET1(P.PA_y[i]), SIMINT_DBLSET1(P.PA_z[i]) };
126 
127                 for(j = jstart; j < jend; j += SIMINT_SIMD_LEN)
128                 {
129                     // calculate the shell offsets
130                     // these are the offset from the shell pointed to by cd
131                     // for each element
132                     int shelloffsets[SIMINT_SIMD_LEN] = {0};
133                     int lastoffset = 0;
134                     const int nlane = ( ((j + SIMINT_SIMD_LEN) < jend) ? SIMINT_SIMD_LEN : (jend - j));
135 
136                     if((iprimcd + SIMINT_SIMD_LEN) >= nprim_icd)
137                     {
138                         // Handle if the first element of the vector is a new shell
139                         if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
140                         {
141                             nprim_icd += Q.nprim12[cd + (++icd)];
142                             PRIM_PTR_INT__k_s_s_s += 36;
143                             PRIM_PTR_INT__l_s_s_s += 45;
144                             PRIM_PTR_INT__m_s_s_s += 55;
145                             PRIM_PTR_INT__n_s_s_s += 66;
146                             PRIM_PTR_INT__o_s_s_s += 78;
147                         }
148                         iprimcd++;
149                         for(n = 1; n < SIMINT_SIMD_LEN; ++n)
150                         {
151                             if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
152                             {
153                                 shelloffsets[n] = shelloffsets[n-1] + 1;
154                                 lastoffset++;
155                                 nprim_icd += Q.nprim12[cd + (++icd)];
156                             }
157                             else
158                                 shelloffsets[n] = shelloffsets[n-1];
159                             iprimcd++;
160                         }
161                     }
162                     else
163                         iprimcd += SIMINT_SIMD_LEN;
164 
165                     // Do we have to compute this vector (or has it been screened out)?
166                     // (not_screened != 0 means we have to do this vector)
167                     if(check_screen)
168                     {
169                         const double vmax = vector_max(SIMINT_MUL(bra_screen_max, SIMINT_DBLLOAD(Q.screen, j)));
170                         if(vmax < screen_tol)
171                         {
172                             PRIM_PTR_INT__k_s_s_s += lastoffset*36;
173                             PRIM_PTR_INT__l_s_s_s += lastoffset*45;
174                             PRIM_PTR_INT__m_s_s_s += lastoffset*55;
175                             PRIM_PTR_INT__n_s_s_s += lastoffset*66;
176                             PRIM_PTR_INT__o_s_s_s += lastoffset*78;
177                             continue;
178                         }
179                     }
180 
181                     const SIMINT_DBLTYPE Q_alpha = SIMINT_DBLLOAD(Q.alpha, j);
182                     const SIMINT_DBLTYPE PQalpha_mul = SIMINT_MUL(P_alpha, Q_alpha);
183                     const SIMINT_DBLTYPE PQalpha_sum = SIMINT_ADD(P_alpha, Q_alpha);
184                     const SIMINT_DBLTYPE one_over_PQalpha_sum = SIMINT_DIV(const_1, PQalpha_sum);
185 
186 
187                     /* construct R2 = (Px - Qx)**2 + (Py - Qy)**2 + (Pz -Qz)**2 */
188                     SIMINT_DBLTYPE PQ[3];
189                     PQ[0] = SIMINT_SUB(Pxyz[0], SIMINT_DBLLOAD(Q.x, j));
190                     PQ[1] = SIMINT_SUB(Pxyz[1], SIMINT_DBLLOAD(Q.y, j));
191                     PQ[2] = SIMINT_SUB(Pxyz[2], SIMINT_DBLLOAD(Q.z, j));
192                     SIMINT_DBLTYPE R2 = SIMINT_MUL(PQ[0], PQ[0]);
193                     R2 = SIMINT_FMADD(PQ[1], PQ[1], R2);
194                     R2 = SIMINT_FMADD(PQ[2], PQ[2], R2);
195 
196                     const SIMINT_DBLTYPE alpha = SIMINT_MUL(PQalpha_mul, one_over_PQalpha_sum); // alpha from MEST
197                     const SIMINT_DBLTYPE one_over_p = SIMINT_DIV(const_1, P_alpha);
198                     const SIMINT_DBLTYPE one_over_q = SIMINT_DIV(const_1, Q_alpha);
199                     const SIMINT_DBLTYPE one_over_2p = SIMINT_MUL(one_half, one_over_p);
200                     const SIMINT_DBLTYPE one_over_2q = SIMINT_MUL(one_half, one_over_q);
201                     const SIMINT_DBLTYPE one_over_2pq = SIMINT_MUL(one_half, one_over_PQalpha_sum);
202 
203                     // NOTE: Minus sign!
204                     const SIMINT_DBLTYPE a_over_p = SIMINT_MUL(SIMINT_NEG(alpha), one_over_p);
205                     SIMINT_DBLTYPE aop_PQ[3];
206                     aop_PQ[0] = SIMINT_MUL(a_over_p, PQ[0]);
207                     aop_PQ[1] = SIMINT_MUL(a_over_p, PQ[1]);
208                     aop_PQ[2] = SIMINT_MUL(a_over_p, PQ[2]);
209 
210 
211                     //////////////////////////////////////////////
212                     // Fjt function section
213                     // Maximum v value: 11
214                     //////////////////////////////////////////////
215                     // The parameter to the Fjt function
216                     const SIMINT_DBLTYPE F_x = SIMINT_MUL(R2, alpha);
217 
218 
219                     const SIMINT_DBLTYPE Q_prefac = mask_load(nlane, Q.prefac + j);
220 
221 
222                     boys_F_split(PRIM_INT__s_s_s_s, F_x, 11);
223                     SIMINT_DBLTYPE prefac = SIMINT_SQRT(one_over_PQalpha_sum);
224                     prefac = SIMINT_MUL(SIMINT_MUL(P_prefac, Q_prefac), prefac);
225                     for(n = 0; n <= 11; n++)
226                         PRIM_INT__s_s_s_s[n] = SIMINT_MUL(PRIM_INT__s_s_s_s[n], prefac);
227 
228                     //////////////////////////////////////////////
229                     // Primitive integrals: Vertical recurrance
230                     //////////////////////////////////////////////
231 
232                     const SIMINT_DBLTYPE vrr_const_1_over_2p = one_over_2p;
233                     const SIMINT_DBLTYPE vrr_const_2_over_2p = SIMINT_MUL(const_2, one_over_2p);
234                     const SIMINT_DBLTYPE vrr_const_3_over_2p = SIMINT_MUL(const_3, one_over_2p);
235                     const SIMINT_DBLTYPE vrr_const_4_over_2p = SIMINT_MUL(const_4, one_over_2p);
236                     const SIMINT_DBLTYPE vrr_const_5_over_2p = SIMINT_MUL(const_5, one_over_2p);
237                     const SIMINT_DBLTYPE vrr_const_6_over_2p = SIMINT_MUL(const_6, one_over_2p);
238                     const SIMINT_DBLTYPE vrr_const_7_over_2p = SIMINT_MUL(const_7, one_over_2p);
239                     const SIMINT_DBLTYPE vrr_const_8_over_2p = SIMINT_MUL(const_8, one_over_2p);
240                     const SIMINT_DBLTYPE vrr_const_9_over_2p = SIMINT_MUL(const_9, one_over_2p);
241                     const SIMINT_DBLTYPE vrr_const_10_over_2p = SIMINT_MUL(const_10, one_over_2p);
242 
243 
244 
245                     // Forming PRIM_INT__p_s_s_s[11 * 3];
246                     for(n = 0; n < 11; ++n)  // loop over orders of auxiliary function
247                     {
248 
249                         PRIM_INT__p_s_s_s[n * 3 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
250                         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]);
251 
252                         PRIM_INT__p_s_s_s[n * 3 + 1] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
253                         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]);
254 
255                         PRIM_INT__p_s_s_s[n * 3 + 2] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
256                         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]);
257 
258                     }
259 
260 
261 
262                     // Forming PRIM_INT__d_s_s_s[10 * 6];
263                     for(n = 0; n < 10; ++n)  // loop over orders of auxiliary function
264                     {
265 
266                         PRIM_INT__d_s_s_s[n * 6 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__p_s_s_s[n * 3 + 0]);
267                         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]);
268                         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]);
269 
270                         PRIM_INT__d_s_s_s[n * 6 + 3] = SIMINT_MUL(P_PA[1], PRIM_INT__p_s_s_s[n * 3 + 1]);
271                         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]);
272                         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]);
273 
274                         PRIM_INT__d_s_s_s[n * 6 + 5] = SIMINT_MUL(P_PA[2], PRIM_INT__p_s_s_s[n * 3 + 2]);
275                         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]);
276                         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]);
277 
278                     }
279 
280 
281 
282                     // Forming PRIM_INT__f_s_s_s[9 * 10];
283                     for(n = 0; n < 9; ++n)  // loop over orders of auxiliary function
284                     {
285 
286                         PRIM_INT__f_s_s_s[n * 10 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__d_s_s_s[n * 6 + 0]);
287                         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]);
288                         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]);
289 
290                         PRIM_INT__f_s_s_s[n * 10 + 6] = SIMINT_MUL(P_PA[1], PRIM_INT__d_s_s_s[n * 6 + 3]);
291                         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]);
292                         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]);
293 
294                         PRIM_INT__f_s_s_s[n * 10 + 9] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 5]);
295                         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]);
296                         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]);
297 
298                     }
299 
300 
301                     VRR_I_g_s_s_s(
302                             PRIM_INT__g_s_s_s,
303                             PRIM_INT__f_s_s_s,
304                             PRIM_INT__d_s_s_s,
305                             P_PA,
306                             a_over_p,
307                             aop_PQ,
308                             one_over_2p,
309                             8);
310 
311 
312                     VRR_I_h_s_s_s(
313                             PRIM_INT__h_s_s_s,
314                             PRIM_INT__g_s_s_s,
315                             PRIM_INT__f_s_s_s,
316                             P_PA,
317                             a_over_p,
318                             aop_PQ,
319                             one_over_2p,
320                             7);
321 
322 
323                     ostei_general_vrr1_I(6, 6,
324                             one_over_2p, a_over_p, aop_PQ, P_PA,
325                             PRIM_INT__h_s_s_s, PRIM_INT__g_s_s_s, PRIM_INT__i_s_s_s);
326 
327 
328                     ostei_general_vrr1_I(7, 5,
329                             one_over_2p, a_over_p, aop_PQ, P_PA,
330                             PRIM_INT__i_s_s_s, PRIM_INT__h_s_s_s, PRIM_INT__k_s_s_s);
331 
332 
333                     ostei_general_vrr1_I(8, 4,
334                             one_over_2p, a_over_p, aop_PQ, P_PA,
335                             PRIM_INT__k_s_s_s, PRIM_INT__i_s_s_s, PRIM_INT__l_s_s_s);
336 
337 
338                     ostei_general_vrr1_I(9, 3,
339                             one_over_2p, a_over_p, aop_PQ, P_PA,
340                             PRIM_INT__l_s_s_s, PRIM_INT__k_s_s_s, PRIM_INT__m_s_s_s);
341 
342 
343                     ostei_general_vrr1_I(10, 2,
344                             one_over_2p, a_over_p, aop_PQ, P_PA,
345                             PRIM_INT__m_s_s_s, PRIM_INT__l_s_s_s, PRIM_INT__n_s_s_s);
346 
347 
348                     ostei_general_vrr1_I(11, 1,
349                             one_over_2p, a_over_p, aop_PQ, P_PA,
350                             PRIM_INT__n_s_s_s, PRIM_INT__m_s_s_s, PRIM_INT__o_s_s_s);
351 
352 
353 
354 
355                     ////////////////////////////////////
356                     // Accumulate contracted integrals
357                     ////////////////////////////////////
358                     if(lastoffset == 0)
359                     {
360                         contract_all(36, PRIM_INT__k_s_s_s, PRIM_PTR_INT__k_s_s_s);
361                         contract_all(45, PRIM_INT__l_s_s_s, PRIM_PTR_INT__l_s_s_s);
362                         contract_all(55, PRIM_INT__m_s_s_s, PRIM_PTR_INT__m_s_s_s);
363                         contract_all(66, PRIM_INT__n_s_s_s, PRIM_PTR_INT__n_s_s_s);
364                         contract_all(78, PRIM_INT__o_s_s_s, PRIM_PTR_INT__o_s_s_s);
365                     }
366                     else
367                     {
368                         contract(36, shelloffsets, PRIM_INT__k_s_s_s, PRIM_PTR_INT__k_s_s_s);
369                         contract(45, shelloffsets, PRIM_INT__l_s_s_s, PRIM_PTR_INT__l_s_s_s);
370                         contract(55, shelloffsets, PRIM_INT__m_s_s_s, PRIM_PTR_INT__m_s_s_s);
371                         contract(66, shelloffsets, PRIM_INT__n_s_s_s, PRIM_PTR_INT__n_s_s_s);
372                         contract(78, shelloffsets, PRIM_INT__o_s_s_s, PRIM_PTR_INT__o_s_s_s);
373                         PRIM_PTR_INT__k_s_s_s += lastoffset*36;
374                         PRIM_PTR_INT__l_s_s_s += lastoffset*45;
375                         PRIM_PTR_INT__m_s_s_s += lastoffset*55;
376                         PRIM_PTR_INT__n_s_s_s += lastoffset*66;
377                         PRIM_PTR_INT__o_s_s_s += lastoffset*78;
378                     }
379 
380                 }  // close loop over j
381             }  // close loop over i
382 
383             //Advance to the next batch
384             jstart = SIMINT_SIMD_ROUND(jend);
385 
386             //////////////////////////////////////////////
387             // Contracted integrals: Horizontal recurrance
388             //////////////////////////////////////////////
389 
390 
391             const double hAB[3] = { P.AB_x[ab], P.AB_y[ab], P.AB_z[ab] };
392 
393 
394             for(abcd = 0; abcd < nshellbatch; ++abcd, ++real_abcd)
395             {
396 
397                 // set up HRR pointers
398                 double const * restrict HRR_INT__k_s_s_s = INT__k_s_s_s + abcd * 36;
399                 double const * restrict HRR_INT__l_s_s_s = INT__l_s_s_s + abcd * 45;
400                 double const * restrict HRR_INT__m_s_s_s = INT__m_s_s_s + abcd * 55;
401                 double const * restrict HRR_INT__n_s_s_s = INT__n_s_s_s + abcd * 66;
402                 double const * restrict HRR_INT__o_s_s_s = INT__o_s_s_s + abcd * 78;
403                 double * restrict HRR_INT__k_g_s_s = INT__k_g_s_s + real_abcd * 540;
404 
405                 // form INT__k_p_s_s
406                 ostei_general_hrr_J(7, 1, 0, 0, hAB, HRR_INT__l_s_s_s, HRR_INT__k_s_s_s, HRR_INT__k_p_s_s);
407 
408                 // form INT__l_p_s_s
409                 ostei_general_hrr_J(8, 1, 0, 0, hAB, HRR_INT__m_s_s_s, HRR_INT__l_s_s_s, HRR_INT__l_p_s_s);
410 
411                 // form INT__m_p_s_s
412                 ostei_general_hrr_J(9, 1, 0, 0, hAB, HRR_INT__n_s_s_s, HRR_INT__m_s_s_s, HRR_INT__m_p_s_s);
413 
414                 // form INT__n_p_s_s
415                 ostei_general_hrr_J(10, 1, 0, 0, hAB, HRR_INT__o_s_s_s, HRR_INT__n_s_s_s, HRR_INT__n_p_s_s);
416 
417                 // form INT__k_d_s_s
418                 ostei_general_hrr_J(7, 2, 0, 0, hAB, HRR_INT__l_p_s_s, HRR_INT__k_p_s_s, HRR_INT__k_d_s_s);
419 
420                 // form INT__l_d_s_s
421                 ostei_general_hrr_J(8, 2, 0, 0, hAB, HRR_INT__m_p_s_s, HRR_INT__l_p_s_s, HRR_INT__l_d_s_s);
422 
423                 // form INT__m_d_s_s
424                 ostei_general_hrr_J(9, 2, 0, 0, hAB, HRR_INT__n_p_s_s, HRR_INT__m_p_s_s, HRR_INT__m_d_s_s);
425 
426                 // form INT__k_f_s_s
427                 ostei_general_hrr_J(7, 3, 0, 0, hAB, HRR_INT__l_d_s_s, HRR_INT__k_d_s_s, HRR_INT__k_f_s_s);
428 
429                 // form INT__l_f_s_s
430                 ostei_general_hrr_J(8, 3, 0, 0, hAB, HRR_INT__m_d_s_s, HRR_INT__l_d_s_s, HRR_INT__l_f_s_s);
431 
432                 // form INT__k_g_s_s
433                 ostei_general_hrr_J(7, 4, 0, 0, hAB, HRR_INT__l_f_s_s, HRR_INT__k_f_s_s, HRR_INT__k_g_s_s);
434 
435 
436             }  // close HRR loop
437 
438 
439         }   // close loop cdbatch
440 
441         istart = iend;
442     }  // close loop over ab
443 
444     return P.nshell12_clip * Q.nshell12_clip;
445 }
446 
ostei_g_k_s_s(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__g_k_s_s)447 int ostei_g_k_s_s(struct simint_multi_shellpair const P,
448                   struct simint_multi_shellpair const Q,
449                   double screen_tol,
450                   double * const restrict work,
451                   double * const restrict INT__g_k_s_s)
452 {
453     double P_AB[3*P.nshell12];
454     struct simint_multi_shellpair P_tmp = P;
455     P_tmp.PA_x = P.PB_x;  P_tmp.PA_y = P.PB_y;  P_tmp.PA_z = P.PB_z;
456     P_tmp.PB_x = P.PA_x;  P_tmp.PB_y = P.PA_y;  P_tmp.PB_z = P.PA_z;
457     P_tmp.AB_x = P_AB;
458     P_tmp.AB_y = P_AB + P.nshell12;
459     P_tmp.AB_z = P_AB + 2*P.nshell12;
460 
461     for(int i = 0; i < P.nshell12; i++)
462     {
463         P_tmp.AB_x[i] = -P.AB_x[i];
464         P_tmp.AB_y[i] = -P.AB_y[i];
465         P_tmp.AB_z[i] = -P.AB_z[i];
466     }
467 
468     int ret = ostei_k_g_s_s(P_tmp, Q, screen_tol, work, INT__g_k_s_s);
469     double buffer[540] SIMINT_ALIGN_ARRAY_DBL;
470 
471     for(int q = 0; q < ret; q++)
472     {
473         int idx = 0;
474         for(int a = 0; a < 15; ++a)
475         for(int b = 0; b < 36; ++b)
476         for(int c = 0; c < 1; ++c)
477         for(int d = 0; d < 1; ++d)
478             buffer[idx++] = INT__g_k_s_s[q*540+b*15+a*1+c*1+d];
479 
480         memcpy(INT__g_k_s_s+q*540, buffer, 540*sizeof(double));
481     }
482 
483     return ret;
484 }
485 
486