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