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