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_p_d_f_d(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__p_d_f_d)8 int ostei_p_d_f_d(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__p_d_f_d)
13 {
14 
15     SIMINT_ASSUME_ALIGN_DBL(work);
16     SIMINT_ASSUME_ALIGN_DBL(INT__p_d_f_d);
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     int ibra;
27 
28     // partition workspace
29     double * const INT__s_d_f_s = work + (SIMINT_NSHELL_SIMD * 0);
30     double * const INT__s_d_g_s = work + (SIMINT_NSHELL_SIMD * 60);
31     double * const INT__s_d_h_s = work + (SIMINT_NSHELL_SIMD * 150);
32     double * const INT__s_f_f_s = work + (SIMINT_NSHELL_SIMD * 276);
33     double * const INT__s_f_g_s = work + (SIMINT_NSHELL_SIMD * 376);
34     double * const INT__s_f_h_s = work + (SIMINT_NSHELL_SIMD * 526);
35     SIMINT_DBLTYPE * const primwork = (SIMINT_DBLTYPE *)(work + SIMINT_NSHELL_SIMD*736);
36     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_s = primwork + 0;
37     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_p_s = primwork + 9;
38     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_d_s = primwork + 33;
39     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_f_s = primwork + 75;
40     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_g_s = primwork + 135;
41     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_h_s = primwork + 210;
42     SIMINT_DBLTYPE * const restrict PRIM_INT__s_p_p_s = primwork + 294;
43     SIMINT_DBLTYPE * const restrict PRIM_INT__s_p_d_s = primwork + 321;
44     SIMINT_DBLTYPE * const restrict PRIM_INT__s_p_f_s = primwork + 375;
45     SIMINT_DBLTYPE * const restrict PRIM_INT__s_p_g_s = primwork + 465;
46     SIMINT_DBLTYPE * const restrict PRIM_INT__s_p_h_s = primwork + 600;
47     SIMINT_DBLTYPE * const restrict PRIM_INT__s_d_d_s = primwork + 789;
48     SIMINT_DBLTYPE * const restrict PRIM_INT__s_d_f_s = primwork + 861;
49     SIMINT_DBLTYPE * const restrict PRIM_INT__s_d_g_s = primwork + 981;
50     SIMINT_DBLTYPE * const restrict PRIM_INT__s_d_h_s = primwork + 1161;
51     SIMINT_DBLTYPE * const restrict PRIM_INT__s_f_f_s = primwork + 1413;
52     SIMINT_DBLTYPE * const restrict PRIM_INT__s_f_g_s = primwork + 1513;
53     SIMINT_DBLTYPE * const restrict PRIM_INT__s_f_h_s = primwork + 1663;
54     double * const hrrwork = (double *)(primwork + 1873);
55     double * const HRR_INT__p_d_f_s = hrrwork + 0;
56     double * const HRR_INT__p_d_f_p = hrrwork + 180;
57     double * const HRR_INT__p_d_g_s = hrrwork + 720;
58     double * const HRR_INT__p_d_g_p = hrrwork + 990;
59     double * const HRR_INT__p_d_h_s = hrrwork + 1800;
60 
61 
62     // Create constants
63     const SIMINT_DBLTYPE const_1 = SIMINT_DBLSET1(1);
64     const SIMINT_DBLTYPE const_2 = SIMINT_DBLSET1(2);
65     const SIMINT_DBLTYPE const_3 = SIMINT_DBLSET1(3);
66     const SIMINT_DBLTYPE const_4 = SIMINT_DBLSET1(4);
67     const SIMINT_DBLTYPE const_5 = SIMINT_DBLSET1(5);
68     const SIMINT_DBLTYPE one_half = SIMINT_DBLSET1(0.5);
69 
70 
71     ////////////////////////////////////////
72     // Loop over shells and primitives
73     ////////////////////////////////////////
74 
75     real_abcd = 0;
76     istart = 0;
77     for(ab = 0; ab < P.nshell12_clip; ++ab)
78     {
79         const int iend = istart + P.nprim12[ab];
80 
81         cd = 0;
82         jstart = 0;
83 
84         for(cd = 0; cd < Q.nshell12_clip; cd += SIMINT_NSHELL_SIMD)
85         {
86             const int nshellbatch = ((cd + SIMINT_NSHELL_SIMD) > Q.nshell12_clip) ? Q.nshell12_clip - cd : SIMINT_NSHELL_SIMD;
87             int jend = jstart;
88             for(i = 0; i < nshellbatch; i++)
89                 jend += Q.nprim12[cd+i];
90 
91             // Clear the beginning of the workspace (where we are accumulating integrals)
92             memset(work, 0, SIMINT_NSHELL_SIMD * 736 * sizeof(double));
93             abcd = 0;
94 
95 
96             for(i = istart; i < iend; ++i)
97             {
98                 SIMINT_DBLTYPE bra_screen_max;  // only used if check_screen
99 
100                 if(check_screen)
101                 {
102                     // Skip this whole thing if always insignificant
103                     if((P.screen[i] * Q.screen_max) < screen_tol)
104                         continue;
105                     bra_screen_max = SIMINT_DBLSET1(P.screen[i]);
106                 }
107 
108                 icd = 0;
109                 iprimcd = 0;
110                 nprim_icd = Q.nprim12[cd];
111                 double * restrict PRIM_PTR_INT__s_d_f_s = INT__s_d_f_s + abcd * 60;
112                 double * restrict PRIM_PTR_INT__s_d_g_s = INT__s_d_g_s + abcd * 90;
113                 double * restrict PRIM_PTR_INT__s_d_h_s = INT__s_d_h_s + abcd * 126;
114                 double * restrict PRIM_PTR_INT__s_f_f_s = INT__s_f_f_s + abcd * 100;
115                 double * restrict PRIM_PTR_INT__s_f_g_s = INT__s_f_g_s + abcd * 150;
116                 double * restrict PRIM_PTR_INT__s_f_h_s = INT__s_f_h_s + abcd * 210;
117 
118 
119 
120                 // Load these one per loop over i
121                 const SIMINT_DBLTYPE P_alpha = SIMINT_DBLSET1(P.alpha[i]);
122                 const SIMINT_DBLTYPE P_prefac = SIMINT_DBLSET1(P.prefac[i]);
123                 const SIMINT_DBLTYPE Pxyz[3] = { SIMINT_DBLSET1(P.x[i]), SIMINT_DBLSET1(P.y[i]), SIMINT_DBLSET1(P.z[i]) };
124 
125                 const SIMINT_DBLTYPE P_PB[3] = { SIMINT_DBLSET1(P.PB_x[i]), SIMINT_DBLSET1(P.PB_y[i]), SIMINT_DBLSET1(P.PB_z[i]) };
126 
127                 for(j = jstart; j < jend; j += SIMINT_SIMD_LEN)
128                 {
129                     // calculate the shell offsets
130                     // these are the offset from the shell pointed to by cd
131                     // for each element
132                     int shelloffsets[SIMINT_SIMD_LEN] = {0};
133                     int lastoffset = 0;
134                     const int nlane = ( ((j + SIMINT_SIMD_LEN) < jend) ? SIMINT_SIMD_LEN : (jend - j));
135 
136                     if((iprimcd + SIMINT_SIMD_LEN) >= nprim_icd)
137                     {
138                         // Handle if the first element of the vector is a new shell
139                         if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
140                         {
141                             nprim_icd += Q.nprim12[cd + (++icd)];
142                             PRIM_PTR_INT__s_d_f_s += 60;
143                             PRIM_PTR_INT__s_d_g_s += 90;
144                             PRIM_PTR_INT__s_d_h_s += 126;
145                             PRIM_PTR_INT__s_f_f_s += 100;
146                             PRIM_PTR_INT__s_f_g_s += 150;
147                             PRIM_PTR_INT__s_f_h_s += 210;
148                         }
149                         iprimcd++;
150                         for(n = 1; n < SIMINT_SIMD_LEN; ++n)
151                         {
152                             if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
153                             {
154                                 shelloffsets[n] = shelloffsets[n-1] + 1;
155                                 lastoffset++;
156                                 nprim_icd += Q.nprim12[cd + (++icd)];
157                             }
158                             else
159                                 shelloffsets[n] = shelloffsets[n-1];
160                             iprimcd++;
161                         }
162                     }
163                     else
164                         iprimcd += SIMINT_SIMD_LEN;
165 
166                     // Do we have to compute this vector (or has it been screened out)?
167                     // (not_screened != 0 means we have to do this vector)
168                     if(check_screen)
169                     {
170                         const double vmax = vector_max(SIMINT_MUL(bra_screen_max, SIMINT_DBLLOAD(Q.screen, j)));
171                         if(vmax < screen_tol)
172                         {
173                             PRIM_PTR_INT__s_d_f_s += lastoffset*60;
174                             PRIM_PTR_INT__s_d_g_s += lastoffset*90;
175                             PRIM_PTR_INT__s_d_h_s += lastoffset*126;
176                             PRIM_PTR_INT__s_f_f_s += lastoffset*100;
177                             PRIM_PTR_INT__s_f_g_s += lastoffset*150;
178                             PRIM_PTR_INT__s_f_h_s += lastoffset*210;
179                             continue;
180                         }
181                     }
182 
183                     const SIMINT_DBLTYPE Q_alpha = SIMINT_DBLLOAD(Q.alpha, j);
184                     const SIMINT_DBLTYPE PQalpha_mul = SIMINT_MUL(P_alpha, Q_alpha);
185                     const SIMINT_DBLTYPE PQalpha_sum = SIMINT_ADD(P_alpha, Q_alpha);
186                     const SIMINT_DBLTYPE one_over_PQalpha_sum = SIMINT_DIV(const_1, PQalpha_sum);
187 
188 
189                     /* construct R2 = (Px - Qx)**2 + (Py - Qy)**2 + (Pz -Qz)**2 */
190                     SIMINT_DBLTYPE PQ[3];
191                     PQ[0] = SIMINT_SUB(Pxyz[0], SIMINT_DBLLOAD(Q.x, j));
192                     PQ[1] = SIMINT_SUB(Pxyz[1], SIMINT_DBLLOAD(Q.y, j));
193                     PQ[2] = SIMINT_SUB(Pxyz[2], SIMINT_DBLLOAD(Q.z, j));
194                     SIMINT_DBLTYPE R2 = SIMINT_MUL(PQ[0], PQ[0]);
195                     R2 = SIMINT_FMADD(PQ[1], PQ[1], R2);
196                     R2 = SIMINT_FMADD(PQ[2], PQ[2], R2);
197 
198                     const SIMINT_DBLTYPE alpha = SIMINT_MUL(PQalpha_mul, one_over_PQalpha_sum); // alpha from MEST
199                     const SIMINT_DBLTYPE one_over_p = SIMINT_DIV(const_1, P_alpha);
200                     const SIMINT_DBLTYPE one_over_q = SIMINT_DIV(const_1, Q_alpha);
201                     const SIMINT_DBLTYPE one_over_2p = SIMINT_MUL(one_half, one_over_p);
202                     const SIMINT_DBLTYPE one_over_2q = SIMINT_MUL(one_half, one_over_q);
203                     const SIMINT_DBLTYPE one_over_2pq = SIMINT_MUL(one_half, one_over_PQalpha_sum);
204                     const SIMINT_DBLTYPE Q_PA[3] = { SIMINT_DBLLOAD(Q.PA_x, j), SIMINT_DBLLOAD(Q.PA_y, j), SIMINT_DBLLOAD(Q.PA_z, j) };
205 
206                     // NOTE: Minus sign!
207                     const SIMINT_DBLTYPE a_over_p = SIMINT_MUL(SIMINT_NEG(alpha), one_over_p);
208                     SIMINT_DBLTYPE aop_PQ[3];
209                     aop_PQ[0] = SIMINT_MUL(a_over_p, PQ[0]);
210                     aop_PQ[1] = SIMINT_MUL(a_over_p, PQ[1]);
211                     aop_PQ[2] = SIMINT_MUL(a_over_p, PQ[2]);
212 
213                     SIMINT_DBLTYPE a_over_q = SIMINT_MUL(alpha, one_over_q);
214                     SIMINT_DBLTYPE aoq_PQ[3];
215                     aoq_PQ[0] = SIMINT_MUL(a_over_q, PQ[0]);
216                     aoq_PQ[1] = SIMINT_MUL(a_over_q, PQ[1]);
217                     aoq_PQ[2] = SIMINT_MUL(a_over_q, PQ[2]);
218                     // Put a minus sign here so we don't have to in RR routines
219                     a_over_q = SIMINT_NEG(a_over_q);
220 
221 
222                     //////////////////////////////////////////////
223                     // Fjt function section
224                     // Maximum v value: 8
225                     //////////////////////////////////////////////
226                     // The parameter to the Fjt function
227                     const SIMINT_DBLTYPE F_x = SIMINT_MUL(R2, alpha);
228 
229 
230                     const SIMINT_DBLTYPE Q_prefac = mask_load(nlane, Q.prefac + j);
231 
232 
233                     boys_F_split(PRIM_INT__s_s_s_s, F_x, 8);
234                     SIMINT_DBLTYPE prefac = SIMINT_SQRT(one_over_PQalpha_sum);
235                     prefac = SIMINT_MUL(SIMINT_MUL(P_prefac, Q_prefac), prefac);
236                     for(n = 0; n <= 8; n++)
237                         PRIM_INT__s_s_s_s[n] = SIMINT_MUL(PRIM_INT__s_s_s_s[n], prefac);
238 
239                     //////////////////////////////////////////////
240                     // Primitive integrals: Vertical recurrance
241                     //////////////////////////////////////////////
242 
243                     const SIMINT_DBLTYPE vrr_const_1_over_2p = one_over_2p;
244                     const SIMINT_DBLTYPE vrr_const_2_over_2p = SIMINT_MUL(const_2, one_over_2p);
245                     const SIMINT_DBLTYPE vrr_const_1_over_2q = one_over_2q;
246                     const SIMINT_DBLTYPE vrr_const_2_over_2q = SIMINT_MUL(const_2, one_over_2q);
247                     const SIMINT_DBLTYPE vrr_const_3_over_2q = SIMINT_MUL(const_3, one_over_2q);
248                     const SIMINT_DBLTYPE vrr_const_4_over_2q = SIMINT_MUL(const_4, one_over_2q);
249                     const SIMINT_DBLTYPE vrr_const_1_over_2pq = one_over_2pq;
250                     const SIMINT_DBLTYPE vrr_const_2_over_2pq = SIMINT_MUL(const_2, one_over_2pq);
251                     const SIMINT_DBLTYPE vrr_const_3_over_2pq = SIMINT_MUL(const_3, one_over_2pq);
252                     const SIMINT_DBLTYPE vrr_const_4_over_2pq = SIMINT_MUL(const_4, one_over_2pq);
253                     const SIMINT_DBLTYPE vrr_const_5_over_2pq = SIMINT_MUL(const_5, one_over_2pq);
254 
255 
256 
257                     // Forming PRIM_INT__s_s_p_s[8 * 3];
258                     for(n = 0; n < 8; ++n)  // loop over orders of auxiliary function
259                     {
260 
261                         PRIM_INT__s_s_p_s[n * 3 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
262                         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]);
263 
264                         PRIM_INT__s_s_p_s[n * 3 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
265                         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]);
266 
267                         PRIM_INT__s_s_p_s[n * 3 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
268                         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]);
269 
270                     }
271 
272 
273 
274                     // Forming PRIM_INT__s_s_d_s[7 * 6];
275                     for(n = 0; n < 7; ++n)  // loop over orders of auxiliary function
276                     {
277 
278                         PRIM_INT__s_s_d_s[n * 6 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_p_s[n * 3 + 0]);
279                         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]);
280                         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]);
281 
282                         PRIM_INT__s_s_d_s[n * 6 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_p_s[n * 3 + 0]);
283                         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]);
284 
285                         PRIM_INT__s_s_d_s[n * 6 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_p_s[n * 3 + 0]);
286                         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]);
287 
288                         PRIM_INT__s_s_d_s[n * 6 + 3] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_p_s[n * 3 + 1]);
289                         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]);
290                         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]);
291 
292                         PRIM_INT__s_s_d_s[n * 6 + 4] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_p_s[n * 3 + 1]);
293                         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]);
294 
295                         PRIM_INT__s_s_d_s[n * 6 + 5] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_p_s[n * 3 + 2]);
296                         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]);
297                         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]);
298 
299                     }
300 
301 
302 
303                     // Forming PRIM_INT__s_s_f_s[6 * 10];
304                     for(n = 0; n < 6; ++n)  // loop over orders of auxiliary function
305                     {
306 
307                         PRIM_INT__s_s_f_s[n * 10 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_d_s[n * 6 + 0]);
308                         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]);
309                         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]);
310 
311                         PRIM_INT__s_s_f_s[n * 10 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 0]);
312                         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]);
313 
314                         PRIM_INT__s_s_f_s[n * 10 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 0]);
315                         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]);
316 
317                         PRIM_INT__s_s_f_s[n * 10 + 3] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_d_s[n * 6 + 3]);
318                         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]);
319 
320                         PRIM_INT__s_s_f_s[n * 10 + 4] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 1]);
321                         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]);
322 
323                         PRIM_INT__s_s_f_s[n * 10 + 5] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_d_s[n * 6 + 5]);
324                         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]);
325 
326                         PRIM_INT__s_s_f_s[n * 10 + 6] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 3]);
327                         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]);
328                         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]);
329 
330                         PRIM_INT__s_s_f_s[n * 10 + 7] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 3]);
331                         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]);
332 
333                         PRIM_INT__s_s_f_s[n * 10 + 8] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 5]);
334                         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]);
335 
336                         PRIM_INT__s_s_f_s[n * 10 + 9] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 5]);
337                         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]);
338                         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]);
339 
340                     }
341 
342 
343                     VRR_J_s_p_f_s(
344                             PRIM_INT__s_p_f_s,
345                             PRIM_INT__s_s_f_s,
346                             PRIM_INT__s_s_d_s,
347                             P_PB,
348                             aop_PQ,
349                             one_over_2pq,
350                             3);
351 
352 
353 
354                     // Forming PRIM_INT__s_p_d_s[3 * 18];
355                     for(n = 0; n < 3; ++n)  // loop over orders of auxiliary function
356                     {
357 
358                         PRIM_INT__s_p_d_s[n * 18 + 0] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_d_s[n * 6 + 0]);
359                         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]);
360                         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]);
361 
362                         PRIM_INT__s_p_d_s[n * 18 + 1] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_d_s[n * 6 + 1]);
363                         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]);
364                         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]);
365 
366                         PRIM_INT__s_p_d_s[n * 18 + 2] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_d_s[n * 6 + 2]);
367                         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]);
368                         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]);
369 
370                         PRIM_INT__s_p_d_s[n * 18 + 3] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_d_s[n * 6 + 3]);
371                         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]);
372 
373                         PRIM_INT__s_p_d_s[n * 18 + 4] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_d_s[n * 6 + 4]);
374                         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]);
375 
376                         PRIM_INT__s_p_d_s[n * 18 + 5] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_d_s[n * 6 + 5]);
377                         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]);
378 
379                         PRIM_INT__s_p_d_s[n * 18 + 6] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_d_s[n * 6 + 0]);
380                         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]);
381 
382                         PRIM_INT__s_p_d_s[n * 18 + 7] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_d_s[n * 6 + 1]);
383                         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]);
384                         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]);
385 
386                         PRIM_INT__s_p_d_s[n * 18 + 8] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_d_s[n * 6 + 2]);
387                         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]);
388 
389                         PRIM_INT__s_p_d_s[n * 18 + 9] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_d_s[n * 6 + 3]);
390                         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]);
391                         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]);
392 
393                         PRIM_INT__s_p_d_s[n * 18 + 10] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_d_s[n * 6 + 4]);
394                         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]);
395                         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]);
396 
397                         PRIM_INT__s_p_d_s[n * 18 + 11] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_d_s[n * 6 + 5]);
398                         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]);
399 
400                         PRIM_INT__s_p_d_s[n * 18 + 12] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_d_s[n * 6 + 0]);
401                         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]);
402 
403                         PRIM_INT__s_p_d_s[n * 18 + 13] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_d_s[n * 6 + 1]);
404                         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]);
405 
406                         PRIM_INT__s_p_d_s[n * 18 + 14] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_d_s[n * 6 + 2]);
407                         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]);
408                         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]);
409 
410                         PRIM_INT__s_p_d_s[n * 18 + 15] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_d_s[n * 6 + 3]);
411                         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]);
412 
413                         PRIM_INT__s_p_d_s[n * 18 + 16] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_d_s[n * 6 + 4]);
414                         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]);
415                         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]);
416 
417                         PRIM_INT__s_p_d_s[n * 18 + 17] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_d_s[n * 6 + 5]);
418                         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]);
419                         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]);
420 
421                     }
422 
423 
424                     VRR_J_s_d_f_s(
425                             PRIM_INT__s_d_f_s,
426                             PRIM_INT__s_p_f_s,
427                             PRIM_INT__s_s_f_s,
428                             PRIM_INT__s_p_d_s,
429                             P_PB,
430                             a_over_p,
431                             aop_PQ,
432                             one_over_2p,
433                             one_over_2pq,
434                             2);
435 
436 
437                     VRR_K_s_s_g_s(
438                             PRIM_INT__s_s_g_s,
439                             PRIM_INT__s_s_f_s,
440                             PRIM_INT__s_s_d_s,
441                             Q_PA,
442                             a_over_q,
443                             aoq_PQ,
444                             one_over_2q,
445                             5);
446 
447 
448                     VRR_J_s_p_g_s(
449                             PRIM_INT__s_p_g_s,
450                             PRIM_INT__s_s_g_s,
451                             PRIM_INT__s_s_f_s,
452                             P_PB,
453                             aop_PQ,
454                             one_over_2pq,
455                             3);
456 
457 
458                     ostei_general_vrr_J(0, 2, 4, 0, 2,
459                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PB,
460                             PRIM_INT__s_p_g_s, NULL, PRIM_INT__s_s_g_s, PRIM_INT__s_p_f_s, NULL, PRIM_INT__s_d_g_s);
461 
462 
463 
464                     // Forming PRIM_INT__s_p_p_s[3 * 9];
465                     for(n = 0; n < 3; ++n)  // loop over orders of auxiliary function
466                     {
467 
468                         PRIM_INT__s_p_p_s[n * 9 + 0] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_p_s[n * 3 + 0]);
469                         PRIM_INT__s_p_p_s[n * 9 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_p_p_s[n * 9 + 0]);
470                         PRIM_INT__s_p_p_s[n * 9 + 0] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_p_p_s[n * 9 + 0]);
471 
472                         PRIM_INT__s_p_p_s[n * 9 + 1] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_p_s[n * 3 + 1]);
473                         PRIM_INT__s_p_p_s[n * 9 + 1] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_p_p_s[n * 9 + 1]);
474 
475                         PRIM_INT__s_p_p_s[n * 9 + 2] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_p_s[n * 3 + 2]);
476                         PRIM_INT__s_p_p_s[n * 9 + 2] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__s_p_p_s[n * 9 + 2]);
477 
478                         PRIM_INT__s_p_p_s[n * 9 + 3] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_p_s[n * 3 + 0]);
479                         PRIM_INT__s_p_p_s[n * 9 + 3] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_p_p_s[n * 9 + 3]);
480 
481                         PRIM_INT__s_p_p_s[n * 9 + 4] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_p_s[n * 3 + 1]);
482                         PRIM_INT__s_p_p_s[n * 9 + 4] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_p_p_s[n * 9 + 4]);
483                         PRIM_INT__s_p_p_s[n * 9 + 4] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_p_p_s[n * 9 + 4]);
484 
485                         PRIM_INT__s_p_p_s[n * 9 + 5] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_p_s[n * 3 + 2]);
486                         PRIM_INT__s_p_p_s[n * 9 + 5] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__s_p_p_s[n * 9 + 5]);
487 
488                         PRIM_INT__s_p_p_s[n * 9 + 6] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_p_s[n * 3 + 0]);
489                         PRIM_INT__s_p_p_s[n * 9 + 6] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_p_p_s[n * 9 + 6]);
490 
491                         PRIM_INT__s_p_p_s[n * 9 + 7] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_p_s[n * 3 + 1]);
492                         PRIM_INT__s_p_p_s[n * 9 + 7] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_p_p_s[n * 9 + 7]);
493 
494                         PRIM_INT__s_p_p_s[n * 9 + 8] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_p_s[n * 3 + 2]);
495                         PRIM_INT__s_p_p_s[n * 9 + 8] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__s_p_p_s[n * 9 + 8]);
496                         PRIM_INT__s_p_p_s[n * 9 + 8] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_p_p_s[n * 9 + 8]);
497 
498                     }
499 
500 
501                     VRR_J_s_d_d_s(
502                             PRIM_INT__s_d_d_s,
503                             PRIM_INT__s_p_d_s,
504                             PRIM_INT__s_s_d_s,
505                             PRIM_INT__s_p_p_s,
506                             P_PB,
507                             a_over_p,
508                             aop_PQ,
509                             one_over_2p,
510                             one_over_2pq,
511                             2);
512 
513 
514                     ostei_general_vrr_J(0, 3, 3, 0, 1,
515                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PB,
516                             PRIM_INT__s_d_f_s, NULL, PRIM_INT__s_p_f_s, PRIM_INT__s_d_d_s, NULL, PRIM_INT__s_f_f_s);
517 
518 
519                     VRR_K_s_s_h_s(
520                             PRIM_INT__s_s_h_s,
521                             PRIM_INT__s_s_g_s,
522                             PRIM_INT__s_s_f_s,
523                             Q_PA,
524                             a_over_q,
525                             aoq_PQ,
526                             one_over_2q,
527                             4);
528 
529 
530                     ostei_general_vrr_J(0, 1, 5, 0, 3,
531                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PB,
532                             PRIM_INT__s_s_h_s, NULL, NULL, PRIM_INT__s_s_g_s, NULL, PRIM_INT__s_p_h_s);
533 
534 
535                     ostei_general_vrr_J(0, 2, 5, 0, 2,
536                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PB,
537                             PRIM_INT__s_p_h_s, NULL, PRIM_INT__s_s_h_s, PRIM_INT__s_p_g_s, NULL, PRIM_INT__s_d_h_s);
538 
539 
540                     ostei_general_vrr_J(0, 3, 4, 0, 1,
541                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PB,
542                             PRIM_INT__s_d_g_s, NULL, PRIM_INT__s_p_g_s, PRIM_INT__s_d_f_s, NULL, PRIM_INT__s_f_g_s);
543 
544 
545                     ostei_general_vrr_J(0, 3, 5, 0, 1,
546                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PB,
547                             PRIM_INT__s_d_h_s, NULL, PRIM_INT__s_p_h_s, PRIM_INT__s_d_g_s, NULL, PRIM_INT__s_f_h_s);
548 
549 
550 
551 
552                     ////////////////////////////////////
553                     // Accumulate contracted integrals
554                     ////////////////////////////////////
555                     if(lastoffset == 0)
556                     {
557                         contract_all(60, PRIM_INT__s_d_f_s, PRIM_PTR_INT__s_d_f_s);
558                         contract_all(90, PRIM_INT__s_d_g_s, PRIM_PTR_INT__s_d_g_s);
559                         contract_all(126, PRIM_INT__s_d_h_s, PRIM_PTR_INT__s_d_h_s);
560                         contract_all(100, PRIM_INT__s_f_f_s, PRIM_PTR_INT__s_f_f_s);
561                         contract_all(150, PRIM_INT__s_f_g_s, PRIM_PTR_INT__s_f_g_s);
562                         contract_all(210, PRIM_INT__s_f_h_s, PRIM_PTR_INT__s_f_h_s);
563                     }
564                     else
565                     {
566                         contract(60, shelloffsets, PRIM_INT__s_d_f_s, PRIM_PTR_INT__s_d_f_s);
567                         contract(90, shelloffsets, PRIM_INT__s_d_g_s, PRIM_PTR_INT__s_d_g_s);
568                         contract(126, shelloffsets, PRIM_INT__s_d_h_s, PRIM_PTR_INT__s_d_h_s);
569                         contract(100, shelloffsets, PRIM_INT__s_f_f_s, PRIM_PTR_INT__s_f_f_s);
570                         contract(150, shelloffsets, PRIM_INT__s_f_g_s, PRIM_PTR_INT__s_f_g_s);
571                         contract(210, shelloffsets, PRIM_INT__s_f_h_s, PRIM_PTR_INT__s_f_h_s);
572                         PRIM_PTR_INT__s_d_f_s += lastoffset*60;
573                         PRIM_PTR_INT__s_d_g_s += lastoffset*90;
574                         PRIM_PTR_INT__s_d_h_s += lastoffset*126;
575                         PRIM_PTR_INT__s_f_f_s += lastoffset*100;
576                         PRIM_PTR_INT__s_f_g_s += lastoffset*150;
577                         PRIM_PTR_INT__s_f_h_s += lastoffset*210;
578                     }
579 
580                 }  // close loop over j
581             }  // close loop over i
582 
583             //Advance to the next batch
584             jstart = SIMINT_SIMD_ROUND(jend);
585 
586             //////////////////////////////////////////////
587             // Contracted integrals: Horizontal recurrance
588             //////////////////////////////////////////////
589 
590 
591             const double hAB[3] = { P.AB_x[ab], P.AB_y[ab], P.AB_z[ab] };
592 
593 
594             for(abcd = 0; abcd < nshellbatch; ++abcd, ++real_abcd)
595             {
596                 const double hCD[3] = { Q.AB_x[cd+abcd], Q.AB_y[cd+abcd], Q.AB_z[cd+abcd] };
597 
598                 // set up HRR pointers
599                 double const * restrict HRR_INT__s_d_f_s = INT__s_d_f_s + abcd * 60;
600                 double const * restrict HRR_INT__s_d_g_s = INT__s_d_g_s + abcd * 90;
601                 double const * restrict HRR_INT__s_d_h_s = INT__s_d_h_s + abcd * 126;
602                 double const * restrict HRR_INT__s_f_f_s = INT__s_f_f_s + abcd * 100;
603                 double const * restrict HRR_INT__s_f_g_s = INT__s_f_g_s + abcd * 150;
604                 double const * restrict HRR_INT__s_f_h_s = INT__s_f_h_s + abcd * 210;
605                 double * restrict HRR_INT__p_d_f_d = INT__p_d_f_d + real_abcd * 1080;
606 
607                 // form INT__p_d_f_s
608                 for(iket = 0; iket < 10; ++iket)
609                 {
610                     HRR_INT__p_d_f_s[0 * 10 + iket] = HRR_INT__s_f_f_s[0 * 10 + iket] - ( hAB[0] * HRR_INT__s_d_f_s[0 * 10 + iket] );
611 
612                     HRR_INT__p_d_f_s[1 * 10 + iket] = HRR_INT__s_f_f_s[1 * 10 + iket] - ( hAB[0] * HRR_INT__s_d_f_s[1 * 10 + iket] );
613 
614                     HRR_INT__p_d_f_s[2 * 10 + iket] = HRR_INT__s_f_f_s[2 * 10 + iket] - ( hAB[0] * HRR_INT__s_d_f_s[2 * 10 + iket] );
615 
616                     HRR_INT__p_d_f_s[3 * 10 + iket] = HRR_INT__s_f_f_s[3 * 10 + iket] - ( hAB[0] * HRR_INT__s_d_f_s[3 * 10 + iket] );
617 
618                     HRR_INT__p_d_f_s[4 * 10 + iket] = HRR_INT__s_f_f_s[4 * 10 + iket] - ( hAB[0] * HRR_INT__s_d_f_s[4 * 10 + iket] );
619 
620                     HRR_INT__p_d_f_s[5 * 10 + iket] = HRR_INT__s_f_f_s[5 * 10 + iket] - ( hAB[0] * HRR_INT__s_d_f_s[5 * 10 + iket] );
621 
622                     HRR_INT__p_d_f_s[6 * 10 + iket] = HRR_INT__s_f_f_s[1 * 10 + iket] - ( hAB[1] * HRR_INT__s_d_f_s[0 * 10 + iket] );
623 
624                     HRR_INT__p_d_f_s[7 * 10 + iket] = HRR_INT__s_f_f_s[3 * 10 + iket] - ( hAB[1] * HRR_INT__s_d_f_s[1 * 10 + iket] );
625 
626                     HRR_INT__p_d_f_s[8 * 10 + iket] = HRR_INT__s_f_f_s[4 * 10 + iket] - ( hAB[1] * HRR_INT__s_d_f_s[2 * 10 + iket] );
627 
628                     HRR_INT__p_d_f_s[9 * 10 + iket] = HRR_INT__s_f_f_s[6 * 10 + iket] - ( hAB[1] * HRR_INT__s_d_f_s[3 * 10 + iket] );
629 
630                     HRR_INT__p_d_f_s[10 * 10 + iket] = HRR_INT__s_f_f_s[7 * 10 + iket] - ( hAB[1] * HRR_INT__s_d_f_s[4 * 10 + iket] );
631 
632                     HRR_INT__p_d_f_s[11 * 10 + iket] = HRR_INT__s_f_f_s[8 * 10 + iket] - ( hAB[1] * HRR_INT__s_d_f_s[5 * 10 + iket] );
633 
634                     HRR_INT__p_d_f_s[12 * 10 + iket] = HRR_INT__s_f_f_s[2 * 10 + iket] - ( hAB[2] * HRR_INT__s_d_f_s[0 * 10 + iket] );
635 
636                     HRR_INT__p_d_f_s[13 * 10 + iket] = HRR_INT__s_f_f_s[4 * 10 + iket] - ( hAB[2] * HRR_INT__s_d_f_s[1 * 10 + iket] );
637 
638                     HRR_INT__p_d_f_s[14 * 10 + iket] = HRR_INT__s_f_f_s[5 * 10 + iket] - ( hAB[2] * HRR_INT__s_d_f_s[2 * 10 + iket] );
639 
640                     HRR_INT__p_d_f_s[15 * 10 + iket] = HRR_INT__s_f_f_s[7 * 10 + iket] - ( hAB[2] * HRR_INT__s_d_f_s[3 * 10 + iket] );
641 
642                     HRR_INT__p_d_f_s[16 * 10 + iket] = HRR_INT__s_f_f_s[8 * 10 + iket] - ( hAB[2] * HRR_INT__s_d_f_s[4 * 10 + iket] );
643 
644                     HRR_INT__p_d_f_s[17 * 10 + iket] = HRR_INT__s_f_f_s[9 * 10 + iket] - ( hAB[2] * HRR_INT__s_d_f_s[5 * 10 + iket] );
645 
646                 }
647 
648 
649                 // form INT__p_d_g_s
650                 for(iket = 0; iket < 15; ++iket)
651                 {
652                     HRR_INT__p_d_g_s[0 * 15 + iket] = HRR_INT__s_f_g_s[0 * 15 + iket] - ( hAB[0] * HRR_INT__s_d_g_s[0 * 15 + iket] );
653 
654                     HRR_INT__p_d_g_s[1 * 15 + iket] = HRR_INT__s_f_g_s[1 * 15 + iket] - ( hAB[0] * HRR_INT__s_d_g_s[1 * 15 + iket] );
655 
656                     HRR_INT__p_d_g_s[2 * 15 + iket] = HRR_INT__s_f_g_s[2 * 15 + iket] - ( hAB[0] * HRR_INT__s_d_g_s[2 * 15 + iket] );
657 
658                     HRR_INT__p_d_g_s[3 * 15 + iket] = HRR_INT__s_f_g_s[3 * 15 + iket] - ( hAB[0] * HRR_INT__s_d_g_s[3 * 15 + iket] );
659 
660                     HRR_INT__p_d_g_s[4 * 15 + iket] = HRR_INT__s_f_g_s[4 * 15 + iket] - ( hAB[0] * HRR_INT__s_d_g_s[4 * 15 + iket] );
661 
662                     HRR_INT__p_d_g_s[5 * 15 + iket] = HRR_INT__s_f_g_s[5 * 15 + iket] - ( hAB[0] * HRR_INT__s_d_g_s[5 * 15 + iket] );
663 
664                     HRR_INT__p_d_g_s[6 * 15 + iket] = HRR_INT__s_f_g_s[1 * 15 + iket] - ( hAB[1] * HRR_INT__s_d_g_s[0 * 15 + iket] );
665 
666                     HRR_INT__p_d_g_s[7 * 15 + iket] = HRR_INT__s_f_g_s[3 * 15 + iket] - ( hAB[1] * HRR_INT__s_d_g_s[1 * 15 + iket] );
667 
668                     HRR_INT__p_d_g_s[8 * 15 + iket] = HRR_INT__s_f_g_s[4 * 15 + iket] - ( hAB[1] * HRR_INT__s_d_g_s[2 * 15 + iket] );
669 
670                     HRR_INT__p_d_g_s[9 * 15 + iket] = HRR_INT__s_f_g_s[6 * 15 + iket] - ( hAB[1] * HRR_INT__s_d_g_s[3 * 15 + iket] );
671 
672                     HRR_INT__p_d_g_s[10 * 15 + iket] = HRR_INT__s_f_g_s[7 * 15 + iket] - ( hAB[1] * HRR_INT__s_d_g_s[4 * 15 + iket] );
673 
674                     HRR_INT__p_d_g_s[11 * 15 + iket] = HRR_INT__s_f_g_s[8 * 15 + iket] - ( hAB[1] * HRR_INT__s_d_g_s[5 * 15 + iket] );
675 
676                     HRR_INT__p_d_g_s[12 * 15 + iket] = HRR_INT__s_f_g_s[2 * 15 + iket] - ( hAB[2] * HRR_INT__s_d_g_s[0 * 15 + iket] );
677 
678                     HRR_INT__p_d_g_s[13 * 15 + iket] = HRR_INT__s_f_g_s[4 * 15 + iket] - ( hAB[2] * HRR_INT__s_d_g_s[1 * 15 + iket] );
679 
680                     HRR_INT__p_d_g_s[14 * 15 + iket] = HRR_INT__s_f_g_s[5 * 15 + iket] - ( hAB[2] * HRR_INT__s_d_g_s[2 * 15 + iket] );
681 
682                     HRR_INT__p_d_g_s[15 * 15 + iket] = HRR_INT__s_f_g_s[7 * 15 + iket] - ( hAB[2] * HRR_INT__s_d_g_s[3 * 15 + iket] );
683 
684                     HRR_INT__p_d_g_s[16 * 15 + iket] = HRR_INT__s_f_g_s[8 * 15 + iket] - ( hAB[2] * HRR_INT__s_d_g_s[4 * 15 + iket] );
685 
686                     HRR_INT__p_d_g_s[17 * 15 + iket] = HRR_INT__s_f_g_s[9 * 15 + iket] - ( hAB[2] * HRR_INT__s_d_g_s[5 * 15 + iket] );
687 
688                 }
689 
690 
691                 // form INT__p_d_h_s
692                 for(iket = 0; iket < 21; ++iket)
693                 {
694                     HRR_INT__p_d_h_s[0 * 21 + iket] = HRR_INT__s_f_h_s[0 * 21 + iket] - ( hAB[0] * HRR_INT__s_d_h_s[0 * 21 + iket] );
695 
696                     HRR_INT__p_d_h_s[1 * 21 + iket] = HRR_INT__s_f_h_s[1 * 21 + iket] - ( hAB[0] * HRR_INT__s_d_h_s[1 * 21 + iket] );
697 
698                     HRR_INT__p_d_h_s[2 * 21 + iket] = HRR_INT__s_f_h_s[2 * 21 + iket] - ( hAB[0] * HRR_INT__s_d_h_s[2 * 21 + iket] );
699 
700                     HRR_INT__p_d_h_s[3 * 21 + iket] = HRR_INT__s_f_h_s[3 * 21 + iket] - ( hAB[0] * HRR_INT__s_d_h_s[3 * 21 + iket] );
701 
702                     HRR_INT__p_d_h_s[4 * 21 + iket] = HRR_INT__s_f_h_s[4 * 21 + iket] - ( hAB[0] * HRR_INT__s_d_h_s[4 * 21 + iket] );
703 
704                     HRR_INT__p_d_h_s[5 * 21 + iket] = HRR_INT__s_f_h_s[5 * 21 + iket] - ( hAB[0] * HRR_INT__s_d_h_s[5 * 21 + iket] );
705 
706                     HRR_INT__p_d_h_s[6 * 21 + iket] = HRR_INT__s_f_h_s[1 * 21 + iket] - ( hAB[1] * HRR_INT__s_d_h_s[0 * 21 + iket] );
707 
708                     HRR_INT__p_d_h_s[7 * 21 + iket] = HRR_INT__s_f_h_s[3 * 21 + iket] - ( hAB[1] * HRR_INT__s_d_h_s[1 * 21 + iket] );
709 
710                     HRR_INT__p_d_h_s[8 * 21 + iket] = HRR_INT__s_f_h_s[4 * 21 + iket] - ( hAB[1] * HRR_INT__s_d_h_s[2 * 21 + iket] );
711 
712                     HRR_INT__p_d_h_s[9 * 21 + iket] = HRR_INT__s_f_h_s[6 * 21 + iket] - ( hAB[1] * HRR_INT__s_d_h_s[3 * 21 + iket] );
713 
714                     HRR_INT__p_d_h_s[10 * 21 + iket] = HRR_INT__s_f_h_s[7 * 21 + iket] - ( hAB[1] * HRR_INT__s_d_h_s[4 * 21 + iket] );
715 
716                     HRR_INT__p_d_h_s[11 * 21 + iket] = HRR_INT__s_f_h_s[8 * 21 + iket] - ( hAB[1] * HRR_INT__s_d_h_s[5 * 21 + iket] );
717 
718                     HRR_INT__p_d_h_s[12 * 21 + iket] = HRR_INT__s_f_h_s[2 * 21 + iket] - ( hAB[2] * HRR_INT__s_d_h_s[0 * 21 + iket] );
719 
720                     HRR_INT__p_d_h_s[13 * 21 + iket] = HRR_INT__s_f_h_s[4 * 21 + iket] - ( hAB[2] * HRR_INT__s_d_h_s[1 * 21 + iket] );
721 
722                     HRR_INT__p_d_h_s[14 * 21 + iket] = HRR_INT__s_f_h_s[5 * 21 + iket] - ( hAB[2] * HRR_INT__s_d_h_s[2 * 21 + iket] );
723 
724                     HRR_INT__p_d_h_s[15 * 21 + iket] = HRR_INT__s_f_h_s[7 * 21 + iket] - ( hAB[2] * HRR_INT__s_d_h_s[3 * 21 + iket] );
725 
726                     HRR_INT__p_d_h_s[16 * 21 + iket] = HRR_INT__s_f_h_s[8 * 21 + iket] - ( hAB[2] * HRR_INT__s_d_h_s[4 * 21 + iket] );
727 
728                     HRR_INT__p_d_h_s[17 * 21 + iket] = HRR_INT__s_f_h_s[9 * 21 + iket] - ( hAB[2] * HRR_INT__s_d_h_s[5 * 21 + iket] );
729 
730                 }
731 
732 
733                 // form INT__p_d_f_p
734                 HRR_L_f_p(
735                     HRR_INT__p_d_f_p,
736                     HRR_INT__p_d_f_s,
737                     HRR_INT__p_d_g_s,
738                     hCD, 18);
739 
740                 // form INT__p_d_g_p
741                 HRR_L_g_p(
742                     HRR_INT__p_d_g_p,
743                     HRR_INT__p_d_g_s,
744                     HRR_INT__p_d_h_s,
745                     hCD, 18);
746 
747                 // form INT__p_d_f_d
748                 HRR_L_f_d(
749                     HRR_INT__p_d_f_d,
750                     HRR_INT__p_d_f_p,
751                     HRR_INT__p_d_g_p,
752                     hCD, 18);
753 
754 
755             }  // close HRR loop
756 
757 
758         }   // close loop cdbatch
759 
760         istart = iend;
761     }  // close loop over ab
762 
763     return P.nshell12_clip * Q.nshell12_clip;
764 }
765 
766