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