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