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