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