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