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