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_s_d_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_d_f_s)8 int ostei_s_d_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__s_d_f_s)
13 {
14 
15     SIMINT_ASSUME_ALIGN_DBL(work);
16     SIMINT_ASSUME_ALIGN_DBL(INT__s_d_f_s);
17     memset(INT__s_d_f_s, 0, P.nshell12_clip * Q.nshell12_clip * 60 * 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__s_s_p_s = primwork + 6;
31     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_d_s = primwork + 21;
32     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_f_s = primwork + 45;
33     SIMINT_DBLTYPE * const restrict PRIM_INT__s_p_d_s = primwork + 75;
34     SIMINT_DBLTYPE * const restrict PRIM_INT__s_p_f_s = primwork + 111;
35     SIMINT_DBLTYPE * const restrict PRIM_INT__s_d_f_s = primwork + 171;
36     double * const hrrwork = (double *)(primwork + 231);
37 
38 
39     // Create constants
40     const SIMINT_DBLTYPE const_1 = SIMINT_DBLSET1(1);
41     const SIMINT_DBLTYPE const_2 = SIMINT_DBLSET1(2);
42     const SIMINT_DBLTYPE const_3 = SIMINT_DBLSET1(3);
43     const SIMINT_DBLTYPE one_half = SIMINT_DBLSET1(0.5);
44 
45 
46     ////////////////////////////////////////
47     // Loop over shells and primitives
48     ////////////////////////////////////////
49 
50     abcd = 0;
51     istart = 0;
52     for(ab = 0; ab < P.nshell12_clip; ++ab)
53     {
54         const int iend = istart + P.nprim12[ab];
55 
56         cd = 0;
57         jstart = 0;
58 
59         for(cd = 0; cd < Q.nshell12_clip; cd += SIMINT_NSHELL_SIMD)
60         {
61             const int nshellbatch = ((cd + SIMINT_NSHELL_SIMD) > Q.nshell12_clip) ? Q.nshell12_clip - cd : SIMINT_NSHELL_SIMD;
62             int jend = jstart;
63             for(i = 0; i < nshellbatch; i++)
64                 jend += Q.nprim12[cd+i];
65 
66 
67             for(i = istart; i < iend; ++i)
68             {
69                 SIMINT_DBLTYPE bra_screen_max;  // only used if check_screen
70 
71                 if(check_screen)
72                 {
73                     // Skip this whole thing if always insignificant
74                     if((P.screen[i] * Q.screen_max) < screen_tol)
75                         continue;
76                     bra_screen_max = SIMINT_DBLSET1(P.screen[i]);
77                 }
78 
79                 icd = 0;
80                 iprimcd = 0;
81                 nprim_icd = Q.nprim12[cd];
82                 double * restrict PRIM_PTR_INT__s_d_f_s = INT__s_d_f_s + abcd * 60;
83 
84 
85 
86                 // Load these one per loop over i
87                 const SIMINT_DBLTYPE P_alpha = SIMINT_DBLSET1(P.alpha[i]);
88                 const SIMINT_DBLTYPE P_prefac = SIMINT_DBLSET1(P.prefac[i]);
89                 const SIMINT_DBLTYPE Pxyz[3] = { SIMINT_DBLSET1(P.x[i]), SIMINT_DBLSET1(P.y[i]), SIMINT_DBLSET1(P.z[i]) };
90 
91                 const SIMINT_DBLTYPE P_PB[3] = { SIMINT_DBLSET1(P.PB_x[i]), SIMINT_DBLSET1(P.PB_y[i]), SIMINT_DBLSET1(P.PB_z[i]) };
92 
93                 for(j = jstart; j < jend; j += SIMINT_SIMD_LEN)
94                 {
95                     // calculate the shell offsets
96                     // these are the offset from the shell pointed to by cd
97                     // for each element
98                     int shelloffsets[SIMINT_SIMD_LEN] = {0};
99                     int lastoffset = 0;
100                     const int nlane = ( ((j + SIMINT_SIMD_LEN) < jend) ? SIMINT_SIMD_LEN : (jend - j));
101 
102                     if((iprimcd + SIMINT_SIMD_LEN) >= nprim_icd)
103                     {
104                         // Handle if the first element of the vector is a new shell
105                         if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
106                         {
107                             nprim_icd += Q.nprim12[cd + (++icd)];
108                             PRIM_PTR_INT__s_d_f_s += 60;
109                         }
110                         iprimcd++;
111                         for(n = 1; n < SIMINT_SIMD_LEN; ++n)
112                         {
113                             if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
114                             {
115                                 shelloffsets[n] = shelloffsets[n-1] + 1;
116                                 lastoffset++;
117                                 nprim_icd += Q.nprim12[cd + (++icd)];
118                             }
119                             else
120                                 shelloffsets[n] = shelloffsets[n-1];
121                             iprimcd++;
122                         }
123                     }
124                     else
125                         iprimcd += SIMINT_SIMD_LEN;
126 
127                     // Do we have to compute this vector (or has it been screened out)?
128                     // (not_screened != 0 means we have to do this vector)
129                     if(check_screen)
130                     {
131                         const double vmax = vector_max(SIMINT_MUL(bra_screen_max, SIMINT_DBLLOAD(Q.screen, j)));
132                         if(vmax < screen_tol)
133                         {
134                             PRIM_PTR_INT__s_d_f_s += lastoffset*60;
135                             continue;
136                         }
137                     }
138 
139                     const SIMINT_DBLTYPE Q_alpha = SIMINT_DBLLOAD(Q.alpha, j);
140                     const SIMINT_DBLTYPE PQalpha_mul = SIMINT_MUL(P_alpha, Q_alpha);
141                     const SIMINT_DBLTYPE PQalpha_sum = SIMINT_ADD(P_alpha, Q_alpha);
142                     const SIMINT_DBLTYPE one_over_PQalpha_sum = SIMINT_DIV(const_1, PQalpha_sum);
143 
144 
145                     /* construct R2 = (Px - Qx)**2 + (Py - Qy)**2 + (Pz -Qz)**2 */
146                     SIMINT_DBLTYPE PQ[3];
147                     PQ[0] = SIMINT_SUB(Pxyz[0], SIMINT_DBLLOAD(Q.x, j));
148                     PQ[1] = SIMINT_SUB(Pxyz[1], SIMINT_DBLLOAD(Q.y, j));
149                     PQ[2] = SIMINT_SUB(Pxyz[2], SIMINT_DBLLOAD(Q.z, j));
150                     SIMINT_DBLTYPE R2 = SIMINT_MUL(PQ[0], PQ[0]);
151                     R2 = SIMINT_FMADD(PQ[1], PQ[1], R2);
152                     R2 = SIMINT_FMADD(PQ[2], PQ[2], R2);
153 
154                     const SIMINT_DBLTYPE alpha = SIMINT_MUL(PQalpha_mul, one_over_PQalpha_sum); // alpha from MEST
155                     const SIMINT_DBLTYPE one_over_p = SIMINT_DIV(const_1, P_alpha);
156                     const SIMINT_DBLTYPE one_over_q = SIMINT_DIV(const_1, Q_alpha);
157                     const SIMINT_DBLTYPE one_over_2p = SIMINT_MUL(one_half, one_over_p);
158                     const SIMINT_DBLTYPE one_over_2q = SIMINT_MUL(one_half, one_over_q);
159                     const SIMINT_DBLTYPE one_over_2pq = SIMINT_MUL(one_half, one_over_PQalpha_sum);
160                     const SIMINT_DBLTYPE Q_PA[3] = { SIMINT_DBLLOAD(Q.PA_x, j), SIMINT_DBLLOAD(Q.PA_y, j), SIMINT_DBLLOAD(Q.PA_z, j) };
161 
162                     // NOTE: Minus sign!
163                     const SIMINT_DBLTYPE a_over_p = SIMINT_MUL(SIMINT_NEG(alpha), one_over_p);
164                     SIMINT_DBLTYPE aop_PQ[3];
165                     aop_PQ[0] = SIMINT_MUL(a_over_p, PQ[0]);
166                     aop_PQ[1] = SIMINT_MUL(a_over_p, PQ[1]);
167                     aop_PQ[2] = SIMINT_MUL(a_over_p, PQ[2]);
168 
169                     SIMINT_DBLTYPE a_over_q = SIMINT_MUL(alpha, one_over_q);
170                     SIMINT_DBLTYPE aoq_PQ[3];
171                     aoq_PQ[0] = SIMINT_MUL(a_over_q, PQ[0]);
172                     aoq_PQ[1] = SIMINT_MUL(a_over_q, PQ[1]);
173                     aoq_PQ[2] = SIMINT_MUL(a_over_q, PQ[2]);
174                     // Put a minus sign here so we don't have to in RR routines
175                     a_over_q = SIMINT_NEG(a_over_q);
176 
177 
178                     //////////////////////////////////////////////
179                     // Fjt function section
180                     // Maximum v value: 5
181                     //////////////////////////////////////////////
182                     // The parameter to the Fjt function
183                     const SIMINT_DBLTYPE F_x = SIMINT_MUL(R2, alpha);
184 
185 
186                     const SIMINT_DBLTYPE Q_prefac = mask_load(nlane, Q.prefac + j);
187 
188 
189                     boys_F_split(PRIM_INT__s_s_s_s, F_x, 5);
190                     SIMINT_DBLTYPE prefac = SIMINT_SQRT(one_over_PQalpha_sum);
191                     prefac = SIMINT_MUL(SIMINT_MUL(P_prefac, Q_prefac), prefac);
192                     for(n = 0; n <= 5; n++)
193                         PRIM_INT__s_s_s_s[n] = SIMINT_MUL(PRIM_INT__s_s_s_s[n], prefac);
194 
195                     //////////////////////////////////////////////
196                     // Primitive integrals: Vertical recurrance
197                     //////////////////////////////////////////////
198 
199                     const SIMINT_DBLTYPE vrr_const_1_over_2p = one_over_2p;
200                     const SIMINT_DBLTYPE vrr_const_1_over_2q = one_over_2q;
201                     const SIMINT_DBLTYPE vrr_const_2_over_2q = SIMINT_MUL(const_2, one_over_2q);
202                     const SIMINT_DBLTYPE vrr_const_1_over_2pq = one_over_2pq;
203                     const SIMINT_DBLTYPE vrr_const_2_over_2pq = SIMINT_MUL(const_2, one_over_2pq);
204                     const SIMINT_DBLTYPE vrr_const_3_over_2pq = SIMINT_MUL(const_3, one_over_2pq);
205 
206 
207 
208                     // Forming PRIM_INT__s_s_p_s[5 * 3];
209                     for(n = 0; n < 5; ++n)  // loop over orders of auxiliary function
210                     {
211 
212                         PRIM_INT__s_s_p_s[n * 3 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
213                         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]);
214 
215                         PRIM_INT__s_s_p_s[n * 3 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
216                         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]);
217 
218                         PRIM_INT__s_s_p_s[n * 3 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
219                         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]);
220 
221                     }
222 
223 
224 
225                     // Forming PRIM_INT__s_s_d_s[4 * 6];
226                     for(n = 0; n < 4; ++n)  // loop over orders of auxiliary function
227                     {
228 
229                         PRIM_INT__s_s_d_s[n * 6 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_p_s[n * 3 + 0]);
230                         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]);
231                         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]);
232 
233                         PRIM_INT__s_s_d_s[n * 6 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_p_s[n * 3 + 0]);
234                         PRIM_INT__s_s_d_s[n * 6 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_s_d_s[n * 6 + 1]);
235 
236                         PRIM_INT__s_s_d_s[n * 6 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_p_s[n * 3 + 0]);
237                         PRIM_INT__s_s_d_s[n * 6 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_s_d_s[n * 6 + 2]);
238 
239                         PRIM_INT__s_s_d_s[n * 6 + 3] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_p_s[n * 3 + 1]);
240                         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]);
241                         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]);
242 
243                         PRIM_INT__s_s_d_s[n * 6 + 4] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_p_s[n * 3 + 1]);
244                         PRIM_INT__s_s_d_s[n * 6 + 4] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_s_d_s[n * 6 + 4]);
245 
246                         PRIM_INT__s_s_d_s[n * 6 + 5] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_p_s[n * 3 + 2]);
247                         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]);
248                         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]);
249 
250                     }
251 
252 
253 
254                     // Forming PRIM_INT__s_s_f_s[3 * 10];
255                     for(n = 0; n < 3; ++n)  // loop over orders of auxiliary function
256                     {
257 
258                         PRIM_INT__s_s_f_s[n * 10 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_d_s[n * 6 + 0]);
259                         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]);
260                         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]);
261 
262                         PRIM_INT__s_s_f_s[n * 10 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 0]);
263                         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]);
264 
265                         PRIM_INT__s_s_f_s[n * 10 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 0]);
266                         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]);
267 
268                         PRIM_INT__s_s_f_s[n * 10 + 3] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_d_s[n * 6 + 3]);
269                         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]);
270 
271                         PRIM_INT__s_s_f_s[n * 10 + 4] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 1]);
272                         PRIM_INT__s_s_f_s[n * 10 + 4] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 1], PRIM_INT__s_s_f_s[n * 10 + 4]);
273 
274                         PRIM_INT__s_s_f_s[n * 10 + 5] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_d_s[n * 6 + 5]);
275                         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]);
276 
277                         PRIM_INT__s_s_f_s[n * 10 + 6] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 3]);
278                         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]);
279                         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]);
280 
281                         PRIM_INT__s_s_f_s[n * 10 + 7] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 3]);
282                         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]);
283 
284                         PRIM_INT__s_s_f_s[n * 10 + 8] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 5]);
285                         PRIM_INT__s_s_f_s[n * 10 + 8] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__s_s_f_s[n * 10 + 8]);
286 
287                         PRIM_INT__s_s_f_s[n * 10 + 9] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 5]);
288                         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]);
289                         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]);
290 
291                     }
292 
293 
294                     VRR_J_s_p_f_s(
295                             PRIM_INT__s_p_f_s,
296                             PRIM_INT__s_s_f_s,
297                             PRIM_INT__s_s_d_s,
298                             P_PB,
299                             aop_PQ,
300                             one_over_2pq,
301                             2);
302 
303 
304 
305                     // Forming PRIM_INT__s_p_d_s[2 * 18];
306                     for(n = 0; n < 2; ++n)  // loop over orders of auxiliary function
307                     {
308 
309                         PRIM_INT__s_p_d_s[n * 18 + 0] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_d_s[n * 6 + 0]);
310                         PRIM_INT__s_p_d_s[n * 18 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__s_p_d_s[n * 18 + 0]);
311                         PRIM_INT__s_p_d_s[n * 18 + 0] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_p_d_s[n * 18 + 0]);
312 
313                         PRIM_INT__s_p_d_s[n * 18 + 1] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_d_s[n * 6 + 1]);
314                         PRIM_INT__s_p_d_s[n * 18 + 1] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 1], PRIM_INT__s_p_d_s[n * 18 + 1]);
315                         PRIM_INT__s_p_d_s[n * 18 + 1] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_p_d_s[n * 18 + 1]);
316 
317                         PRIM_INT__s_p_d_s[n * 18 + 2] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_d_s[n * 6 + 2]);
318                         PRIM_INT__s_p_d_s[n * 18 + 2] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 2], PRIM_INT__s_p_d_s[n * 18 + 2]);
319                         PRIM_INT__s_p_d_s[n * 18 + 2] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__s_p_d_s[n * 18 + 2]);
320 
321                         PRIM_INT__s_p_d_s[n * 18 + 3] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_d_s[n * 6 + 3]);
322                         PRIM_INT__s_p_d_s[n * 18 + 3] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__s_p_d_s[n * 18 + 3]);
323 
324                         PRIM_INT__s_p_d_s[n * 18 + 4] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_d_s[n * 6 + 4]);
325                         PRIM_INT__s_p_d_s[n * 18 + 4] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 4], PRIM_INT__s_p_d_s[n * 18 + 4]);
326 
327                         PRIM_INT__s_p_d_s[n * 18 + 5] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_d_s[n * 6 + 5]);
328                         PRIM_INT__s_p_d_s[n * 18 + 5] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__s_p_d_s[n * 18 + 5]);
329 
330                         PRIM_INT__s_p_d_s[n * 18 + 6] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_d_s[n * 6 + 0]);
331                         PRIM_INT__s_p_d_s[n * 18 + 6] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__s_p_d_s[n * 18 + 6]);
332 
333                         PRIM_INT__s_p_d_s[n * 18 + 7] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_d_s[n * 6 + 1]);
334                         PRIM_INT__s_p_d_s[n * 18 + 7] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 1], PRIM_INT__s_p_d_s[n * 18 + 7]);
335                         PRIM_INT__s_p_d_s[n * 18 + 7] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_p_d_s[n * 18 + 7]);
336 
337                         PRIM_INT__s_p_d_s[n * 18 + 8] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_d_s[n * 6 + 2]);
338                         PRIM_INT__s_p_d_s[n * 18 + 8] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 2], PRIM_INT__s_p_d_s[n * 18 + 8]);
339 
340                         PRIM_INT__s_p_d_s[n * 18 + 9] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_d_s[n * 6 + 3]);
341                         PRIM_INT__s_p_d_s[n * 18 + 9] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__s_p_d_s[n * 18 + 9]);
342                         PRIM_INT__s_p_d_s[n * 18 + 9] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_p_d_s[n * 18 + 9]);
343 
344                         PRIM_INT__s_p_d_s[n * 18 + 10] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_d_s[n * 6 + 4]);
345                         PRIM_INT__s_p_d_s[n * 18 + 10] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 4], PRIM_INT__s_p_d_s[n * 18 + 10]);
346                         PRIM_INT__s_p_d_s[n * 18 + 10] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__s_p_d_s[n * 18 + 10]);
347 
348                         PRIM_INT__s_p_d_s[n * 18 + 11] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_d_s[n * 6 + 5]);
349                         PRIM_INT__s_p_d_s[n * 18 + 11] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__s_p_d_s[n * 18 + 11]);
350 
351                         PRIM_INT__s_p_d_s[n * 18 + 12] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_d_s[n * 6 + 0]);
352                         PRIM_INT__s_p_d_s[n * 18 + 12] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__s_p_d_s[n * 18 + 12]);
353 
354                         PRIM_INT__s_p_d_s[n * 18 + 13] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_d_s[n * 6 + 1]);
355                         PRIM_INT__s_p_d_s[n * 18 + 13] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 1], PRIM_INT__s_p_d_s[n * 18 + 13]);
356 
357                         PRIM_INT__s_p_d_s[n * 18 + 14] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_d_s[n * 6 + 2]);
358                         PRIM_INT__s_p_d_s[n * 18 + 14] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 2], PRIM_INT__s_p_d_s[n * 18 + 14]);
359                         PRIM_INT__s_p_d_s[n * 18 + 14] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_p_d_s[n * 18 + 14]);
360 
361                         PRIM_INT__s_p_d_s[n * 18 + 15] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_d_s[n * 6 + 3]);
362                         PRIM_INT__s_p_d_s[n * 18 + 15] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__s_p_d_s[n * 18 + 15]);
363 
364                         PRIM_INT__s_p_d_s[n * 18 + 16] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_d_s[n * 6 + 4]);
365                         PRIM_INT__s_p_d_s[n * 18 + 16] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 4], PRIM_INT__s_p_d_s[n * 18 + 16]);
366                         PRIM_INT__s_p_d_s[n * 18 + 16] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_p_d_s[n * 18 + 16]);
367 
368                         PRIM_INT__s_p_d_s[n * 18 + 17] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_d_s[n * 6 + 5]);
369                         PRIM_INT__s_p_d_s[n * 18 + 17] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__s_p_d_s[n * 18 + 17]);
370                         PRIM_INT__s_p_d_s[n * 18 + 17] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__s_p_d_s[n * 18 + 17]);
371 
372                     }
373 
374 
375                     VRR_J_s_d_f_s(
376                             PRIM_INT__s_d_f_s,
377                             PRIM_INT__s_p_f_s,
378                             PRIM_INT__s_s_f_s,
379                             PRIM_INT__s_p_d_s,
380                             P_PB,
381                             a_over_p,
382                             aop_PQ,
383                             one_over_2p,
384                             one_over_2pq,
385                             1);
386 
387 
388 
389 
390                     ////////////////////////////////////
391                     // Accumulate contracted integrals
392                     ////////////////////////////////////
393                     if(lastoffset == 0)
394                     {
395                         contract_all(60, PRIM_INT__s_d_f_s, PRIM_PTR_INT__s_d_f_s);
396                     }
397                     else
398                     {
399                         contract(60, shelloffsets, PRIM_INT__s_d_f_s, PRIM_PTR_INT__s_d_f_s);
400                         PRIM_PTR_INT__s_d_f_s += lastoffset*60;
401                     }
402 
403                 }  // close loop over j
404             }  // close loop over i
405 
406             //Advance to the next batch
407             jstart = SIMINT_SIMD_ROUND(jend);
408             abcd += nshellbatch;
409 
410         }   // close loop cdbatch
411 
412         istart = iend;
413     }  // close loop over ab
414 
415     return P.nshell12_clip * Q.nshell12_clip;
416 }
417 
418