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