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