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