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