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