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