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