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