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_p_k_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_p_k_p)8 int ostei_i_p_k_p(struct simint_multi_shellpair const P,
9                   struct simint_multi_shellpair const Q,
10                   double screen_tol,
11                   double * const restrict work,
12                   double * const restrict INT__i_p_k_p)
13 {
14 
15     SIMINT_ASSUME_ALIGN_DBL(work);
16     SIMINT_ASSUME_ALIGN_DBL(INT__i_p_k_p);
17     int ab, cd, abcd;
18     int istart, jstart;
19     int iprimcd, nprim_icd, icd;
20     const int check_screen = (screen_tol > 0.0);
21     int i, j;
22     int n;
23     int not_screened;
24     int real_abcd;
25     int iket;
26     int ibra;
27 
28     // partition workspace
29     double * const INT__i_s_k_s = work + (SIMINT_NSHELL_SIMD * 0);
30     double * const INT__i_s_l_s = work + (SIMINT_NSHELL_SIMD * 1008);
31     double * const INT__k_s_k_s = work + (SIMINT_NSHELL_SIMD * 2268);
32     double * const INT__k_s_l_s = work + (SIMINT_NSHELL_SIMD * 3564);
33     SIMINT_DBLTYPE * const primwork = (SIMINT_DBLTYPE *)(work + SIMINT_NSHELL_SIMD*5184);
34     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_s = primwork + 0;
35     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_p_s = primwork + 16;
36     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_d_s = primwork + 61;
37     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_f_s = primwork + 145;
38     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_g_s = primwork + 275;
39     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_h_s = primwork + 455;
40     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_i_s = primwork + 686;
41     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_k_s = primwork + 966;
42     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_l_s = primwork + 1290;
43     SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_p_s = primwork + 1650;
44     SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_d_s = primwork + 1713;
45     SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_f_s = primwork + 1839;
46     SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_g_s = primwork + 2049;
47     SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_h_s = primwork + 2364;
48     SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_i_s = primwork + 2805;
49     SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_k_s = primwork + 3393;
50     SIMINT_DBLTYPE * const restrict PRIM_INT__p_s_l_s = primwork + 4149;
51     SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_d_s = primwork + 5094;
52     SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_f_s = primwork + 5310;
53     SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_g_s = primwork + 5670;
54     SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_h_s = primwork + 6210;
55     SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_i_s = primwork + 6966;
56     SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_k_s = primwork + 7974;
57     SIMINT_DBLTYPE * const restrict PRIM_INT__d_s_l_s = primwork + 9270;
58     SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_f_s = primwork + 10890;
59     SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_g_s = primwork + 11390;
60     SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_h_s = primwork + 12140;
61     SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_i_s = primwork + 13190;
62     SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_k_s = primwork + 14590;
63     SIMINT_DBLTYPE * const restrict PRIM_INT__f_s_l_s = primwork + 16390;
64     SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_g_s = primwork + 18640;
65     SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_h_s = primwork + 19540;
66     SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_i_s = primwork + 20800;
67     SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_k_s = primwork + 22480;
68     SIMINT_DBLTYPE * const restrict PRIM_INT__g_s_l_s = primwork + 24640;
69     SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_h_s = primwork + 27340;
70     SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_i_s = primwork + 28663;
71     SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_k_s = primwork + 30427;
72     SIMINT_DBLTYPE * const restrict PRIM_INT__h_s_l_s = primwork + 32695;
73     SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_i_s = primwork + 35530;
74     SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_k_s = primwork + 37098;
75     SIMINT_DBLTYPE * const restrict PRIM_INT__i_s_l_s = primwork + 39114;
76     SIMINT_DBLTYPE * const restrict PRIM_INT__k_s_k_s = primwork + 41634;
77     SIMINT_DBLTYPE * const restrict PRIM_INT__k_s_l_s = primwork + 42930;
78     double * const hrrwork = (double *)(primwork + 44550);
79     double * const HRR_INT__i_p_k_s = hrrwork + 0;
80     double * const HRR_INT__i_p_l_s = hrrwork + 3024;
81 
82 
83     // Create constants
84     const SIMINT_DBLTYPE const_1 = SIMINT_DBLSET1(1);
85     const SIMINT_DBLTYPE const_2 = SIMINT_DBLSET1(2);
86     const SIMINT_DBLTYPE const_3 = SIMINT_DBLSET1(3);
87     const SIMINT_DBLTYPE const_4 = SIMINT_DBLSET1(4);
88     const SIMINT_DBLTYPE const_5 = SIMINT_DBLSET1(5);
89     const SIMINT_DBLTYPE const_6 = SIMINT_DBLSET1(6);
90     const SIMINT_DBLTYPE const_7 = SIMINT_DBLSET1(7);
91     const SIMINT_DBLTYPE const_8 = SIMINT_DBLSET1(8);
92     const SIMINT_DBLTYPE one_half = SIMINT_DBLSET1(0.5);
93 
94 
95     ////////////////////////////////////////
96     // Loop over shells and primitives
97     ////////////////////////////////////////
98 
99     real_abcd = 0;
100     istart = 0;
101     for(ab = 0; ab < P.nshell12_clip; ++ab)
102     {
103         const int iend = istart + P.nprim12[ab];
104 
105         cd = 0;
106         jstart = 0;
107 
108         for(cd = 0; cd < Q.nshell12_clip; cd += SIMINT_NSHELL_SIMD)
109         {
110             const int nshellbatch = ((cd + SIMINT_NSHELL_SIMD) > Q.nshell12_clip) ? Q.nshell12_clip - cd : SIMINT_NSHELL_SIMD;
111             int jend = jstart;
112             for(i = 0; i < nshellbatch; i++)
113                 jend += Q.nprim12[cd+i];
114 
115             // Clear the beginning of the workspace (where we are accumulating integrals)
116             memset(work, 0, SIMINT_NSHELL_SIMD * 5184 * sizeof(double));
117             abcd = 0;
118 
119 
120             for(i = istart; i < iend; ++i)
121             {
122                 SIMINT_DBLTYPE bra_screen_max;  // only used if check_screen
123 
124                 if(check_screen)
125                 {
126                     // Skip this whole thing if always insignificant
127                     if((P.screen[i] * Q.screen_max) < screen_tol)
128                         continue;
129                     bra_screen_max = SIMINT_DBLSET1(P.screen[i]);
130                 }
131 
132                 icd = 0;
133                 iprimcd = 0;
134                 nprim_icd = Q.nprim12[cd];
135                 double * restrict PRIM_PTR_INT__i_s_k_s = INT__i_s_k_s + abcd * 1008;
136                 double * restrict PRIM_PTR_INT__i_s_l_s = INT__i_s_l_s + abcd * 1260;
137                 double * restrict PRIM_PTR_INT__k_s_k_s = INT__k_s_k_s + abcd * 1296;
138                 double * restrict PRIM_PTR_INT__k_s_l_s = INT__k_s_l_s + abcd * 1620;
139 
140 
141 
142                 // Load these one per loop over i
143                 const SIMINT_DBLTYPE P_alpha = SIMINT_DBLSET1(P.alpha[i]);
144                 const SIMINT_DBLTYPE P_prefac = SIMINT_DBLSET1(P.prefac[i]);
145                 const SIMINT_DBLTYPE Pxyz[3] = { SIMINT_DBLSET1(P.x[i]), SIMINT_DBLSET1(P.y[i]), SIMINT_DBLSET1(P.z[i]) };
146 
147                 const SIMINT_DBLTYPE P_PA[3] = { SIMINT_DBLSET1(P.PA_x[i]), SIMINT_DBLSET1(P.PA_y[i]), SIMINT_DBLSET1(P.PA_z[i]) };
148 
149                 for(j = jstart; j < jend; j += SIMINT_SIMD_LEN)
150                 {
151                     // calculate the shell offsets
152                     // these are the offset from the shell pointed to by cd
153                     // for each element
154                     int shelloffsets[SIMINT_SIMD_LEN] = {0};
155                     int lastoffset = 0;
156                     const int nlane = ( ((j + SIMINT_SIMD_LEN) < jend) ? SIMINT_SIMD_LEN : (jend - j));
157 
158                     if((iprimcd + SIMINT_SIMD_LEN) >= nprim_icd)
159                     {
160                         // Handle if the first element of the vector is a new shell
161                         if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
162                         {
163                             nprim_icd += Q.nprim12[cd + (++icd)];
164                             PRIM_PTR_INT__i_s_k_s += 1008;
165                             PRIM_PTR_INT__i_s_l_s += 1260;
166                             PRIM_PTR_INT__k_s_k_s += 1296;
167                             PRIM_PTR_INT__k_s_l_s += 1620;
168                         }
169                         iprimcd++;
170                         for(n = 1; n < SIMINT_SIMD_LEN; ++n)
171                         {
172                             if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
173                             {
174                                 shelloffsets[n] = shelloffsets[n-1] + 1;
175                                 lastoffset++;
176                                 nprim_icd += Q.nprim12[cd + (++icd)];
177                             }
178                             else
179                                 shelloffsets[n] = shelloffsets[n-1];
180                             iprimcd++;
181                         }
182                     }
183                     else
184                         iprimcd += SIMINT_SIMD_LEN;
185 
186                     // Do we have to compute this vector (or has it been screened out)?
187                     // (not_screened != 0 means we have to do this vector)
188                     if(check_screen)
189                     {
190                         const double vmax = vector_max(SIMINT_MUL(bra_screen_max, SIMINT_DBLLOAD(Q.screen, j)));
191                         if(vmax < screen_tol)
192                         {
193                             PRIM_PTR_INT__i_s_k_s += lastoffset*1008;
194                             PRIM_PTR_INT__i_s_l_s += lastoffset*1260;
195                             PRIM_PTR_INT__k_s_k_s += lastoffset*1296;
196                             PRIM_PTR_INT__k_s_l_s += lastoffset*1620;
197                             continue;
198                         }
199                     }
200 
201                     const SIMINT_DBLTYPE Q_alpha = SIMINT_DBLLOAD(Q.alpha, j);
202                     const SIMINT_DBLTYPE PQalpha_mul = SIMINT_MUL(P_alpha, Q_alpha);
203                     const SIMINT_DBLTYPE PQalpha_sum = SIMINT_ADD(P_alpha, Q_alpha);
204                     const SIMINT_DBLTYPE one_over_PQalpha_sum = SIMINT_DIV(const_1, PQalpha_sum);
205 
206 
207                     /* construct R2 = (Px - Qx)**2 + (Py - Qy)**2 + (Pz -Qz)**2 */
208                     SIMINT_DBLTYPE PQ[3];
209                     PQ[0] = SIMINT_SUB(Pxyz[0], SIMINT_DBLLOAD(Q.x, j));
210                     PQ[1] = SIMINT_SUB(Pxyz[1], SIMINT_DBLLOAD(Q.y, j));
211                     PQ[2] = SIMINT_SUB(Pxyz[2], SIMINT_DBLLOAD(Q.z, j));
212                     SIMINT_DBLTYPE R2 = SIMINT_MUL(PQ[0], PQ[0]);
213                     R2 = SIMINT_FMADD(PQ[1], PQ[1], R2);
214                     R2 = SIMINT_FMADD(PQ[2], PQ[2], R2);
215 
216                     const SIMINT_DBLTYPE alpha = SIMINT_MUL(PQalpha_mul, one_over_PQalpha_sum); // alpha from MEST
217                     const SIMINT_DBLTYPE one_over_p = SIMINT_DIV(const_1, P_alpha);
218                     const SIMINT_DBLTYPE one_over_q = SIMINT_DIV(const_1, Q_alpha);
219                     const SIMINT_DBLTYPE one_over_2p = SIMINT_MUL(one_half, one_over_p);
220                     const SIMINT_DBLTYPE one_over_2q = SIMINT_MUL(one_half, one_over_q);
221                     const SIMINT_DBLTYPE one_over_2pq = SIMINT_MUL(one_half, one_over_PQalpha_sum);
222                     const SIMINT_DBLTYPE Q_PA[3] = { SIMINT_DBLLOAD(Q.PA_x, j), SIMINT_DBLLOAD(Q.PA_y, j), SIMINT_DBLLOAD(Q.PA_z, j) };
223 
224                     // NOTE: Minus sign!
225                     const SIMINT_DBLTYPE a_over_p = SIMINT_MUL(SIMINT_NEG(alpha), one_over_p);
226                     SIMINT_DBLTYPE aop_PQ[3];
227                     aop_PQ[0] = SIMINT_MUL(a_over_p, PQ[0]);
228                     aop_PQ[1] = SIMINT_MUL(a_over_p, PQ[1]);
229                     aop_PQ[2] = SIMINT_MUL(a_over_p, PQ[2]);
230 
231                     SIMINT_DBLTYPE a_over_q = SIMINT_MUL(alpha, one_over_q);
232                     SIMINT_DBLTYPE aoq_PQ[3];
233                     aoq_PQ[0] = SIMINT_MUL(a_over_q, PQ[0]);
234                     aoq_PQ[1] = SIMINT_MUL(a_over_q, PQ[1]);
235                     aoq_PQ[2] = SIMINT_MUL(a_over_q, PQ[2]);
236                     // Put a minus sign here so we don't have to in RR routines
237                     a_over_q = SIMINT_NEG(a_over_q);
238 
239 
240                     //////////////////////////////////////////////
241                     // Fjt function section
242                     // Maximum v value: 15
243                     //////////////////////////////////////////////
244                     // The parameter to the Fjt function
245                     const SIMINT_DBLTYPE F_x = SIMINT_MUL(R2, alpha);
246 
247 
248                     const SIMINT_DBLTYPE Q_prefac = mask_load(nlane, Q.prefac + j);
249 
250 
251                     boys_F_split(PRIM_INT__s_s_s_s, F_x, 15);
252                     SIMINT_DBLTYPE prefac = SIMINT_SQRT(one_over_PQalpha_sum);
253                     prefac = SIMINT_MUL(SIMINT_MUL(P_prefac, Q_prefac), prefac);
254                     for(n = 0; n <= 15; n++)
255                         PRIM_INT__s_s_s_s[n] = SIMINT_MUL(PRIM_INT__s_s_s_s[n], prefac);
256 
257                     //////////////////////////////////////////////
258                     // Primitive integrals: Vertical recurrance
259                     //////////////////////////////////////////////
260 
261                     const SIMINT_DBLTYPE vrr_const_1_over_2p = one_over_2p;
262                     const SIMINT_DBLTYPE vrr_const_2_over_2p = SIMINT_MUL(const_2, one_over_2p);
263                     const SIMINT_DBLTYPE vrr_const_3_over_2p = SIMINT_MUL(const_3, one_over_2p);
264                     const SIMINT_DBLTYPE vrr_const_4_over_2p = SIMINT_MUL(const_4, one_over_2p);
265                     const SIMINT_DBLTYPE vrr_const_5_over_2p = SIMINT_MUL(const_5, one_over_2p);
266                     const SIMINT_DBLTYPE vrr_const_6_over_2p = SIMINT_MUL(const_6, one_over_2p);
267                     const SIMINT_DBLTYPE vrr_const_1_over_2q = one_over_2q;
268                     const SIMINT_DBLTYPE vrr_const_2_over_2q = SIMINT_MUL(const_2, one_over_2q);
269                     const SIMINT_DBLTYPE vrr_const_3_over_2q = SIMINT_MUL(const_3, one_over_2q);
270                     const SIMINT_DBLTYPE vrr_const_4_over_2q = SIMINT_MUL(const_4, one_over_2q);
271                     const SIMINT_DBLTYPE vrr_const_5_over_2q = SIMINT_MUL(const_5, one_over_2q);
272                     const SIMINT_DBLTYPE vrr_const_6_over_2q = SIMINT_MUL(const_6, one_over_2q);
273                     const SIMINT_DBLTYPE vrr_const_7_over_2q = SIMINT_MUL(const_7, one_over_2q);
274                     const SIMINT_DBLTYPE vrr_const_1_over_2pq = one_over_2pq;
275                     const SIMINT_DBLTYPE vrr_const_2_over_2pq = SIMINT_MUL(const_2, one_over_2pq);
276                     const SIMINT_DBLTYPE vrr_const_3_over_2pq = SIMINT_MUL(const_3, one_over_2pq);
277                     const SIMINT_DBLTYPE vrr_const_4_over_2pq = SIMINT_MUL(const_4, one_over_2pq);
278                     const SIMINT_DBLTYPE vrr_const_5_over_2pq = SIMINT_MUL(const_5, one_over_2pq);
279                     const SIMINT_DBLTYPE vrr_const_6_over_2pq = SIMINT_MUL(const_6, one_over_2pq);
280                     const SIMINT_DBLTYPE vrr_const_7_over_2pq = SIMINT_MUL(const_7, one_over_2pq);
281                     const SIMINT_DBLTYPE vrr_const_8_over_2pq = SIMINT_MUL(const_8, one_over_2pq);
282 
283 
284 
285                     // Forming PRIM_INT__s_s_p_s[15 * 3];
286                     for(n = 0; n < 15; ++n)  // loop over orders of auxiliary function
287                     {
288 
289                         PRIM_INT__s_s_p_s[n * 3 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
290                         PRIM_INT__s_s_p_s[n * 3 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_p_s[n * 3 + 0]);
291 
292                         PRIM_INT__s_s_p_s[n * 3 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
293                         PRIM_INT__s_s_p_s[n * 3 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_p_s[n * 3 + 1]);
294 
295                         PRIM_INT__s_s_p_s[n * 3 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
296                         PRIM_INT__s_s_p_s[n * 3 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_p_s[n * 3 + 2]);
297 
298                     }
299 
300 
301 
302                     // Forming PRIM_INT__s_s_d_s[14 * 6];
303                     for(n = 0; n < 14; ++n)  // loop over orders of auxiliary function
304                     {
305 
306                         PRIM_INT__s_s_d_s[n * 6 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_p_s[n * 3 + 0]);
307                         PRIM_INT__s_s_d_s[n * 6 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_s_d_s[n * 6 + 0]);
308                         PRIM_INT__s_s_d_s[n * 6 + 0] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_s_d_s[n * 6 + 0]);
309 
310                         PRIM_INT__s_s_d_s[n * 6 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_p_s[n * 3 + 0]);
311                         PRIM_INT__s_s_d_s[n * 6 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_s_d_s[n * 6 + 1]);
312 
313                         PRIM_INT__s_s_d_s[n * 6 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_p_s[n * 3 + 0]);
314                         PRIM_INT__s_s_d_s[n * 6 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_s_d_s[n * 6 + 2]);
315 
316                         PRIM_INT__s_s_d_s[n * 6 + 3] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_p_s[n * 3 + 1]);
317                         PRIM_INT__s_s_d_s[n * 6 + 3] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_s_d_s[n * 6 + 3]);
318                         PRIM_INT__s_s_d_s[n * 6 + 3] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_s_d_s[n * 6 + 3]);
319 
320                         PRIM_INT__s_s_d_s[n * 6 + 4] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_p_s[n * 3 + 1]);
321                         PRIM_INT__s_s_d_s[n * 6 + 4] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_s_d_s[n * 6 + 4]);
322 
323                         PRIM_INT__s_s_d_s[n * 6 + 5] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_p_s[n * 3 + 2]);
324                         PRIM_INT__s_s_d_s[n * 6 + 5] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__s_s_d_s[n * 6 + 5]);
325                         PRIM_INT__s_s_d_s[n * 6 + 5] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_s_d_s[n * 6 + 5]);
326 
327                     }
328 
329 
330 
331                     // Forming PRIM_INT__s_s_f_s[13 * 10];
332                     for(n = 0; n < 13; ++n)  // loop over orders of auxiliary function
333                     {
334 
335                         PRIM_INT__s_s_f_s[n * 10 + 0] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_d_s[n * 6 + 0]);
336                         PRIM_INT__s_s_f_s[n * 10 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__s_s_f_s[n * 10 + 0]);
337                         PRIM_INT__s_s_f_s[n * 10 + 0] = SIMINT_FMADD( vrr_const_2_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__s_s_p_s[n * 3 + 0]), PRIM_INT__s_s_f_s[n * 10 + 0]);
338 
339                         PRIM_INT__s_s_f_s[n * 10 + 1] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 0]);
340                         PRIM_INT__s_s_f_s[n * 10 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__s_s_f_s[n * 10 + 1]);
341 
342                         PRIM_INT__s_s_f_s[n * 10 + 2] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 0]);
343                         PRIM_INT__s_s_f_s[n * 10 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__s_s_f_s[n * 10 + 2]);
344 
345                         PRIM_INT__s_s_f_s[n * 10 + 3] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_d_s[n * 6 + 3]);
346                         PRIM_INT__s_s_f_s[n * 10 + 3] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__s_s_f_s[n * 10 + 3]);
347 
348                         PRIM_INT__s_s_f_s[n * 10 + 4] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 1]);
349                         PRIM_INT__s_s_f_s[n * 10 + 4] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 1], PRIM_INT__s_s_f_s[n * 10 + 4]);
350 
351                         PRIM_INT__s_s_f_s[n * 10 + 5] = SIMINT_MUL(Q_PA[0], PRIM_INT__s_s_d_s[n * 6 + 5]);
352                         PRIM_INT__s_s_f_s[n * 10 + 5] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__s_s_f_s[n * 10 + 5]);
353 
354                         PRIM_INT__s_s_f_s[n * 10 + 6] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 3]);
355                         PRIM_INT__s_s_f_s[n * 10 + 6] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__s_s_f_s[n * 10 + 6]);
356                         PRIM_INT__s_s_f_s[n * 10 + 6] = SIMINT_FMADD( vrr_const_2_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__s_s_p_s[n * 3 + 1]), PRIM_INT__s_s_f_s[n * 10 + 6]);
357 
358                         PRIM_INT__s_s_f_s[n * 10 + 7] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 3]);
359                         PRIM_INT__s_s_f_s[n * 10 + 7] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__s_s_f_s[n * 10 + 7]);
360 
361                         PRIM_INT__s_s_f_s[n * 10 + 8] = SIMINT_MUL(Q_PA[1], PRIM_INT__s_s_d_s[n * 6 + 5]);
362                         PRIM_INT__s_s_f_s[n * 10 + 8] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__s_s_f_s[n * 10 + 8]);
363 
364                         PRIM_INT__s_s_f_s[n * 10 + 9] = SIMINT_MUL(Q_PA[2], PRIM_INT__s_s_d_s[n * 6 + 5]);
365                         PRIM_INT__s_s_f_s[n * 10 + 9] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__s_s_f_s[n * 10 + 9]);
366                         PRIM_INT__s_s_f_s[n * 10 + 9] = SIMINT_FMADD( vrr_const_2_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__s_s_p_s[n * 3 + 2]), PRIM_INT__s_s_f_s[n * 10 + 9]);
367 
368                     }
369 
370 
371                     VRR_K_s_s_g_s(
372                             PRIM_INT__s_s_g_s,
373                             PRIM_INT__s_s_f_s,
374                             PRIM_INT__s_s_d_s,
375                             Q_PA,
376                             a_over_q,
377                             aoq_PQ,
378                             one_over_2q,
379                             12);
380 
381 
382                     VRR_K_s_s_h_s(
383                             PRIM_INT__s_s_h_s,
384                             PRIM_INT__s_s_g_s,
385                             PRIM_INT__s_s_f_s,
386                             Q_PA,
387                             a_over_q,
388                             aoq_PQ,
389                             one_over_2q,
390                             11);
391 
392 
393                     ostei_general_vrr1_K(6, 10,
394                             one_over_2q, a_over_q, aoq_PQ, Q_PA,
395                             PRIM_INT__s_s_h_s, PRIM_INT__s_s_g_s, PRIM_INT__s_s_i_s);
396 
397 
398                     ostei_general_vrr1_K(7, 9,
399                             one_over_2q, a_over_q, aoq_PQ, Q_PA,
400                             PRIM_INT__s_s_i_s, PRIM_INT__s_s_h_s, PRIM_INT__s_s_k_s);
401 
402 
403                     ostei_general_vrr_I(1, 0, 7, 0, 7,
404                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
405                             PRIM_INT__s_s_k_s, NULL, NULL, PRIM_INT__s_s_i_s, NULL, PRIM_INT__p_s_k_s);
406 
407 
408                     ostei_general_vrr_I(1, 0, 6, 0, 7,
409                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
410                             PRIM_INT__s_s_i_s, NULL, NULL, PRIM_INT__s_s_h_s, NULL, PRIM_INT__p_s_i_s);
411 
412 
413                     ostei_general_vrr_I(2, 0, 7, 0, 6,
414                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
415                             PRIM_INT__p_s_k_s, PRIM_INT__s_s_k_s, NULL, PRIM_INT__p_s_i_s, NULL, PRIM_INT__d_s_k_s);
416 
417 
418                     ostei_general_vrr_I(1, 0, 5, 0, 7,
419                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
420                             PRIM_INT__s_s_h_s, NULL, NULL, PRIM_INT__s_s_g_s, NULL, PRIM_INT__p_s_h_s);
421 
422 
423                     ostei_general_vrr_I(2, 0, 6, 0, 6,
424                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
425                             PRIM_INT__p_s_i_s, PRIM_INT__s_s_i_s, NULL, PRIM_INT__p_s_h_s, NULL, PRIM_INT__d_s_i_s);
426 
427 
428                     ostei_general_vrr_I(3, 0, 7, 0, 5,
429                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
430                             PRIM_INT__d_s_k_s, PRIM_INT__p_s_k_s, NULL, PRIM_INT__d_s_i_s, NULL, PRIM_INT__f_s_k_s);
431 
432 
433                     VRR_I_p_s_g_s(
434                             PRIM_INT__p_s_g_s,
435                             PRIM_INT__s_s_g_s,
436                             PRIM_INT__s_s_f_s,
437                             P_PA,
438                             aop_PQ,
439                             one_over_2pq,
440                             7);
441 
442 
443                     ostei_general_vrr_I(2, 0, 5, 0, 6,
444                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
445                             PRIM_INT__p_s_h_s, PRIM_INT__s_s_h_s, NULL, PRIM_INT__p_s_g_s, NULL, PRIM_INT__d_s_h_s);
446 
447 
448                     ostei_general_vrr_I(3, 0, 6, 0, 5,
449                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
450                             PRIM_INT__d_s_i_s, PRIM_INT__p_s_i_s, NULL, PRIM_INT__d_s_h_s, NULL, PRIM_INT__f_s_i_s);
451 
452 
453                     ostei_general_vrr_I(4, 0, 7, 0, 4,
454                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
455                             PRIM_INT__f_s_k_s, PRIM_INT__d_s_k_s, NULL, PRIM_INT__f_s_i_s, NULL, PRIM_INT__g_s_k_s);
456 
457 
458                     VRR_I_p_s_f_s(
459                             PRIM_INT__p_s_f_s,
460                             PRIM_INT__s_s_f_s,
461                             PRIM_INT__s_s_d_s,
462                             P_PA,
463                             aop_PQ,
464                             one_over_2pq,
465                             7);
466 
467 
468                     ostei_general_vrr_I(2, 0, 4, 0, 6,
469                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
470                             PRIM_INT__p_s_g_s, PRIM_INT__s_s_g_s, NULL, PRIM_INT__p_s_f_s, NULL, PRIM_INT__d_s_g_s);
471 
472 
473                     ostei_general_vrr_I(3, 0, 5, 0, 5,
474                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
475                             PRIM_INT__d_s_h_s, PRIM_INT__p_s_h_s, NULL, PRIM_INT__d_s_g_s, NULL, PRIM_INT__f_s_h_s);
476 
477 
478                     ostei_general_vrr_I(4, 0, 6, 0, 4,
479                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
480                             PRIM_INT__f_s_i_s, PRIM_INT__d_s_i_s, NULL, PRIM_INT__f_s_h_s, NULL, PRIM_INT__g_s_i_s);
481 
482 
483                     ostei_general_vrr_I(5, 0, 7, 0, 3,
484                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
485                             PRIM_INT__g_s_k_s, PRIM_INT__f_s_k_s, NULL, PRIM_INT__g_s_i_s, NULL, PRIM_INT__h_s_k_s);
486 
487 
488 
489                     // Forming PRIM_INT__p_s_d_s[7 * 18];
490                     for(n = 0; n < 7; ++n)  // loop over orders of auxiliary function
491                     {
492 
493                         PRIM_INT__p_s_d_s[n * 18 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_d_s[n * 6 + 0]);
494                         PRIM_INT__p_s_d_s[n * 18 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__p_s_d_s[n * 18 + 0]);
495                         PRIM_INT__p_s_d_s[n * 18 + 0] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__p_s_d_s[n * 18 + 0]);
496 
497                         PRIM_INT__p_s_d_s[n * 18 + 1] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_d_s[n * 6 + 1]);
498                         PRIM_INT__p_s_d_s[n * 18 + 1] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 1], PRIM_INT__p_s_d_s[n * 18 + 1]);
499                         PRIM_INT__p_s_d_s[n * 18 + 1] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__p_s_d_s[n * 18 + 1]);
500 
501                         PRIM_INT__p_s_d_s[n * 18 + 2] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_d_s[n * 6 + 2]);
502                         PRIM_INT__p_s_d_s[n * 18 + 2] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 2], PRIM_INT__p_s_d_s[n * 18 + 2]);
503                         PRIM_INT__p_s_d_s[n * 18 + 2] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__p_s_d_s[n * 18 + 2]);
504 
505                         PRIM_INT__p_s_d_s[n * 18 + 3] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_d_s[n * 6 + 3]);
506                         PRIM_INT__p_s_d_s[n * 18 + 3] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__p_s_d_s[n * 18 + 3]);
507 
508                         PRIM_INT__p_s_d_s[n * 18 + 4] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_d_s[n * 6 + 4]);
509                         PRIM_INT__p_s_d_s[n * 18 + 4] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 4], PRIM_INT__p_s_d_s[n * 18 + 4]);
510 
511                         PRIM_INT__p_s_d_s[n * 18 + 5] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_d_s[n * 6 + 5]);
512                         PRIM_INT__p_s_d_s[n * 18 + 5] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__p_s_d_s[n * 18 + 5]);
513 
514                         PRIM_INT__p_s_d_s[n * 18 + 6] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_d_s[n * 6 + 0]);
515                         PRIM_INT__p_s_d_s[n * 18 + 6] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__p_s_d_s[n * 18 + 6]);
516 
517                         PRIM_INT__p_s_d_s[n * 18 + 7] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_d_s[n * 6 + 1]);
518                         PRIM_INT__p_s_d_s[n * 18 + 7] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 1], PRIM_INT__p_s_d_s[n * 18 + 7]);
519                         PRIM_INT__p_s_d_s[n * 18 + 7] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__p_s_d_s[n * 18 + 7]);
520 
521                         PRIM_INT__p_s_d_s[n * 18 + 8] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_d_s[n * 6 + 2]);
522                         PRIM_INT__p_s_d_s[n * 18 + 8] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 2], PRIM_INT__p_s_d_s[n * 18 + 8]);
523 
524                         PRIM_INT__p_s_d_s[n * 18 + 9] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_d_s[n * 6 + 3]);
525                         PRIM_INT__p_s_d_s[n * 18 + 9] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__p_s_d_s[n * 18 + 9]);
526                         PRIM_INT__p_s_d_s[n * 18 + 9] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__p_s_d_s[n * 18 + 9]);
527 
528                         PRIM_INT__p_s_d_s[n * 18 + 10] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_d_s[n * 6 + 4]);
529                         PRIM_INT__p_s_d_s[n * 18 + 10] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 4], PRIM_INT__p_s_d_s[n * 18 + 10]);
530                         PRIM_INT__p_s_d_s[n * 18 + 10] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__p_s_d_s[n * 18 + 10]);
531 
532                         PRIM_INT__p_s_d_s[n * 18 + 11] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_d_s[n * 6 + 5]);
533                         PRIM_INT__p_s_d_s[n * 18 + 11] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__p_s_d_s[n * 18 + 11]);
534 
535                         PRIM_INT__p_s_d_s[n * 18 + 12] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_d_s[n * 6 + 0]);
536                         PRIM_INT__p_s_d_s[n * 18 + 12] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 0], PRIM_INT__p_s_d_s[n * 18 + 12]);
537 
538                         PRIM_INT__p_s_d_s[n * 18 + 13] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_d_s[n * 6 + 1]);
539                         PRIM_INT__p_s_d_s[n * 18 + 13] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 1], PRIM_INT__p_s_d_s[n * 18 + 13]);
540 
541                         PRIM_INT__p_s_d_s[n * 18 + 14] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_d_s[n * 6 + 2]);
542                         PRIM_INT__p_s_d_s[n * 18 + 14] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 2], PRIM_INT__p_s_d_s[n * 18 + 14]);
543                         PRIM_INT__p_s_d_s[n * 18 + 14] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__p_s_d_s[n * 18 + 14]);
544 
545                         PRIM_INT__p_s_d_s[n * 18 + 15] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_d_s[n * 6 + 3]);
546                         PRIM_INT__p_s_d_s[n * 18 + 15] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 3], PRIM_INT__p_s_d_s[n * 18 + 15]);
547 
548                         PRIM_INT__p_s_d_s[n * 18 + 16] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_d_s[n * 6 + 4]);
549                         PRIM_INT__p_s_d_s[n * 18 + 16] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 4], PRIM_INT__p_s_d_s[n * 18 + 16]);
550                         PRIM_INT__p_s_d_s[n * 18 + 16] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__p_s_d_s[n * 18 + 16]);
551 
552                         PRIM_INT__p_s_d_s[n * 18 + 17] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_d_s[n * 6 + 5]);
553                         PRIM_INT__p_s_d_s[n * 18 + 17] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_d_s[(n+1) * 6 + 5], PRIM_INT__p_s_d_s[n * 18 + 17]);
554                         PRIM_INT__p_s_d_s[n * 18 + 17] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__p_s_d_s[n * 18 + 17]);
555 
556                     }
557 
558 
559                     VRR_I_d_s_f_s(
560                             PRIM_INT__d_s_f_s,
561                             PRIM_INT__p_s_f_s,
562                             PRIM_INT__s_s_f_s,
563                             PRIM_INT__p_s_d_s,
564                             P_PA,
565                             a_over_p,
566                             aop_PQ,
567                             one_over_2p,
568                             one_over_2pq,
569                             6);
570 
571 
572                     ostei_general_vrr_I(3, 0, 4, 0, 5,
573                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
574                             PRIM_INT__d_s_g_s, PRIM_INT__p_s_g_s, NULL, PRIM_INT__d_s_f_s, NULL, PRIM_INT__f_s_g_s);
575 
576 
577                     ostei_general_vrr_I(4, 0, 5, 0, 4,
578                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
579                             PRIM_INT__f_s_h_s, PRIM_INT__d_s_h_s, NULL, PRIM_INT__f_s_g_s, NULL, PRIM_INT__g_s_h_s);
580 
581 
582                     ostei_general_vrr_I(5, 0, 6, 0, 3,
583                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
584                             PRIM_INT__g_s_i_s, PRIM_INT__f_s_i_s, NULL, PRIM_INT__g_s_h_s, NULL, PRIM_INT__h_s_i_s);
585 
586 
587                     ostei_general_vrr_I(6, 0, 7, 0, 2,
588                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
589                             PRIM_INT__h_s_k_s, PRIM_INT__g_s_k_s, NULL, PRIM_INT__h_s_i_s, NULL, PRIM_INT__i_s_k_s);
590 
591 
592                     ostei_general_vrr1_K(8, 8,
593                             one_over_2q, a_over_q, aoq_PQ, Q_PA,
594                             PRIM_INT__s_s_k_s, PRIM_INT__s_s_i_s, PRIM_INT__s_s_l_s);
595 
596 
597                     ostei_general_vrr_I(1, 0, 8, 0, 7,
598                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
599                             PRIM_INT__s_s_l_s, NULL, NULL, PRIM_INT__s_s_k_s, NULL, PRIM_INT__p_s_l_s);
600 
601 
602                     ostei_general_vrr_I(2, 0, 8, 0, 6,
603                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
604                             PRIM_INT__p_s_l_s, PRIM_INT__s_s_l_s, NULL, PRIM_INT__p_s_k_s, NULL, PRIM_INT__d_s_l_s);
605 
606 
607                     ostei_general_vrr_I(3, 0, 8, 0, 5,
608                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
609                             PRIM_INT__d_s_l_s, PRIM_INT__p_s_l_s, NULL, PRIM_INT__d_s_k_s, NULL, PRIM_INT__f_s_l_s);
610 
611 
612                     ostei_general_vrr_I(4, 0, 8, 0, 4,
613                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
614                             PRIM_INT__f_s_l_s, PRIM_INT__d_s_l_s, NULL, PRIM_INT__f_s_k_s, NULL, PRIM_INT__g_s_l_s);
615 
616 
617                     ostei_general_vrr_I(5, 0, 8, 0, 3,
618                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
619                             PRIM_INT__g_s_l_s, PRIM_INT__f_s_l_s, NULL, PRIM_INT__g_s_k_s, NULL, PRIM_INT__h_s_l_s);
620 
621 
622                     ostei_general_vrr_I(6, 0, 8, 0, 2,
623                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
624                             PRIM_INT__h_s_l_s, PRIM_INT__g_s_l_s, NULL, PRIM_INT__h_s_k_s, NULL, PRIM_INT__i_s_l_s);
625 
626 
627 
628                     // Forming PRIM_INT__p_s_p_s[7 * 9];
629                     for(n = 0; n < 7; ++n)  // loop over orders of auxiliary function
630                     {
631 
632                         PRIM_INT__p_s_p_s[n * 9 + 0] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_p_s[n * 3 + 0]);
633                         PRIM_INT__p_s_p_s[n * 9 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__p_s_p_s[n * 9 + 0]);
634                         PRIM_INT__p_s_p_s[n * 9 + 0] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_p_s[n * 9 + 0]);
635 
636                         PRIM_INT__p_s_p_s[n * 9 + 1] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_p_s[n * 3 + 1]);
637                         PRIM_INT__p_s_p_s[n * 9 + 1] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__p_s_p_s[n * 9 + 1]);
638 
639                         PRIM_INT__p_s_p_s[n * 9 + 2] = SIMINT_MUL(P_PA[0], PRIM_INT__s_s_p_s[n * 3 + 2]);
640                         PRIM_INT__p_s_p_s[n * 9 + 2] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__p_s_p_s[n * 9 + 2]);
641 
642                         PRIM_INT__p_s_p_s[n * 9 + 3] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_p_s[n * 3 + 0]);
643                         PRIM_INT__p_s_p_s[n * 9 + 3] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__p_s_p_s[n * 9 + 3]);
644 
645                         PRIM_INT__p_s_p_s[n * 9 + 4] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_p_s[n * 3 + 1]);
646                         PRIM_INT__p_s_p_s[n * 9 + 4] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__p_s_p_s[n * 9 + 4]);
647                         PRIM_INT__p_s_p_s[n * 9 + 4] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_p_s[n * 9 + 4]);
648 
649                         PRIM_INT__p_s_p_s[n * 9 + 5] = SIMINT_MUL(P_PA[1], PRIM_INT__s_s_p_s[n * 3 + 2]);
650                         PRIM_INT__p_s_p_s[n * 9 + 5] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__p_s_p_s[n * 9 + 5]);
651 
652                         PRIM_INT__p_s_p_s[n * 9 + 6] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_p_s[n * 3 + 0]);
653                         PRIM_INT__p_s_p_s[n * 9 + 6] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 0], PRIM_INT__p_s_p_s[n * 9 + 6]);
654 
655                         PRIM_INT__p_s_p_s[n * 9 + 7] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_p_s[n * 3 + 1]);
656                         PRIM_INT__p_s_p_s[n * 9 + 7] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 1], PRIM_INT__p_s_p_s[n * 9 + 7]);
657 
658                         PRIM_INT__p_s_p_s[n * 9 + 8] = SIMINT_MUL(P_PA[2], PRIM_INT__s_s_p_s[n * 3 + 2]);
659                         PRIM_INT__p_s_p_s[n * 9 + 8] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_p_s[(n+1) * 3 + 2], PRIM_INT__p_s_p_s[n * 9 + 8]);
660                         PRIM_INT__p_s_p_s[n * 9 + 8] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__p_s_p_s[n * 9 + 8]);
661 
662                     }
663 
664 
665                     VRR_I_d_s_d_s(
666                             PRIM_INT__d_s_d_s,
667                             PRIM_INT__p_s_d_s,
668                             PRIM_INT__s_s_d_s,
669                             PRIM_INT__p_s_p_s,
670                             P_PA,
671                             a_over_p,
672                             aop_PQ,
673                             one_over_2p,
674                             one_over_2pq,
675                             6);
676 
677 
678                     ostei_general_vrr_I(3, 0, 3, 0, 5,
679                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
680                             PRIM_INT__d_s_f_s, PRIM_INT__p_s_f_s, NULL, PRIM_INT__d_s_d_s, NULL, PRIM_INT__f_s_f_s);
681 
682 
683                     ostei_general_vrr_I(4, 0, 4, 0, 4,
684                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
685                             PRIM_INT__f_s_g_s, PRIM_INT__d_s_g_s, NULL, PRIM_INT__f_s_f_s, NULL, PRIM_INT__g_s_g_s);
686 
687 
688                     ostei_general_vrr_I(5, 0, 5, 0, 3,
689                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
690                             PRIM_INT__g_s_h_s, PRIM_INT__f_s_h_s, NULL, PRIM_INT__g_s_g_s, NULL, PRIM_INT__h_s_h_s);
691 
692 
693                     ostei_general_vrr_I(6, 0, 6, 0, 2,
694                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
695                             PRIM_INT__h_s_i_s, PRIM_INT__g_s_i_s, NULL, PRIM_INT__h_s_h_s, NULL, PRIM_INT__i_s_i_s);
696 
697 
698                     ostei_general_vrr_I(7, 0, 7, 0, 1,
699                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
700                             PRIM_INT__i_s_k_s, PRIM_INT__h_s_k_s, NULL, PRIM_INT__i_s_i_s, NULL, PRIM_INT__k_s_k_s);
701 
702 
703                     ostei_general_vrr_I(7, 0, 8, 0, 1,
704                             one_over_2p, a_over_p, one_over_2pq, aop_PQ, P_PA,
705                             PRIM_INT__i_s_l_s, PRIM_INT__h_s_l_s, NULL, PRIM_INT__i_s_k_s, NULL, PRIM_INT__k_s_l_s);
706 
707 
708 
709 
710                     ////////////////////////////////////
711                     // Accumulate contracted integrals
712                     ////////////////////////////////////
713                     if(lastoffset == 0)
714                     {
715                         contract_all(1008, PRIM_INT__i_s_k_s, PRIM_PTR_INT__i_s_k_s);
716                         contract_all(1260, PRIM_INT__i_s_l_s, PRIM_PTR_INT__i_s_l_s);
717                         contract_all(1296, PRIM_INT__k_s_k_s, PRIM_PTR_INT__k_s_k_s);
718                         contract_all(1620, PRIM_INT__k_s_l_s, PRIM_PTR_INT__k_s_l_s);
719                     }
720                     else
721                     {
722                         contract(1008, shelloffsets, PRIM_INT__i_s_k_s, PRIM_PTR_INT__i_s_k_s);
723                         contract(1260, shelloffsets, PRIM_INT__i_s_l_s, PRIM_PTR_INT__i_s_l_s);
724                         contract(1296, shelloffsets, PRIM_INT__k_s_k_s, PRIM_PTR_INT__k_s_k_s);
725                         contract(1620, shelloffsets, PRIM_INT__k_s_l_s, PRIM_PTR_INT__k_s_l_s);
726                         PRIM_PTR_INT__i_s_k_s += lastoffset*1008;
727                         PRIM_PTR_INT__i_s_l_s += lastoffset*1260;
728                         PRIM_PTR_INT__k_s_k_s += lastoffset*1296;
729                         PRIM_PTR_INT__k_s_l_s += lastoffset*1620;
730                     }
731 
732                 }  // close loop over j
733             }  // close loop over i
734 
735             //Advance to the next batch
736             jstart = SIMINT_SIMD_ROUND(jend);
737 
738             //////////////////////////////////////////////
739             // Contracted integrals: Horizontal recurrance
740             //////////////////////////////////////////////
741 
742 
743             const double hAB[3] = { P.AB_x[ab], P.AB_y[ab], P.AB_z[ab] };
744 
745 
746             for(abcd = 0; abcd < nshellbatch; ++abcd, ++real_abcd)
747             {
748                 const double hCD[3] = { Q.AB_x[cd+abcd], Q.AB_y[cd+abcd], Q.AB_z[cd+abcd] };
749 
750                 // set up HRR pointers
751                 double const * restrict HRR_INT__i_s_k_s = INT__i_s_k_s + abcd * 1008;
752                 double const * restrict HRR_INT__i_s_l_s = INT__i_s_l_s + abcd * 1260;
753                 double const * restrict HRR_INT__k_s_k_s = INT__k_s_k_s + abcd * 1296;
754                 double const * restrict HRR_INT__k_s_l_s = INT__k_s_l_s + abcd * 1620;
755                 double * restrict HRR_INT__i_p_k_p = INT__i_p_k_p + real_abcd * 9072;
756 
757                 // form INT__i_p_k_s
758                 ostei_general_hrr_J(6, 1, 7, 0, hAB, HRR_INT__k_s_k_s, HRR_INT__i_s_k_s, HRR_INT__i_p_k_s);
759 
760                 // form INT__i_p_l_s
761                 ostei_general_hrr_J(6, 1, 8, 0, hAB, HRR_INT__k_s_l_s, HRR_INT__i_s_l_s, HRR_INT__i_p_l_s);
762 
763                 // form INT__i_p_k_p
764                 ostei_general_hrr_L(6, 1, 7, 1, hCD, HRR_INT__i_p_l_s, HRR_INT__i_p_k_s, HRR_INT__i_p_k_p);
765 
766 
767             }  // close HRR loop
768 
769 
770         }   // close loop cdbatch
771 
772         istart = iend;
773     }  // close loop over ab
774 
775     return P.nshell12_clip * Q.nshell12_clip;
776 }
777 
ostei_p_i_k_p(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__p_i_k_p)778 int ostei_p_i_k_p(struct simint_multi_shellpair const P,
779                   struct simint_multi_shellpair const Q,
780                   double screen_tol,
781                   double * const restrict work,
782                   double * const restrict INT__p_i_k_p)
783 {
784     double P_AB[3*P.nshell12];
785     struct simint_multi_shellpair P_tmp = P;
786     P_tmp.PA_x = P.PB_x;  P_tmp.PA_y = P.PB_y;  P_tmp.PA_z = P.PB_z;
787     P_tmp.PB_x = P.PA_x;  P_tmp.PB_y = P.PA_y;  P_tmp.PB_z = P.PA_z;
788     P_tmp.AB_x = P_AB;
789     P_tmp.AB_y = P_AB + P.nshell12;
790     P_tmp.AB_z = P_AB + 2*P.nshell12;
791 
792     for(int i = 0; i < P.nshell12; i++)
793     {
794         P_tmp.AB_x[i] = -P.AB_x[i];
795         P_tmp.AB_y[i] = -P.AB_y[i];
796         P_tmp.AB_z[i] = -P.AB_z[i];
797     }
798 
799     int ret = ostei_i_p_k_p(P_tmp, Q, screen_tol, work, INT__p_i_k_p);
800     double buffer[9072] SIMINT_ALIGN_ARRAY_DBL;
801 
802     for(int q = 0; q < ret; q++)
803     {
804         int idx = 0;
805         for(int a = 0; a < 3; ++a)
806         for(int b = 0; b < 28; ++b)
807         for(int c = 0; c < 36; ++c)
808         for(int d = 0; d < 3; ++d)
809             buffer[idx++] = INT__p_i_k_p[q*9072+b*324+a*108+c*3+d];
810 
811         memcpy(INT__p_i_k_p+q*9072, buffer, 9072*sizeof(double));
812     }
813 
814     return ret;
815 }
816 
ostei_i_p_p_k(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__i_p_p_k)817 int ostei_i_p_p_k(struct simint_multi_shellpair const P,
818                   struct simint_multi_shellpair const Q,
819                   double screen_tol,
820                   double * const restrict work,
821                   double * const restrict INT__i_p_p_k)
822 {
823     double Q_AB[3*Q.nshell12];
824     struct simint_multi_shellpair Q_tmp = Q;
825     Q_tmp.PA_x = Q.PB_x;  Q_tmp.PA_y = Q.PB_y;  Q_tmp.PA_z = Q.PB_z;
826     Q_tmp.PB_x = Q.PA_x;  Q_tmp.PB_y = Q.PA_y;  Q_tmp.PB_z = Q.PA_z;
827     Q_tmp.AB_x = Q_AB;
828     Q_tmp.AB_y = Q_AB + Q.nshell12;
829     Q_tmp.AB_z = Q_AB + 2*Q.nshell12;
830 
831     for(int i = 0; i < Q.nshell12; i++)
832     {
833         Q_tmp.AB_x[i] = -Q.AB_x[i];
834         Q_tmp.AB_y[i] = -Q.AB_y[i];
835         Q_tmp.AB_z[i] = -Q.AB_z[i];
836     }
837 
838     int ret = ostei_i_p_k_p(P, Q_tmp, screen_tol, work, INT__i_p_p_k);
839     double buffer[9072] SIMINT_ALIGN_ARRAY_DBL;
840 
841     for(int q = 0; q < ret; q++)
842     {
843         int idx = 0;
844         for(int a = 0; a < 28; ++a)
845         for(int b = 0; b < 3; ++b)
846         for(int c = 0; c < 3; ++c)
847         for(int d = 0; d < 36; ++d)
848             buffer[idx++] = INT__i_p_p_k[q*9072+a*324+b*108+d*3+c];
849 
850         memcpy(INT__i_p_p_k+q*9072, buffer, 9072*sizeof(double));
851     }
852 
853     return ret;
854 }
855 
ostei_p_i_p_k(struct simint_multi_shellpair const P,struct simint_multi_shellpair const Q,double screen_tol,double * const restrict work,double * const restrict INT__p_i_p_k)856 int ostei_p_i_p_k(struct simint_multi_shellpair const P,
857                   struct simint_multi_shellpair const Q,
858                   double screen_tol,
859                   double * const restrict work,
860                   double * const restrict INT__p_i_p_k)
861 {
862     double P_AB[3*P.nshell12];
863     struct simint_multi_shellpair P_tmp = P;
864     P_tmp.PA_x = P.PB_x;  P_tmp.PA_y = P.PB_y;  P_tmp.PA_z = P.PB_z;
865     P_tmp.PB_x = P.PA_x;  P_tmp.PB_y = P.PA_y;  P_tmp.PB_z = P.PA_z;
866     P_tmp.AB_x = P_AB;
867     P_tmp.AB_y = P_AB + P.nshell12;
868     P_tmp.AB_z = P_AB + 2*P.nshell12;
869 
870     for(int i = 0; i < P.nshell12; i++)
871     {
872         P_tmp.AB_x[i] = -P.AB_x[i];
873         P_tmp.AB_y[i] = -P.AB_y[i];
874         P_tmp.AB_z[i] = -P.AB_z[i];
875     }
876 
877     double Q_AB[3*Q.nshell12];
878     struct simint_multi_shellpair Q_tmp = Q;
879     Q_tmp.PA_x = Q.PB_x;  Q_tmp.PA_y = Q.PB_y;  Q_tmp.PA_z = Q.PB_z;
880     Q_tmp.PB_x = Q.PA_x;  Q_tmp.PB_y = Q.PA_y;  Q_tmp.PB_z = Q.PA_z;
881     Q_tmp.AB_x = Q_AB;
882     Q_tmp.AB_y = Q_AB + Q.nshell12;
883     Q_tmp.AB_z = Q_AB + 2*Q.nshell12;
884 
885     for(int i = 0; i < Q.nshell12; i++)
886     {
887         Q_tmp.AB_x[i] = -Q.AB_x[i];
888         Q_tmp.AB_y[i] = -Q.AB_y[i];
889         Q_tmp.AB_z[i] = -Q.AB_z[i];
890     }
891 
892     int ret = ostei_i_p_k_p(P_tmp, Q_tmp, screen_tol, work, INT__p_i_p_k);
893     double buffer[9072] SIMINT_ALIGN_ARRAY_DBL;
894 
895     for(int q = 0; q < ret; q++)
896     {
897         int idx = 0;
898         for(int a = 0; a < 3; ++a)
899         for(int b = 0; b < 28; ++b)
900         for(int c = 0; c < 3; ++c)
901         for(int d = 0; d < 36; ++d)
902             buffer[idx++] = INT__p_i_p_k[q*9072+b*324+a*108+d*3+c];
903 
904         memcpy(INT__p_i_p_k+q*9072, buffer, 9072*sizeof(double));
905     }
906 
907     return ret;
908 }
909 
910