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_i_g_p_s(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__i_g_p_s)8 int ostei_i_g_p_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__i_g_p_s)
13 {
14 
15     SIMINT_ASSUME_ALIGN_DBL(work);
16     SIMINT_ASSUME_ALIGN_DBL(INT__i_g_p_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__i_s_p_s = work + (SIMINT_NSHELL_SIMD * 0);
29     double * const INT__k_s_p_s = work + (SIMINT_NSHELL_SIMD * 84);
30     double * const INT__l_s_p_s = work + (SIMINT_NSHELL_SIMD * 192);
31     double * const INT__m_s_p_s = work + (SIMINT_NSHELL_SIMD * 327);
32     double * const INT__n_s_p_s = work + (SIMINT_NSHELL_SIMD * 492);
33     SIMINT_DBLTYPE * const primwork = (SIMINT_DBLTYPE *)(work + SIMINT_NSHELL_SIMD*690);
34     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_s = primwork + 0;
35     SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_s_s = primwork + 12;
36     SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_s_s = primwork + 45;
37     SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_s_s = primwork + 105;
38     SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_s_s = primwork + 195;
39     SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_s_s = primwork + 315;
40     SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_s_s = primwork + 462;
41     SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_p_s = primwork + 630;
42     SIMINT_DBLTYPE * const restrict PRIM_INT__k_s_s_s = primwork + 714;
43     SIMINT_DBLTYPE * const restrict PRIM_INT__k_s_p_s = primwork + 894;
44     SIMINT_DBLTYPE * const restrict PRIM_INT__l_s_s_s = primwork + 1002;
45     SIMINT_DBLTYPE * const restrict PRIM_INT__l_s_p_s = primwork + 1182;
46     SIMINT_DBLTYPE * const restrict PRIM_INT__m_s_s_s = primwork + 1317;
47     SIMINT_DBLTYPE * const restrict PRIM_INT__m_s_p_s = primwork + 1482;
48     SIMINT_DBLTYPE * const restrict PRIM_INT__n_s_s_s = primwork + 1647;
49     SIMINT_DBLTYPE * const restrict PRIM_INT__n_s_p_s = primwork + 1779;
50     double * const hrrwork = (double *)(primwork + 1977);
51     double * const HRR_INT__i_p_p_s = hrrwork + 0;
52     double * const HRR_INT__i_d_p_s = hrrwork + 252;
53     double * const HRR_INT__i_f_p_s = hrrwork + 756;
54     double * const HRR_INT__k_p_p_s = hrrwork + 1596;
55     double * const HRR_INT__k_d_p_s = hrrwork + 1920;
56     double * const HRR_INT__k_f_p_s = hrrwork + 2568;
57     double * const HRR_INT__l_p_p_s = hrrwork + 3648;
58     double * const HRR_INT__l_d_p_s = hrrwork + 4053;
59     double * const HRR_INT__m_p_p_s = hrrwork + 4863;
60 
61 
62     // Create constants
63     const SIMINT_DBLTYPE const_1 = SIMINT_DBLSET1(1);
64     const SIMINT_DBLTYPE const_10 = SIMINT_DBLSET1(10);
65     const SIMINT_DBLTYPE const_2 = SIMINT_DBLSET1(2);
66     const SIMINT_DBLTYPE const_3 = SIMINT_DBLSET1(3);
67     const SIMINT_DBLTYPE const_4 = SIMINT_DBLSET1(4);
68     const SIMINT_DBLTYPE const_5 = SIMINT_DBLSET1(5);
69     const SIMINT_DBLTYPE const_6 = SIMINT_DBLSET1(6);
70     const SIMINT_DBLTYPE const_7 = SIMINT_DBLSET1(7);
71     const SIMINT_DBLTYPE const_8 = SIMINT_DBLSET1(8);
72     const SIMINT_DBLTYPE const_9 = SIMINT_DBLSET1(9);
73     const SIMINT_DBLTYPE one_half = SIMINT_DBLSET1(0.5);
74 
75 
76     ////////////////////////////////////////
77     // Loop over shells and primitives
78     ////////////////////////////////////////
79 
80     real_abcd = 0;
81     istart = 0;
82     for(ab = 0; ab < P.nshell12_clip; ++ab)
83     {
84         const int iend = istart + P.nprim12[ab];
85 
86         cd = 0;
87         jstart = 0;
88 
89         for(cd = 0; cd < Q.nshell12_clip; cd += SIMINT_NSHELL_SIMD)
90         {
91             const int nshellbatch = ((cd + SIMINT_NSHELL_SIMD) > Q.nshell12_clip) ? Q.nshell12_clip - cd : SIMINT_NSHELL_SIMD;
92             int jend = jstart;
93             for(i = 0; i < nshellbatch; i++)
94                 jend += Q.nprim12[cd+i];
95 
96             // Clear the beginning of the workspace (where we are accumulating integrals)
97             memset(work, 0, SIMINT_NSHELL_SIMD * 690 * sizeof(double));
98             abcd = 0;
99 
100 
101             for(i = istart; i < iend; ++i)
102             {
103                 SIMINT_DBLTYPE bra_screen_max;  // only used if check_screen
104 
105                 if(check_screen)
106                 {
107                     // Skip this whole thing if always insignificant
108                     if((P.screen[i] * Q.screen_max) < screen_tol)
109                         continue;
110                     bra_screen_max = SIMINT_DBLSET1(P.screen[i]);
111                 }
112 
113                 icd = 0;
114                 iprimcd = 0;
115                 nprim_icd = Q.nprim12[cd];
116                 double * restrict PRIM_PTR_INT__i_s_p_s = INT__i_s_p_s + abcd * 84;
117                 double * restrict PRIM_PTR_INT__k_s_p_s = INT__k_s_p_s + abcd * 108;
118                 double * restrict PRIM_PTR_INT__l_s_p_s = INT__l_s_p_s + abcd * 135;
119                 double * restrict PRIM_PTR_INT__m_s_p_s = INT__m_s_p_s + abcd * 165;
120                 double * restrict PRIM_PTR_INT__n_s_p_s = INT__n_s_p_s + abcd * 198;
121 
122 
123 
124                 // Load these one per loop over i
125                 const SIMINT_DBLTYPE P_alpha = SIMINT_DBLSET1(P.alpha[i]);
126                 const SIMINT_DBLTYPE P_prefac = SIMINT_DBLSET1(P.prefac[i]);
127                 const SIMINT_DBLTYPE Pxyz[3] = { SIMINT_DBLSET1(P.x[i]), SIMINT_DBLSET1(P.y[i]), SIMINT_DBLSET1(P.z[i]) };
128 
129                 const SIMINT_DBLTYPE P_PA[3] = { SIMINT_DBLSET1(P.PA_x[i]), SIMINT_DBLSET1(P.PA_y[i]), SIMINT_DBLSET1(P.PA_z[i]) };
130 
131                 for(j = jstart; j < jend; j += SIMINT_SIMD_LEN)
132                 {
133                     // calculate the shell offsets
134                     // these are the offset from the shell pointed to by cd
135                     // for each element
136                     int shelloffsets[SIMINT_SIMD_LEN] = {0};
137                     int lastoffset = 0;
138                     const int nlane = ( ((j + SIMINT_SIMD_LEN) < jend) ? SIMINT_SIMD_LEN : (jend - j));
139 
140                     if((iprimcd + SIMINT_SIMD_LEN) >= nprim_icd)
141                     {
142                         // Handle if the first element of the vector is a new shell
143                         if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
144                         {
145                             nprim_icd += Q.nprim12[cd + (++icd)];
146                             PRIM_PTR_INT__i_s_p_s += 84;
147                             PRIM_PTR_INT__k_s_p_s += 108;
148                             PRIM_PTR_INT__l_s_p_s += 135;
149                             PRIM_PTR_INT__m_s_p_s += 165;
150                             PRIM_PTR_INT__n_s_p_s += 198;
151                         }
152                         iprimcd++;
153                         for(n = 1; n < SIMINT_SIMD_LEN; ++n)
154                         {
155                             if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
156                             {
157                                 shelloffsets[n] = shelloffsets[n-1] + 1;
158                                 lastoffset++;
159                                 nprim_icd += Q.nprim12[cd + (++icd)];
160                             }
161                             else
162                                 shelloffsets[n] = shelloffsets[n-1];
163                             iprimcd++;
164                         }
165                     }
166                     else
167                         iprimcd += SIMINT_SIMD_LEN;
168 
169                     // Do we have to compute this vector (or has it been screened out)?
170                     // (not_screened != 0 means we have to do this vector)
171                     if(check_screen)
172                     {
173                         const double vmax = vector_max(SIMINT_MUL(bra_screen_max, SIMINT_DBLLOAD(Q.screen, j)));
174                         if(vmax < screen_tol)
175                         {
176                             PRIM_PTR_INT__i_s_p_s += lastoffset*84;
177                             PRIM_PTR_INT__k_s_p_s += lastoffset*108;
178                             PRIM_PTR_INT__l_s_p_s += lastoffset*135;
179                             PRIM_PTR_INT__m_s_p_s += lastoffset*165;
180                             PRIM_PTR_INT__n_s_p_s += lastoffset*198;
181                             continue;
182                         }
183                     }
184 
185                     const SIMINT_DBLTYPE Q_alpha = SIMINT_DBLLOAD(Q.alpha, j);
186                     const SIMINT_DBLTYPE PQalpha_mul = SIMINT_MUL(P_alpha, Q_alpha);
187                     const SIMINT_DBLTYPE PQalpha_sum = SIMINT_ADD(P_alpha, Q_alpha);
188                     const SIMINT_DBLTYPE one_over_PQalpha_sum = SIMINT_DIV(const_1, PQalpha_sum);
189 
190 
191                     /* construct R2 = (Px - Qx)**2 + (Py - Qy)**2 + (Pz -Qz)**2 */
192                     SIMINT_DBLTYPE PQ[3];
193                     PQ[0] = SIMINT_SUB(Pxyz[0], SIMINT_DBLLOAD(Q.x, j));
194                     PQ[1] = SIMINT_SUB(Pxyz[1], SIMINT_DBLLOAD(Q.y, j));
195                     PQ[2] = SIMINT_SUB(Pxyz[2], SIMINT_DBLLOAD(Q.z, j));
196                     SIMINT_DBLTYPE R2 = SIMINT_MUL(PQ[0], PQ[0]);
197                     R2 = SIMINT_FMADD(PQ[1], PQ[1], R2);
198                     R2 = SIMINT_FMADD(PQ[2], PQ[2], R2);
199 
200                     const SIMINT_DBLTYPE alpha = SIMINT_MUL(PQalpha_mul, one_over_PQalpha_sum); // alpha from MEST
201                     const SIMINT_DBLTYPE one_over_p = SIMINT_DIV(const_1, P_alpha);
202                     const SIMINT_DBLTYPE one_over_q = SIMINT_DIV(const_1, Q_alpha);
203                     const SIMINT_DBLTYPE one_over_2p = SIMINT_MUL(one_half, one_over_p);
204                     const SIMINT_DBLTYPE one_over_2q = SIMINT_MUL(one_half, one_over_q);
205                     const SIMINT_DBLTYPE one_over_2pq = SIMINT_MUL(one_half, one_over_PQalpha_sum);
206                     const SIMINT_DBLTYPE Q_PA[3] = { SIMINT_DBLLOAD(Q.PA_x, j), SIMINT_DBLLOAD(Q.PA_y, j), SIMINT_DBLLOAD(Q.PA_z, j) };
207 
208                     // NOTE: Minus sign!
209                     const SIMINT_DBLTYPE a_over_p = SIMINT_MUL(SIMINT_NEG(alpha), one_over_p);
210                     SIMINT_DBLTYPE aop_PQ[3];
211                     aop_PQ[0] = SIMINT_MUL(a_over_p, PQ[0]);
212                     aop_PQ[1] = SIMINT_MUL(a_over_p, PQ[1]);
213                     aop_PQ[2] = SIMINT_MUL(a_over_p, PQ[2]);
214 
215                     SIMINT_DBLTYPE a_over_q = SIMINT_MUL(alpha, one_over_q);
216                     SIMINT_DBLTYPE aoq_PQ[3];
217                     aoq_PQ[0] = SIMINT_MUL(a_over_q, PQ[0]);
218                     aoq_PQ[1] = SIMINT_MUL(a_over_q, PQ[1]);
219                     aoq_PQ[2] = SIMINT_MUL(a_over_q, PQ[2]);
220                     // Put a minus sign here so we don't have to in RR routines
221                     a_over_q = SIMINT_NEG(a_over_q);
222 
223 
224                     //////////////////////////////////////////////
225                     // Fjt function section
226                     // Maximum v value: 11
227                     //////////////////////////////////////////////
228                     // The parameter to the Fjt function
229                     const SIMINT_DBLTYPE F_x = SIMINT_MUL(R2, alpha);
230 
231 
232                     const SIMINT_DBLTYPE Q_prefac = mask_load(nlane, Q.prefac + j);
233 
234 
235                     boys_F_split(PRIM_INT__s_s_s_s, F_x, 11);
236                     SIMINT_DBLTYPE prefac = SIMINT_SQRT(one_over_PQalpha_sum);
237                     prefac = SIMINT_MUL(SIMINT_MUL(P_prefac, Q_prefac), prefac);
238                     for(n = 0; n <= 11; n++)
239                         PRIM_INT__s_s_s_s[n] = SIMINT_MUL(PRIM_INT__s_s_s_s[n], prefac);
240 
241                     //////////////////////////////////////////////
242                     // Primitive integrals: Vertical recurrance
243                     //////////////////////////////////////////////
244 
245                     const SIMINT_DBLTYPE vrr_const_1_over_2p = one_over_2p;
246                     const SIMINT_DBLTYPE vrr_const_2_over_2p = SIMINT_MUL(const_2, one_over_2p);
247                     const SIMINT_DBLTYPE vrr_const_3_over_2p = SIMINT_MUL(const_3, one_over_2p);
248                     const SIMINT_DBLTYPE vrr_const_4_over_2p = SIMINT_MUL(const_4, one_over_2p);
249                     const SIMINT_DBLTYPE vrr_const_5_over_2p = SIMINT_MUL(const_5, one_over_2p);
250                     const SIMINT_DBLTYPE vrr_const_6_over_2p = SIMINT_MUL(const_6, one_over_2p);
251                     const SIMINT_DBLTYPE vrr_const_7_over_2p = SIMINT_MUL(const_7, one_over_2p);
252                     const SIMINT_DBLTYPE vrr_const_8_over_2p = SIMINT_MUL(const_8, one_over_2p);
253                     const SIMINT_DBLTYPE vrr_const_9_over_2p = SIMINT_MUL(const_9, one_over_2p);
254                     const SIMINT_DBLTYPE vrr_const_1_over_2pq = one_over_2pq;
255                     const SIMINT_DBLTYPE vrr_const_2_over_2pq = SIMINT_MUL(const_2, one_over_2pq);
256                     const SIMINT_DBLTYPE vrr_const_3_over_2pq = SIMINT_MUL(const_3, one_over_2pq);
257                     const SIMINT_DBLTYPE vrr_const_4_over_2pq = SIMINT_MUL(const_4, one_over_2pq);
258                     const SIMINT_DBLTYPE vrr_const_5_over_2pq = SIMINT_MUL(const_5, one_over_2pq);
259                     const SIMINT_DBLTYPE vrr_const_6_over_2pq = SIMINT_MUL(const_6, one_over_2pq);
260                     const SIMINT_DBLTYPE vrr_const_7_over_2pq = SIMINT_MUL(const_7, one_over_2pq);
261                     const SIMINT_DBLTYPE vrr_const_8_over_2pq = SIMINT_MUL(const_8, one_over_2pq);
262                     const SIMINT_DBLTYPE vrr_const_9_over_2pq = SIMINT_MUL(const_9, one_over_2pq);
263                     const SIMINT_DBLTYPE vrr_const_10_over_2pq = SIMINT_MUL(const_10, one_over_2pq);
264 
265 
266 
267                     // Forming PRIM_INT__p_s_s_s[11 * 3];
268                     for(n = 0; n < 11; ++n)  // loop over orders of auxiliary function
269                     {
270 
271                         PRIM_INT__p_s_s_s[n * 3 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
272                         PRIM_INT__p_s_s_s[n * 3 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_s_s[n * 3 + 0]);
273 
274                         PRIM_INT__p_s_s_s[n * 3 + 1] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
275                         PRIM_INT__p_s_s_s[n * 3 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_s_s[n * 3 + 1]);
276 
277                         PRIM_INT__p_s_s_s[n * 3 + 2] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
278                         PRIM_INT__p_s_s_s[n * 3 + 2] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_s_s[n * 3 + 2]);
279 
280                     }
281 
282 
283 
284                     // Forming PRIM_INT__d_s_s_s[10 * 6];
285                     for(n = 0; n < 10; ++n)  // loop over orders of auxiliary function
286                     {
287 
288                         PRIM_INT__d_s_s_s[n * 6 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__p_s_s_s[n * 3 + 0]);
289                         PRIM_INT__d_s_s_s[n * 6 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__d_s_s_s[n * 6 + 0]);
290                         PRIM_INT__d_s_s_s[n * 6 + 0] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__d_s_s_s[n * 6 + 0]);
291 
292                         PRIM_INT__d_s_s_s[n * 6 + 3] = SIMINT_MUL(P_PA[1], PRIM_INT__p_s_s_s[n * 3 + 1]);
293                         PRIM_INT__d_s_s_s[n * 6 + 3] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__d_s_s_s[n * 6 + 3]);
294                         PRIM_INT__d_s_s_s[n * 6 + 3] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__d_s_s_s[n * 6 + 3]);
295 
296                         PRIM_INT__d_s_s_s[n * 6 + 5] = SIMINT_MUL(P_PA[2], PRIM_INT__p_s_s_s[n * 3 + 2]);
297                         PRIM_INT__d_s_s_s[n * 6 + 5] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__d_s_s_s[n * 6 + 5]);
298                         PRIM_INT__d_s_s_s[n * 6 + 5] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__d_s_s_s[n * 6 + 5]);
299 
300                     }
301 
302 
303 
304                     // Forming PRIM_INT__f_s_s_s[9 * 10];
305                     for(n = 0; n < 9; ++n)  // loop over orders of auxiliary function
306                     {
307 
308                         PRIM_INT__f_s_s_s[n * 10 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__d_s_s_s[n * 6 + 0]);
309                         PRIM_INT__f_s_s_s[n * 10 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__f_s_s_s[n * 10 + 0]);
310                         PRIM_INT__f_s_s_s[n * 10 + 0] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__p_s_s_s[(n+1) * 3 + 0], PRIM_INT__p_s_s_s[n * 3 + 0]), PRIM_INT__f_s_s_s[n * 10 + 0]);
311 
312                         PRIM_INT__f_s_s_s[n * 10 + 1] = SIMINT_MUL(P_PA[1], PRIM_INT__d_s_s_s[n * 6 + 0]);
313                         PRIM_INT__f_s_s_s[n * 10 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__f_s_s_s[n * 10 + 1]);
314 
315                         PRIM_INT__f_s_s_s[n * 10 + 2] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 0]);
316                         PRIM_INT__f_s_s_s[n * 10 + 2] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 0], PRIM_INT__f_s_s_s[n * 10 + 2]);
317 
318                         PRIM_INT__f_s_s_s[n * 10 + 6] = SIMINT_MUL(P_PA[1], PRIM_INT__d_s_s_s[n * 6 + 3]);
319                         PRIM_INT__f_s_s_s[n * 10 + 6] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__f_s_s_s[n * 10 + 6]);
320                         PRIM_INT__f_s_s_s[n * 10 + 6] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__p_s_s_s[(n+1) * 3 + 1], PRIM_INT__p_s_s_s[n * 3 + 1]), PRIM_INT__f_s_s_s[n * 10 + 6]);
321 
322                         PRIM_INT__f_s_s_s[n * 10 + 7] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 3]);
323                         PRIM_INT__f_s_s_s[n * 10 + 7] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 3], PRIM_INT__f_s_s_s[n * 10 + 7]);
324 
325                         PRIM_INT__f_s_s_s[n * 10 + 9] = SIMINT_MUL(P_PA[2], PRIM_INT__d_s_s_s[n * 6 + 5]);
326                         PRIM_INT__f_s_s_s[n * 10 + 9] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__d_s_s_s[(n+1) * 6 + 5], PRIM_INT__f_s_s_s[n * 10 + 9]);
327                         PRIM_INT__f_s_s_s[n * 10 + 9] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__p_s_s_s[(n+1) * 3 + 2], PRIM_INT__p_s_s_s[n * 3 + 2]), PRIM_INT__f_s_s_s[n * 10 + 9]);
328 
329                     }
330 
331 
332                     VRR_I_g_s_s_s(
333                             PRIM_INT__g_s_s_s,
334                             PRIM_INT__f_s_s_s,
335                             PRIM_INT__d_s_s_s,
336                             P_PA,
337                             a_over_p,
338                             aop_PQ,
339                             one_over_2p,
340                             8);
341 
342 
343                     VRR_I_h_s_s_s(
344                             PRIM_INT__h_s_s_s,
345                             PRIM_INT__g_s_s_s,
346                             PRIM_INT__f_s_s_s,
347                             P_PA,
348                             a_over_p,
349                             aop_PQ,
350                             one_over_2p,
351                             7);
352 
353 
354                     ostei_general_vrr1_I(6, 6,
355                             one_over_2p, a_over_p, aop_PQ, P_PA,
356                             PRIM_INT__h_s_s_s, PRIM_INT__g_s_s_s, PRIM_INT__i_s_s_s);
357 
358 
359                     ostei_general_vrr_K(6, 0, 1, 0, 1,
360                             one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
361                             PRIM_INT__i_s_s_s, NULL, NULL, PRIM_INT__h_s_s_s, NULL, PRIM_INT__i_s_p_s);
362 
363 
364                     ostei_general_vrr1_I(7, 5,
365                             one_over_2p, a_over_p, aop_PQ, P_PA,
366                             PRIM_INT__i_s_s_s, PRIM_INT__h_s_s_s, PRIM_INT__k_s_s_s);
367 
368 
369                     ostei_general_vrr_K(7, 0, 1, 0, 1,
370                             one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
371                             PRIM_INT__k_s_s_s, NULL, NULL, PRIM_INT__i_s_s_s, NULL, PRIM_INT__k_s_p_s);
372 
373 
374                     ostei_general_vrr1_I(8, 4,
375                             one_over_2p, a_over_p, aop_PQ, P_PA,
376                             PRIM_INT__k_s_s_s, PRIM_INT__i_s_s_s, PRIM_INT__l_s_s_s);
377 
378 
379                     ostei_general_vrr_K(8, 0, 1, 0, 1,
380                             one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
381                             PRIM_INT__l_s_s_s, NULL, NULL, PRIM_INT__k_s_s_s, NULL, PRIM_INT__l_s_p_s);
382 
383 
384                     ostei_general_vrr1_I(9, 3,
385                             one_over_2p, a_over_p, aop_PQ, P_PA,
386                             PRIM_INT__l_s_s_s, PRIM_INT__k_s_s_s, PRIM_INT__m_s_s_s);
387 
388 
389                     ostei_general_vrr_K(9, 0, 1, 0, 1,
390                             one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
391                             PRIM_INT__m_s_s_s, NULL, NULL, PRIM_INT__l_s_s_s, NULL, PRIM_INT__m_s_p_s);
392 
393 
394                     ostei_general_vrr1_I(10, 2,
395                             one_over_2p, a_over_p, aop_PQ, P_PA,
396                             PRIM_INT__m_s_s_s, PRIM_INT__l_s_s_s, PRIM_INT__n_s_s_s);
397 
398 
399                     ostei_general_vrr_K(10, 0, 1, 0, 1,
400                             one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PA,
401                             PRIM_INT__n_s_s_s, NULL, NULL, PRIM_INT__m_s_s_s, NULL, PRIM_INT__n_s_p_s);
402 
403 
404 
405 
406                     ////////////////////////////////////
407                     // Accumulate contracted integrals
408                     ////////////////////////////////////
409                     if(lastoffset == 0)
410                     {
411                         contract_all(84, PRIM_INT__i_s_p_s, PRIM_PTR_INT__i_s_p_s);
412                         contract_all(108, PRIM_INT__k_s_p_s, PRIM_PTR_INT__k_s_p_s);
413                         contract_all(135, PRIM_INT__l_s_p_s, PRIM_PTR_INT__l_s_p_s);
414                         contract_all(165, PRIM_INT__m_s_p_s, PRIM_PTR_INT__m_s_p_s);
415                         contract_all(198, PRIM_INT__n_s_p_s, PRIM_PTR_INT__n_s_p_s);
416                     }
417                     else
418                     {
419                         contract(84, shelloffsets, PRIM_INT__i_s_p_s, PRIM_PTR_INT__i_s_p_s);
420                         contract(108, shelloffsets, PRIM_INT__k_s_p_s, PRIM_PTR_INT__k_s_p_s);
421                         contract(135, shelloffsets, PRIM_INT__l_s_p_s, PRIM_PTR_INT__l_s_p_s);
422                         contract(165, shelloffsets, PRIM_INT__m_s_p_s, PRIM_PTR_INT__m_s_p_s);
423                         contract(198, shelloffsets, PRIM_INT__n_s_p_s, PRIM_PTR_INT__n_s_p_s);
424                         PRIM_PTR_INT__i_s_p_s += lastoffset*84;
425                         PRIM_PTR_INT__k_s_p_s += lastoffset*108;
426                         PRIM_PTR_INT__l_s_p_s += lastoffset*135;
427                         PRIM_PTR_INT__m_s_p_s += lastoffset*165;
428                         PRIM_PTR_INT__n_s_p_s += lastoffset*198;
429                     }
430 
431                 }  // close loop over j
432             }  // close loop over i
433 
434             //Advance to the next batch
435             jstart = SIMINT_SIMD_ROUND(jend);
436 
437             //////////////////////////////////////////////
438             // Contracted integrals: Horizontal recurrance
439             //////////////////////////////////////////////
440 
441 
442             const double hAB[3] = { P.AB_x[ab], P.AB_y[ab], P.AB_z[ab] };
443 
444 
445             for(abcd = 0; abcd < nshellbatch; ++abcd, ++real_abcd)
446             {
447 
448                 // set up HRR pointers
449                 double const * restrict HRR_INT__i_s_p_s = INT__i_s_p_s + abcd * 84;
450                 double const * restrict HRR_INT__k_s_p_s = INT__k_s_p_s + abcd * 108;
451                 double const * restrict HRR_INT__l_s_p_s = INT__l_s_p_s + abcd * 135;
452                 double const * restrict HRR_INT__m_s_p_s = INT__m_s_p_s + abcd * 165;
453                 double const * restrict HRR_INT__n_s_p_s = INT__n_s_p_s + abcd * 198;
454                 double * restrict HRR_INT__i_g_p_s = INT__i_g_p_s + real_abcd * 1260;
455 
456                 // form INT__i_p_p_s
457                 ostei_general_hrr_J(6, 1, 1, 0, hAB, HRR_INT__k_s_p_s, HRR_INT__i_s_p_s, HRR_INT__i_p_p_s);
458 
459                 // form INT__k_p_p_s
460                 ostei_general_hrr_J(7, 1, 1, 0, hAB, HRR_INT__l_s_p_s, HRR_INT__k_s_p_s, HRR_INT__k_p_p_s);
461 
462                 // form INT__l_p_p_s
463                 ostei_general_hrr_J(8, 1, 1, 0, hAB, HRR_INT__m_s_p_s, HRR_INT__l_s_p_s, HRR_INT__l_p_p_s);
464 
465                 // form INT__m_p_p_s
466                 ostei_general_hrr_J(9, 1, 1, 0, hAB, HRR_INT__n_s_p_s, HRR_INT__m_s_p_s, HRR_INT__m_p_p_s);
467 
468                 // form INT__i_d_p_s
469                 ostei_general_hrr_J(6, 2, 1, 0, hAB, HRR_INT__k_p_p_s, HRR_INT__i_p_p_s, HRR_INT__i_d_p_s);
470 
471                 // form INT__k_d_p_s
472                 ostei_general_hrr_J(7, 2, 1, 0, hAB, HRR_INT__l_p_p_s, HRR_INT__k_p_p_s, HRR_INT__k_d_p_s);
473 
474                 // form INT__l_d_p_s
475                 ostei_general_hrr_J(8, 2, 1, 0, hAB, HRR_INT__m_p_p_s, HRR_INT__l_p_p_s, HRR_INT__l_d_p_s);
476 
477                 // form INT__i_f_p_s
478                 ostei_general_hrr_J(6, 3, 1, 0, hAB, HRR_INT__k_d_p_s, HRR_INT__i_d_p_s, HRR_INT__i_f_p_s);
479 
480                 // form INT__k_f_p_s
481                 ostei_general_hrr_J(7, 3, 1, 0, hAB, HRR_INT__l_d_p_s, HRR_INT__k_d_p_s, HRR_INT__k_f_p_s);
482 
483                 // form INT__i_g_p_s
484                 ostei_general_hrr_J(6, 4, 1, 0, hAB, HRR_INT__k_f_p_s, HRR_INT__i_f_p_s, HRR_INT__i_g_p_s);
485 
486 
487             }  // close HRR loop
488 
489 
490         }   // close loop cdbatch
491 
492         istart = iend;
493     }  // close loop over ab
494 
495     return P.nshell12_clip * Q.nshell12_clip;
496 }
497 
ostei_g_i_p_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_i_p_s)498 int ostei_g_i_p_s(struct simint_multi_shellpair const P,
499                   struct simint_multi_shellpair const Q,
500                   double screen_tol,
501                   double * const restrict work,
502                   double * const restrict INT__g_i_p_s)
503 {
504     double P_AB[3*P.nshell12];
505     struct simint_multi_shellpair P_tmp = P;
506     P_tmp.PA_x = P.PB_x;  P_tmp.PA_y = P.PB_y;  P_tmp.PA_z = P.PB_z;
507     P_tmp.PB_x = P.PA_x;  P_tmp.PB_y = P.PA_y;  P_tmp.PB_z = P.PA_z;
508     P_tmp.AB_x = P_AB;
509     P_tmp.AB_y = P_AB + P.nshell12;
510     P_tmp.AB_z = P_AB + 2*P.nshell12;
511 
512     for(int i = 0; i < P.nshell12; i++)
513     {
514         P_tmp.AB_x[i] = -P.AB_x[i];
515         P_tmp.AB_y[i] = -P.AB_y[i];
516         P_tmp.AB_z[i] = -P.AB_z[i];
517     }
518 
519     int ret = ostei_i_g_p_s(P_tmp, Q, screen_tol, work, INT__g_i_p_s);
520     double buffer[1260] SIMINT_ALIGN_ARRAY_DBL;
521 
522     for(int q = 0; q < ret; q++)
523     {
524         int idx = 0;
525         for(int a = 0; a < 15; ++a)
526         for(int b = 0; b < 28; ++b)
527         for(int c = 0; c < 3; ++c)
528         for(int d = 0; d < 1; ++d)
529             buffer[idx++] = INT__g_i_p_s[q*1260+b*45+a*3+c*1+d];
530 
531         memcpy(INT__g_i_p_s+q*1260, buffer, 1260*sizeof(double));
532     }
533 
534     return ret;
535 }
536 
ostei_i_g_s_p(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__i_g_s_p)537 int ostei_i_g_s_p(struct simint_multi_shellpair const P,
538                   struct simint_multi_shellpair const Q,
539                   double screen_tol,
540                   double * const restrict work,
541                   double * const restrict INT__i_g_s_p)
542 {
543     double Q_AB[3*Q.nshell12];
544     struct simint_multi_shellpair Q_tmp = Q;
545     Q_tmp.PA_x = Q.PB_x;  Q_tmp.PA_y = Q.PB_y;  Q_tmp.PA_z = Q.PB_z;
546     Q_tmp.PB_x = Q.PA_x;  Q_tmp.PB_y = Q.PA_y;  Q_tmp.PB_z = Q.PA_z;
547     Q_tmp.AB_x = Q_AB;
548     Q_tmp.AB_y = Q_AB + Q.nshell12;
549     Q_tmp.AB_z = Q_AB + 2*Q.nshell12;
550 
551     for(int i = 0; i < Q.nshell12; i++)
552     {
553         Q_tmp.AB_x[i] = -Q.AB_x[i];
554         Q_tmp.AB_y[i] = -Q.AB_y[i];
555         Q_tmp.AB_z[i] = -Q.AB_z[i];
556     }
557 
558     int ret = ostei_i_g_p_s(P, Q_tmp, screen_tol, work, INT__i_g_s_p);
559     double buffer[1260] SIMINT_ALIGN_ARRAY_DBL;
560 
561     for(int q = 0; q < ret; q++)
562     {
563         int idx = 0;
564         for(int a = 0; a < 28; ++a)
565         for(int b = 0; b < 15; ++b)
566         for(int c = 0; c < 1; ++c)
567         for(int d = 0; d < 3; ++d)
568             buffer[idx++] = INT__i_g_s_p[q*1260+a*45+b*3+d*1+c];
569 
570         memcpy(INT__i_g_s_p+q*1260, buffer, 1260*sizeof(double));
571     }
572 
573     return ret;
574 }
575 
ostei_g_i_s_p(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__g_i_s_p)576 int ostei_g_i_s_p(struct simint_multi_shellpair const P,
577                   struct simint_multi_shellpair const Q,
578                   double screen_tol,
579                   double * const restrict work,
580                   double * const restrict INT__g_i_s_p)
581 {
582     double P_AB[3*P.nshell12];
583     struct simint_multi_shellpair P_tmp = P;
584     P_tmp.PA_x = P.PB_x;  P_tmp.PA_y = P.PB_y;  P_tmp.PA_z = P.PB_z;
585     P_tmp.PB_x = P.PA_x;  P_tmp.PB_y = P.PA_y;  P_tmp.PB_z = P.PA_z;
586     P_tmp.AB_x = P_AB;
587     P_tmp.AB_y = P_AB + P.nshell12;
588     P_tmp.AB_z = P_AB + 2*P.nshell12;
589 
590     for(int i = 0; i < P.nshell12; i++)
591     {
592         P_tmp.AB_x[i] = -P.AB_x[i];
593         P_tmp.AB_y[i] = -P.AB_y[i];
594         P_tmp.AB_z[i] = -P.AB_z[i];
595     }
596 
597     double Q_AB[3*Q.nshell12];
598     struct simint_multi_shellpair Q_tmp = Q;
599     Q_tmp.PA_x = Q.PB_x;  Q_tmp.PA_y = Q.PB_y;  Q_tmp.PA_z = Q.PB_z;
600     Q_tmp.PB_x = Q.PA_x;  Q_tmp.PB_y = Q.PA_y;  Q_tmp.PB_z = Q.PA_z;
601     Q_tmp.AB_x = Q_AB;
602     Q_tmp.AB_y = Q_AB + Q.nshell12;
603     Q_tmp.AB_z = Q_AB + 2*Q.nshell12;
604 
605     for(int i = 0; i < Q.nshell12; i++)
606     {
607         Q_tmp.AB_x[i] = -Q.AB_x[i];
608         Q_tmp.AB_y[i] = -Q.AB_y[i];
609         Q_tmp.AB_z[i] = -Q.AB_z[i];
610     }
611 
612     int ret = ostei_i_g_p_s(P_tmp, Q_tmp, screen_tol, work, INT__g_i_s_p);
613     double buffer[1260] SIMINT_ALIGN_ARRAY_DBL;
614 
615     for(int q = 0; q < ret; q++)
616     {
617         int idx = 0;
618         for(int a = 0; a < 15; ++a)
619         for(int b = 0; b < 28; ++b)
620         for(int c = 0; c < 1; ++c)
621         for(int d = 0; d < 3; ++d)
622             buffer[idx++] = INT__g_i_s_p[q*1260+b*45+a*3+d*1+c];
623 
624         memcpy(INT__g_i_s_p+q*1260, buffer, 1260*sizeof(double));
625     }
626 
627     return ret;
628 }
629 
630