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_g_s_f_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_s_f_s)8 int ostei_g_s_f_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__g_s_f_s)
13 {
14 
15     SIMINT_ASSUME_ALIGN_DBL(work);
16     SIMINT_ASSUME_ALIGN_DBL(INT__g_s_f_s);
17     memset(INT__g_s_f_s, 0, P.nshell12_clip * Q.nshell12_clip * 150 * sizeof(double));
18 
19     int ab, cd, abcd;
20     int istart, jstart;
21     int iprimcd, nprim_icd, icd;
22     const int check_screen = (screen_tol > 0.0);
23     int i, j;
24     int n;
25     int not_screened;
26 
27     // partition workspace
28     SIMINT_DBLTYPE * const primwork = (SIMINT_DBLTYPE *)(work + SIMINT_NSHELL_SIMD*0);
29     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_s = primwork + 0;
30     SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_s_s = primwork + 8;
31     SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_s_s = primwork + 29;
32     SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_p_s = primwork + 65;
33     SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_s_s = primwork + 119;
34     SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_p_s = primwork + 169;
35     SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_d_s = primwork + 259;
36     SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_s_s = primwork + 379;
37     SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_p_s = primwork + 439;
38     SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_d_s = primwork + 574;
39     SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_f_s = primwork + 754;
40     double * const hrrwork = (double *)(primwork + 904);
41 
42 
43     // Create constants
44     const SIMINT_DBLTYPE const_1 = SIMINT_DBLSET1(1);
45     const SIMINT_DBLTYPE const_2 = SIMINT_DBLSET1(2);
46     const SIMINT_DBLTYPE const_3 = SIMINT_DBLSET1(3);
47     const SIMINT_DBLTYPE const_4 = SIMINT_DBLSET1(4);
48     const SIMINT_DBLTYPE one_half = SIMINT_DBLSET1(0.5);
49 
50 
51     ////////////////////////////////////////
52     // Loop over shells and primitives
53     ////////////////////////////////////////
54 
55     abcd = 0;
56     istart = 0;
57     for(ab = 0; ab < P.nshell12_clip; ++ab)
58     {
59         const int iend = istart + P.nprim12[ab];
60 
61         cd = 0;
62         jstart = 0;
63 
64         for(cd = 0; cd < Q.nshell12_clip; cd += SIMINT_NSHELL_SIMD)
65         {
66             const int nshellbatch = ((cd + SIMINT_NSHELL_SIMD) > Q.nshell12_clip) ? Q.nshell12_clip - cd : SIMINT_NSHELL_SIMD;
67             int jend = jstart;
68             for(i = 0; i < nshellbatch; i++)
69                 jend += Q.nprim12[cd+i];
70 
71 
72             for(i = istart; i < iend; ++i)
73             {
74                 SIMINT_DBLTYPE bra_screen_max;  // only used if check_screen
75 
76                 if(check_screen)
77                 {
78                     // Skip this whole thing if always insignificant
79                     if((P.screen[i] * Q.screen_max) < screen_tol)
80                         continue;
81                     bra_screen_max = SIMINT_DBLSET1(P.screen[i]);
82                 }
83 
84                 icd = 0;
85                 iprimcd = 0;
86                 nprim_icd = Q.nprim12[cd];
87                 double * restrict PRIM_PTR_INT__g_s_f_s = INT__g_s_f_s + abcd * 150;
88 
89 
90 
91                 // Load these one per loop over i
92                 const SIMINT_DBLTYPE P_alpha = SIMINT_DBLSET1(P.alpha[i]);
93                 const SIMINT_DBLTYPE P_prefac = SIMINT_DBLSET1(P.prefac[i]);
94                 const SIMINT_DBLTYPE Pxyz[3] = { SIMINT_DBLSET1(P.x[i]), SIMINT_DBLSET1(P.y[i]), SIMINT_DBLSET1(P.z[i]) };
95 
96                 const SIMINT_DBLTYPE P_PA[3] = { SIMINT_DBLSET1(P.PA_x[i]), SIMINT_DBLSET1(P.PA_y[i]), SIMINT_DBLSET1(P.PA_z[i]) };
97 
98                 for(j = jstart; j < jend; j += SIMINT_SIMD_LEN)
99                 {
100                     // calculate the shell offsets
101                     // these are the offset from the shell pointed to by cd
102                     // for each element
103                     int shelloffsets[SIMINT_SIMD_LEN] = {0};
104                     int lastoffset = 0;
105                     const int nlane = ( ((j + SIMINT_SIMD_LEN) < jend) ? SIMINT_SIMD_LEN : (jend - j));
106 
107                     if((iprimcd + SIMINT_SIMD_LEN) >= nprim_icd)
108                     {
109                         // Handle if the first element of the vector is a new shell
110                         if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
111                         {
112                             nprim_icd += Q.nprim12[cd + (++icd)];
113                             PRIM_PTR_INT__g_s_f_s += 150;
114                         }
115                         iprimcd++;
116                         for(n = 1; n < SIMINT_SIMD_LEN; ++n)
117                         {
118                             if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
119                             {
120                                 shelloffsets[n] = shelloffsets[n-1] + 1;
121                                 lastoffset++;
122                                 nprim_icd += Q.nprim12[cd + (++icd)];
123                             }
124                             else
125                                 shelloffsets[n] = shelloffsets[n-1];
126                             iprimcd++;
127                         }
128                     }
129                     else
130                         iprimcd += SIMINT_SIMD_LEN;
131 
132                     // Do we have to compute this vector (or has it been screened out)?
133                     // (not_screened != 0 means we have to do this vector)
134                     if(check_screen)
135                     {
136                         const double vmax = vector_max(SIMINT_MUL(bra_screen_max, SIMINT_DBLLOAD(Q.screen, j)));
137                         if(vmax < screen_tol)
138                         {
139                             PRIM_PTR_INT__g_s_f_s += lastoffset*150;
140                             continue;
141                         }
142                     }
143 
144                     const SIMINT_DBLTYPE Q_alpha = SIMINT_DBLLOAD(Q.alpha, j);
145                     const SIMINT_DBLTYPE PQalpha_mul = SIMINT_MUL(P_alpha, Q_alpha);
146                     const SIMINT_DBLTYPE PQalpha_sum = SIMINT_ADD(P_alpha, Q_alpha);
147                     const SIMINT_DBLTYPE one_over_PQalpha_sum = SIMINT_DIV(const_1, PQalpha_sum);
148 
149 
150                     /* construct R2 = (Px - Qx)**2 + (Py - Qy)**2 + (Pz -Qz)**2 */
151                     SIMINT_DBLTYPE PQ[3];
152                     PQ[0] = SIMINT_SUB(Pxyz[0], SIMINT_DBLLOAD(Q.x, j));
153                     PQ[1] = SIMINT_SUB(Pxyz[1], SIMINT_DBLLOAD(Q.y, j));
154                     PQ[2] = SIMINT_SUB(Pxyz[2], SIMINT_DBLLOAD(Q.z, j));
155                     SIMINT_DBLTYPE R2 = SIMINT_MUL(PQ[0], PQ[0]);
156                     R2 = SIMINT_FMADD(PQ[1], PQ[1], R2);
157                     R2 = SIMINT_FMADD(PQ[2], PQ[2], R2);
158 
159                     const SIMINT_DBLTYPE alpha = SIMINT_MUL(PQalpha_mul, one_over_PQalpha_sum); // alpha from MEST
160                     const SIMINT_DBLTYPE one_over_p = SIMINT_DIV(const_1, P_alpha);
161                     const SIMINT_DBLTYPE one_over_q = SIMINT_DIV(const_1, Q_alpha);
162                     const SIMINT_DBLTYPE one_over_2p = SIMINT_MUL(one_half, one_over_p);
163                     const SIMINT_DBLTYPE one_over_2q = SIMINT_MUL(one_half, one_over_q);
164                     const SIMINT_DBLTYPE one_over_2pq = SIMINT_MUL(one_half, one_over_PQalpha_sum);
165                     const SIMINT_DBLTYPE Q_PA[3] = { SIMINT_DBLLOAD(Q.PA_x, j), SIMINT_DBLLOAD(Q.PA_y, j), SIMINT_DBLLOAD(Q.PA_z, j) };
166 
167                     // NOTE: Minus sign!
168                     const SIMINT_DBLTYPE a_over_p = SIMINT_MUL(SIMINT_NEG(alpha), one_over_p);
169                     SIMINT_DBLTYPE aop_PQ[3];
170                     aop_PQ[0] = SIMINT_MUL(a_over_p, PQ[0]);
171                     aop_PQ[1] = SIMINT_MUL(a_over_p, PQ[1]);
172                     aop_PQ[2] = SIMINT_MUL(a_over_p, PQ[2]);
173 
174                     SIMINT_DBLTYPE a_over_q = SIMINT_MUL(alpha, one_over_q);
175                     SIMINT_DBLTYPE aoq_PQ[3];
176                     aoq_PQ[0] = SIMINT_MUL(a_over_q, PQ[0]);
177                     aoq_PQ[1] = SIMINT_MUL(a_over_q, PQ[1]);
178                     aoq_PQ[2] = SIMINT_MUL(a_over_q, PQ[2]);
179                     // Put a minus sign here so we don't have to in RR routines
180                     a_over_q = SIMINT_NEG(a_over_q);
181 
182 
183                     //////////////////////////////////////////////
184                     // Fjt function section
185                     // Maximum v value: 7
186                     //////////////////////////////////////////////
187                     // The parameter to the Fjt function
188                     const SIMINT_DBLTYPE F_x = SIMINT_MUL(R2, alpha);
189 
190 
191                     const SIMINT_DBLTYPE Q_prefac = mask_load(nlane, Q.prefac + j);
192 
193 
194                     boys_F_split(PRIM_INT__s_s_s_s, F_x, 7);
195                     SIMINT_DBLTYPE prefac = SIMINT_SQRT(one_over_PQalpha_sum);
196                     prefac = SIMINT_MUL(SIMINT_MUL(P_prefac, Q_prefac), prefac);
197                     for(n = 0; n <= 7; n++)
198                         PRIM_INT__s_s_s_s[n] = SIMINT_MUL(PRIM_INT__s_s_s_s[n], prefac);
199 
200                     //////////////////////////////////////////////
201                     // Primitive integrals: Vertical recurrance
202                     //////////////////////////////////////////////
203 
204                     const SIMINT_DBLTYPE vrr_const_1_over_2p = one_over_2p;
205                     const SIMINT_DBLTYPE vrr_const_2_over_2p = SIMINT_MUL(const_2, one_over_2p);
206                     const SIMINT_DBLTYPE vrr_const_3_over_2p = SIMINT_MUL(const_3, one_over_2p);
207                     const SIMINT_DBLTYPE vrr_const_1_over_2q = one_over_2q;
208                     const SIMINT_DBLTYPE vrr_const_2_over_2q = SIMINT_MUL(const_2, one_over_2q);
209                     const SIMINT_DBLTYPE vrr_const_1_over_2pq = one_over_2pq;
210                     const SIMINT_DBLTYPE vrr_const_2_over_2pq = SIMINT_MUL(const_2, one_over_2pq);
211                     const SIMINT_DBLTYPE vrr_const_3_over_2pq = SIMINT_MUL(const_3, one_over_2pq);
212                     const SIMINT_DBLTYPE vrr_const_4_over_2pq = SIMINT_MUL(const_4, one_over_2pq);
213 
214 
215 
216                     // Forming PRIM_INT__p_s_s_s[7 * 3];
217                     for(n = 0; n < 7; ++n)  // loop over orders of auxiliary function
218                     {
219 
220                         PRIM_INT__p_s_s_s[n * 3 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
221                         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]);
222 
223                         PRIM_INT__p_s_s_s[n * 3 + 1] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
224                         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]);
225 
226                         PRIM_INT__p_s_s_s[n * 3 + 2] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
227                         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]);
228 
229                     }
230 
231 
232 
233                     // Forming PRIM_INT__d_s_s_s[6 * 6];
234                     for(n = 0; n < 6; ++n)  // loop over orders of auxiliary function
235                     {
236 
237                         PRIM_INT__d_s_s_s[n * 6 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__p_s_s_s[n * 3 + 0]);
238                         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]);
239                         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]);
240 
241                         PRIM_INT__d_s_s_s[n * 6 + 1] = SIMINT_MUL(P_PA[1], PRIM_INT__p_s_s_s[n * 3 + 0]);
242                         PRIM_INT__d_s_s_s[n * 6 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_s_s[n * 6 + 1]);
243 
244                         PRIM_INT__d_s_s_s[n * 6 + 2] = SIMINT_MUL(P_PA[2], PRIM_INT__p_s_s_s[n * 3 + 0]);
245                         PRIM_INT__d_s_s_s[n * 6 + 2] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_s_s[n * 6 + 2]);
246 
247                         PRIM_INT__d_s_s_s[n * 6 + 3] = SIMINT_MUL(P_PA[1], PRIM_INT__p_s_s_s[n * 3 + 1]);
248                         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]);
249                         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]);
250 
251                         PRIM_INT__d_s_s_s[n * 6 + 4] = SIMINT_MUL(P_PA[2], PRIM_INT__p_s_s_s[n * 3 + 1]);
252                         PRIM_INT__d_s_s_s[n * 6 + 4] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__d_s_s_s[n * 6 + 4]);
253 
254                         PRIM_INT__d_s_s_s[n * 6 + 5] = SIMINT_MUL(P_PA[2], PRIM_INT__p_s_s_s[n * 3 + 2]);
255                         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]);
256                         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]);
257 
258                     }
259 
260 
261 
262                     // Forming PRIM_INT__f_s_s_s[5 * 10];
263                     for(n = 0; n < 5; ++n)  // loop over orders of auxiliary function
264                     {
265 
266                         PRIM_INT__f_s_s_s[n * 10 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__d_s_s_s[n * 6 + 0]);
267                         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]);
268                         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]);
269 
270                         PRIM_INT__f_s_s_s[n * 10 + 1] = SIMINT_MUL(P_PA[1], PRIM_INT__d_s_s_s[n * 6 + 0]);
271                         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]);
272 
273                         PRIM_INT__f_s_s_s[n * 10 + 2] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 0]);
274                         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]);
275 
276                         PRIM_INT__f_s_s_s[n * 10 + 3] = SIMINT_MUL(P_PA[0], PRIM_INT__d_s_s_s[n * 6 + 3]);
277                         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]);
278 
279                         PRIM_INT__f_s_s_s[n * 10 + 4] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 1]);
280                         PRIM_INT__f_s_s_s[n * 10 + 4] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 1], PRIM_INT__f_s_s_s[n * 10 + 4]);
281 
282                         PRIM_INT__f_s_s_s[n * 10 + 5] = SIMINT_MUL(P_PA[0], PRIM_INT__d_s_s_s[n * 6 + 5]);
283                         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]);
284 
285                         PRIM_INT__f_s_s_s[n * 10 + 6] = SIMINT_MUL(P_PA[1], PRIM_INT__d_s_s_s[n * 6 + 3]);
286                         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]);
287                         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]);
288 
289                         PRIM_INT__f_s_s_s[n * 10 + 7] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 3]);
290                         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]);
291 
292                         PRIM_INT__f_s_s_s[n * 10 + 8] = SIMINT_MUL(P_PA[1], PRIM_INT__d_s_s_s[n * 6 + 5]);
293                         PRIM_INT__f_s_s_s[n * 10 + 8] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__f_s_s_s[n * 10 + 8]);
294 
295                         PRIM_INT__f_s_s_s[n * 10 + 9] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 5]);
296                         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]);
297                         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]);
298 
299                     }
300 
301 
302                     VRR_I_g_s_s_s(
303                             PRIM_INT__g_s_s_s,
304                             PRIM_INT__f_s_s_s,
305                             PRIM_INT__d_s_s_s,
306                             P_PA,
307                             a_over_p,
308                             aop_PQ,
309                             one_over_2p,
310                             4);
311 
312 
313                     VRR_K_g_s_p_s(
314                             PRIM_INT__g_s_p_s,
315                             PRIM_INT__g_s_s_s,
316                             PRIM_INT__f_s_s_s,
317                             Q_PA,
318                             aoq_PQ,
319                             one_over_2pq,
320                             3);
321 
322 
323                     VRR_K_f_s_p_s(
324                             PRIM_INT__f_s_p_s,
325                             PRIM_INT__f_s_s_s,
326                             PRIM_INT__d_s_s_s,
327                             Q_PA,
328                             aoq_PQ,
329                             one_over_2pq,
330                             3);
331 
332 
333                     ostei_general_vrr_K(4, 0, 2, 0, 2,
334                             one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
335                             PRIM_INT__g_s_p_s, PRIM_INT__g_s_s_s, NULL, PRIM_INT__f_s_p_s, NULL, PRIM_INT__g_s_d_s);
336 
337 
338 
339                     // Forming PRIM_INT__d_s_p_s[3 * 18];
340                     for(n = 0; n < 3; ++n)  // loop over orders of auxiliary function
341                     {
342 
343                         PRIM_INT__d_s_p_s[n * 18 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__d_s_s_s[n * 6 + 0]);
344                         PRIM_INT__d_s_p_s[n * 18 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__d_s_p_s[n * 18 + 0]);
345                         PRIM_INT__d_s_p_s[n * 18 + 0] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_p_s[n * 18 + 0]);
346 
347                         PRIM_INT__d_s_p_s[n * 18 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__d_s_s_s[n * 6 + 0]);
348                         PRIM_INT__d_s_p_s[n * 18 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__d_s_p_s[n * 18 + 1]);
349 
350                         PRIM_INT__d_s_p_s[n * 18 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__d_s_s_s[n * 6 + 0]);
351                         PRIM_INT__d_s_p_s[n * 18 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__d_s_p_s[n * 18 + 2]);
352 
353                         PRIM_INT__d_s_p_s[n * 18 + 3] = SIMINT_MUL(Q_PA[0], PRIM_INT__d_s_s_s[n * 6 + 1]);
354                         PRIM_INT__d_s_p_s[n * 18 + 3] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 1], PRIM_INT__d_s_p_s[n * 18 + 3]);
355                         PRIM_INT__d_s_p_s[n * 18 + 3] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__d_s_p_s[n * 18 + 3]);
356 
357                         PRIM_INT__d_s_p_s[n * 18 + 4] = SIMINT_MUL(Q_PA[1], PRIM_INT__d_s_s_s[n * 6 + 1]);
358                         PRIM_INT__d_s_p_s[n * 18 + 4] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 1], PRIM_INT__d_s_p_s[n * 18 + 4]);
359                         PRIM_INT__d_s_p_s[n * 18 + 4] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_p_s[n * 18 + 4]);
360 
361                         PRIM_INT__d_s_p_s[n * 18 + 5] = SIMINT_MUL(Q_PA[2], PRIM_INT__d_s_s_s[n * 6 + 1]);
362                         PRIM_INT__d_s_p_s[n * 18 + 5] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 1], PRIM_INT__d_s_p_s[n * 18 + 5]);
363 
364                         PRIM_INT__d_s_p_s[n * 18 + 6] = SIMINT_MUL(Q_PA[0], PRIM_INT__d_s_s_s[n * 6 + 2]);
365                         PRIM_INT__d_s_p_s[n * 18 + 6] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 2], PRIM_INT__d_s_p_s[n * 18 + 6]);
366                         PRIM_INT__d_s_p_s[n * 18 + 6] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__d_s_p_s[n * 18 + 6]);
367 
368                         PRIM_INT__d_s_p_s[n * 18 + 7] = SIMINT_MUL(Q_PA[1], PRIM_INT__d_s_s_s[n * 6 + 2]);
369                         PRIM_INT__d_s_p_s[n * 18 + 7] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 2], PRIM_INT__d_s_p_s[n * 18 + 7]);
370 
371                         PRIM_INT__d_s_p_s[n * 18 + 8] = SIMINT_MUL(Q_PA[2], PRIM_INT__d_s_s_s[n * 6 + 2]);
372                         PRIM_INT__d_s_p_s[n * 18 + 8] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 2], PRIM_INT__d_s_p_s[n * 18 + 8]);
373                         PRIM_INT__d_s_p_s[n * 18 + 8] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_p_s[n * 18 + 8]);
374 
375                         PRIM_INT__d_s_p_s[n * 18 + 9] = SIMINT_MUL(Q_PA[0], PRIM_INT__d_s_s_s[n * 6 + 3]);
376                         PRIM_INT__d_s_p_s[n * 18 + 9] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__d_s_p_s[n * 18 + 9]);
377 
378                         PRIM_INT__d_s_p_s[n * 18 + 10] = SIMINT_MUL(Q_PA[1], PRIM_INT__d_s_s_s[n * 6 + 3]);
379                         PRIM_INT__d_s_p_s[n * 18 + 10] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__d_s_p_s[n * 18 + 10]);
380                         PRIM_INT__d_s_p_s[n * 18 + 10] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__d_s_p_s[n * 18 + 10]);
381 
382                         PRIM_INT__d_s_p_s[n * 18 + 11] = SIMINT_MUL(Q_PA[2], PRIM_INT__d_s_s_s[n * 6 + 3]);
383                         PRIM_INT__d_s_p_s[n * 18 + 11] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__d_s_p_s[n * 18 + 11]);
384 
385                         PRIM_INT__d_s_p_s[n * 18 + 12] = SIMINT_MUL(Q_PA[0], PRIM_INT__d_s_s_s[n * 6 + 4]);
386                         PRIM_INT__d_s_p_s[n * 18 + 12] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 4], PRIM_INT__d_s_p_s[n * 18 + 12]);
387 
388                         PRIM_INT__d_s_p_s[n * 18 + 13] = SIMINT_MUL(Q_PA[1], PRIM_INT__d_s_s_s[n * 6 + 4]);
389                         PRIM_INT__d_s_p_s[n * 18 + 13] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 4], PRIM_INT__d_s_p_s[n * 18 + 13]);
390                         PRIM_INT__d_s_p_s[n * 18 + 13] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__d_s_p_s[n * 18 + 13]);
391 
392                         PRIM_INT__d_s_p_s[n * 18 + 14] = SIMINT_MUL(Q_PA[2], PRIM_INT__d_s_s_s[n * 6 + 4]);
393                         PRIM_INT__d_s_p_s[n * 18 + 14] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 4], PRIM_INT__d_s_p_s[n * 18 + 14]);
394                         PRIM_INT__d_s_p_s[n * 18 + 14] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__d_s_p_s[n * 18 + 14]);
395 
396                         PRIM_INT__d_s_p_s[n * 18 + 15] = SIMINT_MUL(Q_PA[0], PRIM_INT__d_s_s_s[n * 6 + 5]);
397                         PRIM_INT__d_s_p_s[n * 18 + 15] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__d_s_p_s[n * 18 + 15]);
398 
399                         PRIM_INT__d_s_p_s[n * 18 + 16] = SIMINT_MUL(Q_PA[1], PRIM_INT__d_s_s_s[n * 6 + 5]);
400                         PRIM_INT__d_s_p_s[n * 18 + 16] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__d_s_p_s[n * 18 + 16]);
401 
402                         PRIM_INT__d_s_p_s[n * 18 + 17] = SIMINT_MUL(Q_PA[2], PRIM_INT__d_s_s_s[n * 6 + 5]);
403                         PRIM_INT__d_s_p_s[n * 18 + 17] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__d_s_p_s[n * 18 + 17]);
404                         PRIM_INT__d_s_p_s[n * 18 + 17] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__d_s_p_s[n * 18 + 17]);
405 
406                     }
407 
408 
409                     VRR_K_f_s_d_s(
410                             PRIM_INT__f_s_d_s,
411                             PRIM_INT__f_s_p_s,
412                             PRIM_INT__f_s_s_s,
413                             PRIM_INT__d_s_p_s,
414                             Q_PA,
415                             a_over_q,
416                             aoq_PQ,
417                             one_over_2pq,
418                             one_over_2q,
419                             2);
420 
421 
422                     ostei_general_vrr_K(4, 0, 3, 0, 1,
423                             one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
424                             PRIM_INT__g_s_d_s, PRIM_INT__g_s_p_s, NULL, PRIM_INT__f_s_d_s, NULL, PRIM_INT__g_s_f_s);
425 
426 
427 
428 
429                     ////////////////////////////////////
430                     // Accumulate contracted integrals
431                     ////////////////////////////////////
432                     if(lastoffset == 0)
433                     {
434                         contract_all(150, PRIM_INT__g_s_f_s, PRIM_PTR_INT__g_s_f_s);
435                     }
436                     else
437                     {
438                         contract(150, shelloffsets, PRIM_INT__g_s_f_s, PRIM_PTR_INT__g_s_f_s);
439                         PRIM_PTR_INT__g_s_f_s += lastoffset*150;
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             abcd += nshellbatch;
448 
449         }   // close loop cdbatch
450 
451         istart = iend;
452     }  // close loop over ab
453 
454     return P.nshell12_clip * Q.nshell12_clip;
455 }
456 
ostei_s_g_f_s(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__s_g_f_s)457 int ostei_s_g_f_s(struct simint_multi_shellpair const P,
458                   struct simint_multi_shellpair const Q,
459                   double screen_tol,
460                   double * const restrict work,
461                   double * const restrict INT__s_g_f_s)
462 {
463     double P_AB[3*P.nshell12];
464     struct simint_multi_shellpair P_tmp = P;
465     P_tmp.PA_x = P.PB_x;  P_tmp.PA_y = P.PB_y;  P_tmp.PA_z = P.PB_z;
466     P_tmp.PB_x = P.PA_x;  P_tmp.PB_y = P.PA_y;  P_tmp.PB_z = P.PA_z;
467     P_tmp.AB_x = P_AB;
468     P_tmp.AB_y = P_AB + P.nshell12;
469     P_tmp.AB_z = P_AB + 2*P.nshell12;
470 
471     for(int i = 0; i < P.nshell12; i++)
472     {
473         P_tmp.AB_x[i] = -P.AB_x[i];
474         P_tmp.AB_y[i] = -P.AB_y[i];
475         P_tmp.AB_z[i] = -P.AB_z[i];
476     }
477 
478     int ret = ostei_g_s_f_s(P_tmp, Q, screen_tol, work, INT__s_g_f_s);
479 
480     return ret;
481 }
482 
ostei_g_s_s_f(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__g_s_s_f)483 int ostei_g_s_s_f(struct simint_multi_shellpair const P,
484                   struct simint_multi_shellpair const Q,
485                   double screen_tol,
486                   double * const restrict work,
487                   double * const restrict INT__g_s_s_f)
488 {
489     double Q_AB[3*Q.nshell12];
490     struct simint_multi_shellpair Q_tmp = Q;
491     Q_tmp.PA_x = Q.PB_x;  Q_tmp.PA_y = Q.PB_y;  Q_tmp.PA_z = Q.PB_z;
492     Q_tmp.PB_x = Q.PA_x;  Q_tmp.PB_y = Q.PA_y;  Q_tmp.PB_z = Q.PA_z;
493     Q_tmp.AB_x = Q_AB;
494     Q_tmp.AB_y = Q_AB + Q.nshell12;
495     Q_tmp.AB_z = Q_AB + 2*Q.nshell12;
496 
497     for(int i = 0; i < Q.nshell12; i++)
498     {
499         Q_tmp.AB_x[i] = -Q.AB_x[i];
500         Q_tmp.AB_y[i] = -Q.AB_y[i];
501         Q_tmp.AB_z[i] = -Q.AB_z[i];
502     }
503 
504     int ret = ostei_g_s_f_s(P, Q_tmp, screen_tol, work, INT__g_s_s_f);
505 
506     return ret;
507 }
508 
ostei_s_g_s_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_g_s_f)509 int ostei_s_g_s_f(struct simint_multi_shellpair const P,
510                   struct simint_multi_shellpair const Q,
511                   double screen_tol,
512                   double * const restrict work,
513                   double * const restrict INT__s_g_s_f)
514 {
515     double P_AB[3*P.nshell12];
516     struct simint_multi_shellpair P_tmp = P;
517     P_tmp.PA_x = P.PB_x;  P_tmp.PA_y = P.PB_y;  P_tmp.PA_z = P.PB_z;
518     P_tmp.PB_x = P.PA_x;  P_tmp.PB_y = P.PA_y;  P_tmp.PB_z = P.PA_z;
519     P_tmp.AB_x = P_AB;
520     P_tmp.AB_y = P_AB + P.nshell12;
521     P_tmp.AB_z = P_AB + 2*P.nshell12;
522 
523     for(int i = 0; i < P.nshell12; i++)
524     {
525         P_tmp.AB_x[i] = -P.AB_x[i];
526         P_tmp.AB_y[i] = -P.AB_y[i];
527         P_tmp.AB_z[i] = -P.AB_z[i];
528     }
529 
530     double Q_AB[3*Q.nshell12];
531     struct simint_multi_shellpair Q_tmp = Q;
532     Q_tmp.PA_x = Q.PB_x;  Q_tmp.PA_y = Q.PB_y;  Q_tmp.PA_z = Q.PB_z;
533     Q_tmp.PB_x = Q.PA_x;  Q_tmp.PB_y = Q.PA_y;  Q_tmp.PB_z = Q.PA_z;
534     Q_tmp.AB_x = Q_AB;
535     Q_tmp.AB_y = Q_AB + Q.nshell12;
536     Q_tmp.AB_z = Q_AB + 2*Q.nshell12;
537 
538     for(int i = 0; i < Q.nshell12; i++)
539     {
540         Q_tmp.AB_x[i] = -Q.AB_x[i];
541         Q_tmp.AB_y[i] = -Q.AB_y[i];
542         Q_tmp.AB_z[i] = -Q.AB_z[i];
543     }
544 
545     int ret = ostei_g_s_f_s(P_tmp, Q_tmp, screen_tol, work, INT__s_g_s_f);
546 
547     return ret;
548 }
549 
550