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_p_d_p_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_d_p_d)8 int ostei_p_d_p_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__p_d_p_d)
13 {
14 
15     SIMINT_ASSUME_ALIGN_DBL(work);
16     SIMINT_ASSUME_ALIGN_DBL(INT__p_d_p_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__s_d_s_d = work + (SIMINT_NSHELL_SIMD * 0);
30     double * const INT__s_d_s_f = work + (SIMINT_NSHELL_SIMD * 36);
31     double * const INT__s_f_s_d = work + (SIMINT_NSHELL_SIMD * 96);
32     double * const INT__s_f_s_f = work + (SIMINT_NSHELL_SIMD * 156);
33     SIMINT_DBLTYPE * const primwork = (SIMINT_DBLTYPE *)(work + SIMINT_NSHELL_SIMD*256);
34     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_s = primwork + 0;
35     SIMINT_DBLTYPE * const restrict PRIM_INT__s_s_s_p = primwork + 7;
36     SIMINT_DBLTYPE * const restrict PRIM_INT__s_p_s_s = primwork + 16;
37     SIMINT_DBLTYPE * const restrict PRIM_INT__s_p_s_p = primwork + 34;
38     SIMINT_DBLTYPE * const restrict PRIM_INT__s_p_s_d = primwork + 61;
39     SIMINT_DBLTYPE * const restrict PRIM_INT__s_d_s_s = primwork + 97;
40     SIMINT_DBLTYPE * const restrict PRIM_INT__s_d_s_p = primwork + 127;
41     SIMINT_DBLTYPE * const restrict PRIM_INT__s_d_s_d = primwork + 181;
42     SIMINT_DBLTYPE * const restrict PRIM_INT__s_d_s_f = primwork + 253;
43     SIMINT_DBLTYPE * const restrict PRIM_INT__s_f_s_s = primwork + 313;
44     SIMINT_DBLTYPE * const restrict PRIM_INT__s_f_s_p = primwork + 353;
45     SIMINT_DBLTYPE * const restrict PRIM_INT__s_f_s_d = primwork + 443;
46     SIMINT_DBLTYPE * const restrict PRIM_INT__s_f_s_f = primwork + 563;
47     double * const hrrwork = (double *)(primwork + 663);
48     double * const HRR_INT__p_d_s_d = hrrwork + 0;
49     double * const HRR_INT__p_d_s_f = hrrwork + 108;
50 
51 
52     // Create constants
53     const SIMINT_DBLTYPE const_1 = SIMINT_DBLSET1(1);
54     const SIMINT_DBLTYPE const_2 = SIMINT_DBLSET1(2);
55     const SIMINT_DBLTYPE const_3 = SIMINT_DBLSET1(3);
56     const SIMINT_DBLTYPE one_half = SIMINT_DBLSET1(0.5);
57 
58 
59     ////////////////////////////////////////
60     // Loop over shells and primitives
61     ////////////////////////////////////////
62 
63     real_abcd = 0;
64     istart = 0;
65     for(ab = 0; ab < P.nshell12_clip; ++ab)
66     {
67         const int iend = istart + P.nprim12[ab];
68 
69         cd = 0;
70         jstart = 0;
71 
72         for(cd = 0; cd < Q.nshell12_clip; cd += SIMINT_NSHELL_SIMD)
73         {
74             const int nshellbatch = ((cd + SIMINT_NSHELL_SIMD) > Q.nshell12_clip) ? Q.nshell12_clip - cd : SIMINT_NSHELL_SIMD;
75             int jend = jstart;
76             for(i = 0; i < nshellbatch; i++)
77                 jend += Q.nprim12[cd+i];
78 
79             // Clear the beginning of the workspace (where we are accumulating integrals)
80             memset(work, 0, SIMINT_NSHELL_SIMD * 256 * sizeof(double));
81             abcd = 0;
82 
83 
84             for(i = istart; i < iend; ++i)
85             {
86                 SIMINT_DBLTYPE bra_screen_max;  // only used if check_screen
87 
88                 if(check_screen)
89                 {
90                     // Skip this whole thing if always insignificant
91                     if((P.screen[i] * Q.screen_max) < screen_tol)
92                         continue;
93                     bra_screen_max = SIMINT_DBLSET1(P.screen[i]);
94                 }
95 
96                 icd = 0;
97                 iprimcd = 0;
98                 nprim_icd = Q.nprim12[cd];
99                 double * restrict PRIM_PTR_INT__s_d_s_d = INT__s_d_s_d + abcd * 36;
100                 double * restrict PRIM_PTR_INT__s_d_s_f = INT__s_d_s_f + abcd * 60;
101                 double * restrict PRIM_PTR_INT__s_f_s_d = INT__s_f_s_d + abcd * 60;
102                 double * restrict PRIM_PTR_INT__s_f_s_f = INT__s_f_s_f + abcd * 100;
103 
104 
105 
106                 // Load these one per loop over i
107                 const SIMINT_DBLTYPE P_alpha = SIMINT_DBLSET1(P.alpha[i]);
108                 const SIMINT_DBLTYPE P_prefac = SIMINT_DBLSET1(P.prefac[i]);
109                 const SIMINT_DBLTYPE Pxyz[3] = { SIMINT_DBLSET1(P.x[i]), SIMINT_DBLSET1(P.y[i]), SIMINT_DBLSET1(P.z[i]) };
110 
111                 const SIMINT_DBLTYPE P_PB[3] = { SIMINT_DBLSET1(P.PB_x[i]), SIMINT_DBLSET1(P.PB_y[i]), SIMINT_DBLSET1(P.PB_z[i]) };
112 
113                 for(j = jstart; j < jend; j += SIMINT_SIMD_LEN)
114                 {
115                     // calculate the shell offsets
116                     // these are the offset from the shell pointed to by cd
117                     // for each element
118                     int shelloffsets[SIMINT_SIMD_LEN] = {0};
119                     int lastoffset = 0;
120                     const int nlane = ( ((j + SIMINT_SIMD_LEN) < jend) ? SIMINT_SIMD_LEN : (jend - j));
121 
122                     if((iprimcd + SIMINT_SIMD_LEN) >= nprim_icd)
123                     {
124                         // Handle if the first element of the vector is a new shell
125                         if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
126                         {
127                             nprim_icd += Q.nprim12[cd + (++icd)];
128                             PRIM_PTR_INT__s_d_s_d += 36;
129                             PRIM_PTR_INT__s_d_s_f += 60;
130                             PRIM_PTR_INT__s_f_s_d += 60;
131                             PRIM_PTR_INT__s_f_s_f += 100;
132                         }
133                         iprimcd++;
134                         for(n = 1; n < SIMINT_SIMD_LEN; ++n)
135                         {
136                             if(iprimcd >= nprim_icd && ((icd+1) < nshellbatch))
137                             {
138                                 shelloffsets[n] = shelloffsets[n-1] + 1;
139                                 lastoffset++;
140                                 nprim_icd += Q.nprim12[cd + (++icd)];
141                             }
142                             else
143                                 shelloffsets[n] = shelloffsets[n-1];
144                             iprimcd++;
145                         }
146                     }
147                     else
148                         iprimcd += SIMINT_SIMD_LEN;
149 
150                     // Do we have to compute this vector (or has it been screened out)?
151                     // (not_screened != 0 means we have to do this vector)
152                     if(check_screen)
153                     {
154                         const double vmax = vector_max(SIMINT_MUL(bra_screen_max, SIMINT_DBLLOAD(Q.screen, j)));
155                         if(vmax < screen_tol)
156                         {
157                             PRIM_PTR_INT__s_d_s_d += lastoffset*36;
158                             PRIM_PTR_INT__s_d_s_f += lastoffset*60;
159                             PRIM_PTR_INT__s_f_s_d += lastoffset*60;
160                             PRIM_PTR_INT__s_f_s_f += lastoffset*100;
161                             continue;
162                         }
163                     }
164 
165                     const SIMINT_DBLTYPE Q_alpha = SIMINT_DBLLOAD(Q.alpha, j);
166                     const SIMINT_DBLTYPE PQalpha_mul = SIMINT_MUL(P_alpha, Q_alpha);
167                     const SIMINT_DBLTYPE PQalpha_sum = SIMINT_ADD(P_alpha, Q_alpha);
168                     const SIMINT_DBLTYPE one_over_PQalpha_sum = SIMINT_DIV(const_1, PQalpha_sum);
169 
170 
171                     /* construct R2 = (Px - Qx)**2 + (Py - Qy)**2 + (Pz -Qz)**2 */
172                     SIMINT_DBLTYPE PQ[3];
173                     PQ[0] = SIMINT_SUB(Pxyz[0], SIMINT_DBLLOAD(Q.x, j));
174                     PQ[1] = SIMINT_SUB(Pxyz[1], SIMINT_DBLLOAD(Q.y, j));
175                     PQ[2] = SIMINT_SUB(Pxyz[2], SIMINT_DBLLOAD(Q.z, j));
176                     SIMINT_DBLTYPE R2 = SIMINT_MUL(PQ[0], PQ[0]);
177                     R2 = SIMINT_FMADD(PQ[1], PQ[1], R2);
178                     R2 = SIMINT_FMADD(PQ[2], PQ[2], R2);
179 
180                     const SIMINT_DBLTYPE alpha = SIMINT_MUL(PQalpha_mul, one_over_PQalpha_sum); // alpha from MEST
181                     const SIMINT_DBLTYPE one_over_p = SIMINT_DIV(const_1, P_alpha);
182                     const SIMINT_DBLTYPE one_over_q = SIMINT_DIV(const_1, Q_alpha);
183                     const SIMINT_DBLTYPE one_over_2p = SIMINT_MUL(one_half, one_over_p);
184                     const SIMINT_DBLTYPE one_over_2q = SIMINT_MUL(one_half, one_over_q);
185                     const SIMINT_DBLTYPE one_over_2pq = SIMINT_MUL(one_half, one_over_PQalpha_sum);
186                     const SIMINT_DBLTYPE Q_PB[3] = { SIMINT_DBLLOAD(Q.PB_x, j), SIMINT_DBLLOAD(Q.PB_y, j), SIMINT_DBLLOAD(Q.PB_z, j) };
187 
188                     // NOTE: Minus sign!
189                     const SIMINT_DBLTYPE a_over_p = SIMINT_MUL(SIMINT_NEG(alpha), one_over_p);
190                     SIMINT_DBLTYPE aop_PQ[3];
191                     aop_PQ[0] = SIMINT_MUL(a_over_p, PQ[0]);
192                     aop_PQ[1] = SIMINT_MUL(a_over_p, PQ[1]);
193                     aop_PQ[2] = SIMINT_MUL(a_over_p, PQ[2]);
194 
195                     SIMINT_DBLTYPE a_over_q = SIMINT_MUL(alpha, one_over_q);
196                     SIMINT_DBLTYPE aoq_PQ[3];
197                     aoq_PQ[0] = SIMINT_MUL(a_over_q, PQ[0]);
198                     aoq_PQ[1] = SIMINT_MUL(a_over_q, PQ[1]);
199                     aoq_PQ[2] = SIMINT_MUL(a_over_q, PQ[2]);
200                     // Put a minus sign here so we don't have to in RR routines
201                     a_over_q = SIMINT_NEG(a_over_q);
202 
203 
204                     //////////////////////////////////////////////
205                     // Fjt function section
206                     // Maximum v value: 6
207                     //////////////////////////////////////////////
208                     // The parameter to the Fjt function
209                     const SIMINT_DBLTYPE F_x = SIMINT_MUL(R2, alpha);
210 
211 
212                     const SIMINT_DBLTYPE Q_prefac = mask_load(nlane, Q.prefac + j);
213 
214 
215                     boys_F_split(PRIM_INT__s_s_s_s, F_x, 6);
216                     SIMINT_DBLTYPE prefac = SIMINT_SQRT(one_over_PQalpha_sum);
217                     prefac = SIMINT_MUL(SIMINT_MUL(P_prefac, Q_prefac), prefac);
218                     for(n = 0; n <= 6; n++)
219                         PRIM_INT__s_s_s_s[n] = SIMINT_MUL(PRIM_INT__s_s_s_s[n], prefac);
220 
221                     //////////////////////////////////////////////
222                     // Primitive integrals: Vertical recurrance
223                     //////////////////////////////////////////////
224 
225                     const SIMINT_DBLTYPE vrr_const_1_over_2p = one_over_2p;
226                     const SIMINT_DBLTYPE vrr_const_2_over_2p = SIMINT_MUL(const_2, one_over_2p);
227                     const SIMINT_DBLTYPE vrr_const_1_over_2q = one_over_2q;
228                     const SIMINT_DBLTYPE vrr_const_2_over_2q = SIMINT_MUL(const_2, one_over_2q);
229                     const SIMINT_DBLTYPE vrr_const_1_over_2pq = one_over_2pq;
230                     const SIMINT_DBLTYPE vrr_const_2_over_2pq = SIMINT_MUL(const_2, one_over_2pq);
231                     const SIMINT_DBLTYPE vrr_const_3_over_2pq = SIMINT_MUL(const_3, one_over_2pq);
232 
233 
234 
235                     // Forming PRIM_INT__s_p_s_s[6 * 3];
236                     for(n = 0; n < 6; ++n)  // loop over orders of auxiliary function
237                     {
238 
239                         PRIM_INT__s_p_s_s[n * 3 + 0] = SIMINT_MUL(P_PB[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
240                         PRIM_INT__s_p_s_s[n * 3 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_p_s_s[n * 3 + 0]);
241 
242                         PRIM_INT__s_p_s_s[n * 3 + 1] = SIMINT_MUL(P_PB[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
243                         PRIM_INT__s_p_s_s[n * 3 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_p_s_s[n * 3 + 1]);
244 
245                         PRIM_INT__s_p_s_s[n * 3 + 2] = SIMINT_MUL(P_PB[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
246                         PRIM_INT__s_p_s_s[n * 3 + 2] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_p_s_s[n * 3 + 2]);
247 
248                     }
249 
250 
251 
252                     // Forming PRIM_INT__s_d_s_s[5 * 6];
253                     for(n = 0; n < 5; ++n)  // loop over orders of auxiliary function
254                     {
255 
256                         PRIM_INT__s_d_s_s[n * 6 + 0] = SIMINT_MUL(P_PB[0], PRIM_INT__s_p_s_s[n * 3 + 0]);
257                         PRIM_INT__s_d_s_s[n * 6 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_d_s_s[n * 6 + 0]);
258                         PRIM_INT__s_d_s_s[n * 6 + 0] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_d_s_s[n * 6 + 0]);
259 
260                         PRIM_INT__s_d_s_s[n * 6 + 1] = SIMINT_MUL(P_PB[1], PRIM_INT__s_p_s_s[n * 3 + 0]);
261                         PRIM_INT__s_d_s_s[n * 6 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_d_s_s[n * 6 + 1]);
262 
263                         PRIM_INT__s_d_s_s[n * 6 + 2] = SIMINT_MUL(P_PB[2], PRIM_INT__s_p_s_s[n * 3 + 0]);
264                         PRIM_INT__s_d_s_s[n * 6 + 2] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_d_s_s[n * 6 + 2]);
265 
266                         PRIM_INT__s_d_s_s[n * 6 + 3] = SIMINT_MUL(P_PB[1], PRIM_INT__s_p_s_s[n * 3 + 1]);
267                         PRIM_INT__s_d_s_s[n * 6 + 3] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_d_s_s[n * 6 + 3]);
268                         PRIM_INT__s_d_s_s[n * 6 + 3] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_d_s_s[n * 6 + 3]);
269 
270                         PRIM_INT__s_d_s_s[n * 6 + 4] = SIMINT_MUL(P_PB[2], PRIM_INT__s_p_s_s[n * 3 + 1]);
271                         PRIM_INT__s_d_s_s[n * 6 + 4] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_d_s_s[n * 6 + 4]);
272 
273                         PRIM_INT__s_d_s_s[n * 6 + 5] = SIMINT_MUL(P_PB[2], PRIM_INT__s_p_s_s[n * 3 + 2]);
274                         PRIM_INT__s_d_s_s[n * 6 + 5] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_p_s_s[(n+1) * 3 + 2], PRIM_INT__s_d_s_s[n * 6 + 5]);
275                         PRIM_INT__s_d_s_s[n * 6 + 5] = SIMINT_FMADD( vrr_const_1_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_s[n * 1 + 0]), PRIM_INT__s_d_s_s[n * 6 + 5]);
276 
277                     }
278 
279 
280 
281                     // Forming PRIM_INT__s_d_s_p[3 * 18];
282                     for(n = 0; n < 3; ++n)  // loop over orders of auxiliary function
283                     {
284 
285                         PRIM_INT__s_d_s_p[n * 18 + 0] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_d_s_s[n * 6 + 0]);
286                         PRIM_INT__s_d_s_p[n * 18 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_d_s_s[(n+1) * 6 + 0], PRIM_INT__s_d_s_p[n * 18 + 0]);
287                         PRIM_INT__s_d_s_p[n * 18 + 0] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_d_s_p[n * 18 + 0]);
288 
289                         PRIM_INT__s_d_s_p[n * 18 + 1] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_d_s_s[n * 6 + 0]);
290                         PRIM_INT__s_d_s_p[n * 18 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_d_s_s[(n+1) * 6 + 0], PRIM_INT__s_d_s_p[n * 18 + 1]);
291 
292                         PRIM_INT__s_d_s_p[n * 18 + 2] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_d_s_s[n * 6 + 0]);
293                         PRIM_INT__s_d_s_p[n * 18 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 0], PRIM_INT__s_d_s_p[n * 18 + 2]);
294 
295                         PRIM_INT__s_d_s_p[n * 18 + 3] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_d_s_s[n * 6 + 1]);
296                         PRIM_INT__s_d_s_p[n * 18 + 3] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_d_s_s[(n+1) * 6 + 1], PRIM_INT__s_d_s_p[n * 18 + 3]);
297                         PRIM_INT__s_d_s_p[n * 18 + 3] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_d_s_p[n * 18 + 3]);
298 
299                         PRIM_INT__s_d_s_p[n * 18 + 4] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_d_s_s[n * 6 + 1]);
300                         PRIM_INT__s_d_s_p[n * 18 + 4] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_d_s_s[(n+1) * 6 + 1], PRIM_INT__s_d_s_p[n * 18 + 4]);
301                         PRIM_INT__s_d_s_p[n * 18 + 4] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_d_s_p[n * 18 + 4]);
302 
303                         PRIM_INT__s_d_s_p[n * 18 + 5] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_d_s_s[n * 6 + 1]);
304                         PRIM_INT__s_d_s_p[n * 18 + 5] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 1], PRIM_INT__s_d_s_p[n * 18 + 5]);
305 
306                         PRIM_INT__s_d_s_p[n * 18 + 6] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_d_s_s[n * 6 + 2]);
307                         PRIM_INT__s_d_s_p[n * 18 + 6] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_d_s_s[(n+1) * 6 + 2], PRIM_INT__s_d_s_p[n * 18 + 6]);
308                         PRIM_INT__s_d_s_p[n * 18 + 6] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_p_s_s[(n+1) * 3 + 2], PRIM_INT__s_d_s_p[n * 18 + 6]);
309 
310                         PRIM_INT__s_d_s_p[n * 18 + 7] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_d_s_s[n * 6 + 2]);
311                         PRIM_INT__s_d_s_p[n * 18 + 7] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_d_s_s[(n+1) * 6 + 2], PRIM_INT__s_d_s_p[n * 18 + 7]);
312 
313                         PRIM_INT__s_d_s_p[n * 18 + 8] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_d_s_s[n * 6 + 2]);
314                         PRIM_INT__s_d_s_p[n * 18 + 8] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 2], PRIM_INT__s_d_s_p[n * 18 + 8]);
315                         PRIM_INT__s_d_s_p[n * 18 + 8] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_d_s_p[n * 18 + 8]);
316 
317                         PRIM_INT__s_d_s_p[n * 18 + 9] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_d_s_s[n * 6 + 3]);
318                         PRIM_INT__s_d_s_p[n * 18 + 9] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_d_s_s[(n+1) * 6 + 3], PRIM_INT__s_d_s_p[n * 18 + 9]);
319 
320                         PRIM_INT__s_d_s_p[n * 18 + 10] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_d_s_s[n * 6 + 3]);
321                         PRIM_INT__s_d_s_p[n * 18 + 10] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_d_s_s[(n+1) * 6 + 3], PRIM_INT__s_d_s_p[n * 18 + 10]);
322                         PRIM_INT__s_d_s_p[n * 18 + 10] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_d_s_p[n * 18 + 10]);
323 
324                         PRIM_INT__s_d_s_p[n * 18 + 11] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_d_s_s[n * 6 + 3]);
325                         PRIM_INT__s_d_s_p[n * 18 + 11] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 3], PRIM_INT__s_d_s_p[n * 18 + 11]);
326 
327                         PRIM_INT__s_d_s_p[n * 18 + 12] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_d_s_s[n * 6 + 4]);
328                         PRIM_INT__s_d_s_p[n * 18 + 12] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_d_s_s[(n+1) * 6 + 4], PRIM_INT__s_d_s_p[n * 18 + 12]);
329 
330                         PRIM_INT__s_d_s_p[n * 18 + 13] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_d_s_s[n * 6 + 4]);
331                         PRIM_INT__s_d_s_p[n * 18 + 13] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_d_s_s[(n+1) * 6 + 4], PRIM_INT__s_d_s_p[n * 18 + 13]);
332                         PRIM_INT__s_d_s_p[n * 18 + 13] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_p_s_s[(n+1) * 3 + 2], PRIM_INT__s_d_s_p[n * 18 + 13]);
333 
334                         PRIM_INT__s_d_s_p[n * 18 + 14] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_d_s_s[n * 6 + 4]);
335                         PRIM_INT__s_d_s_p[n * 18 + 14] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 4], PRIM_INT__s_d_s_p[n * 18 + 14]);
336                         PRIM_INT__s_d_s_p[n * 18 + 14] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_d_s_p[n * 18 + 14]);
337 
338                         PRIM_INT__s_d_s_p[n * 18 + 15] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_d_s_s[n * 6 + 5]);
339                         PRIM_INT__s_d_s_p[n * 18 + 15] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_d_s_s[(n+1) * 6 + 5], PRIM_INT__s_d_s_p[n * 18 + 15]);
340 
341                         PRIM_INT__s_d_s_p[n * 18 + 16] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_d_s_s[n * 6 + 5]);
342                         PRIM_INT__s_d_s_p[n * 18 + 16] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_d_s_s[(n+1) * 6 + 5], PRIM_INT__s_d_s_p[n * 18 + 16]);
343 
344                         PRIM_INT__s_d_s_p[n * 18 + 17] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_d_s_s[n * 6 + 5]);
345                         PRIM_INT__s_d_s_p[n * 18 + 17] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 5], PRIM_INT__s_d_s_p[n * 18 + 17]);
346                         PRIM_INT__s_d_s_p[n * 18 + 17] = SIMINT_FMADD( vrr_const_2_over_2pq, PRIM_INT__s_p_s_s[(n+1) * 3 + 2], PRIM_INT__s_d_s_p[n * 18 + 17]);
347 
348                     }
349 
350 
351 
352                     // Forming PRIM_INT__s_p_s_p[3 * 9];
353                     for(n = 0; n < 3; ++n)  // loop over orders of auxiliary function
354                     {
355 
356                         PRIM_INT__s_p_s_p[n * 9 + 0] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_p_s_s[n * 3 + 0]);
357                         PRIM_INT__s_p_s_p[n * 9 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_p_s_p[n * 9 + 0]);
358                         PRIM_INT__s_p_s_p[n * 9 + 0] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_p_s_p[n * 9 + 0]);
359 
360                         PRIM_INT__s_p_s_p[n * 9 + 1] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_p_s_s[n * 3 + 0]);
361                         PRIM_INT__s_p_s_p[n * 9 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_p_s_p[n * 9 + 1]);
362 
363                         PRIM_INT__s_p_s_p[n * 9 + 2] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_p_s_s[n * 3 + 0]);
364                         PRIM_INT__s_p_s_p[n * 9 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_p_s_p[n * 9 + 2]);
365 
366                         PRIM_INT__s_p_s_p[n * 9 + 3] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_p_s_s[n * 3 + 1]);
367                         PRIM_INT__s_p_s_p[n * 9 + 3] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_p_s_p[n * 9 + 3]);
368 
369                         PRIM_INT__s_p_s_p[n * 9 + 4] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_p_s_s[n * 3 + 1]);
370                         PRIM_INT__s_p_s_p[n * 9 + 4] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_p_s_p[n * 9 + 4]);
371                         PRIM_INT__s_p_s_p[n * 9 + 4] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_p_s_p[n * 9 + 4]);
372 
373                         PRIM_INT__s_p_s_p[n * 9 + 5] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_p_s_s[n * 3 + 1]);
374                         PRIM_INT__s_p_s_p[n * 9 + 5] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_p_s_p[n * 9 + 5]);
375 
376                         PRIM_INT__s_p_s_p[n * 9 + 6] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_p_s_s[n * 3 + 2]);
377                         PRIM_INT__s_p_s_p[n * 9 + 6] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_p_s_s[(n+1) * 3 + 2], PRIM_INT__s_p_s_p[n * 9 + 6]);
378 
379                         PRIM_INT__s_p_s_p[n * 9 + 7] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_p_s_s[n * 3 + 2]);
380                         PRIM_INT__s_p_s_p[n * 9 + 7] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_p_s_s[(n+1) * 3 + 2], PRIM_INT__s_p_s_p[n * 9 + 7]);
381 
382                         PRIM_INT__s_p_s_p[n * 9 + 8] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_p_s_s[n * 3 + 2]);
383                         PRIM_INT__s_p_s_p[n * 9 + 8] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_p_s_s[(n+1) * 3 + 2], PRIM_INT__s_p_s_p[n * 9 + 8]);
384                         PRIM_INT__s_p_s_p[n * 9 + 8] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_p_s_p[n * 9 + 8]);
385 
386                     }
387 
388 
389                     VRR_L_s_d_s_d(
390                             PRIM_INT__s_d_s_d,
391                             PRIM_INT__s_d_s_p,
392                             PRIM_INT__s_d_s_s,
393                             PRIM_INT__s_p_s_p,
394                             Q_PB,
395                             a_over_q,
396                             aoq_PQ,
397                             one_over_2pq,
398                             one_over_2q,
399                             2);
400 
401 
402 
403                     // Forming PRIM_INT__s_s_s_p[3 * 3];
404                     for(n = 0; n < 3; ++n)  // loop over orders of auxiliary function
405                     {
406 
407                         PRIM_INT__s_s_s_p[n * 3 + 0] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_s_s_s[n * 1 + 0]);
408                         PRIM_INT__s_s_s_p[n * 3 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_p[n * 3 + 0]);
409 
410                         PRIM_INT__s_s_s_p[n * 3 + 1] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_s_s_s[n * 1 + 0]);
411                         PRIM_INT__s_s_s_p[n * 3 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_p[n * 3 + 1]);
412 
413                         PRIM_INT__s_s_s_p[n * 3 + 2] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_s_s_s[n * 1 + 0]);
414                         PRIM_INT__s_s_s_p[n * 3 + 2] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_s_s_s[(n+1) * 1 + 0], PRIM_INT__s_s_s_p[n * 3 + 2]);
415 
416                     }
417 
418 
419 
420                     // Forming PRIM_INT__s_p_s_d[2 * 18];
421                     for(n = 0; n < 2; ++n)  // loop over orders of auxiliary function
422                     {
423 
424                         PRIM_INT__s_p_s_d[n * 18 + 0] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_p_s_p[n * 9 + 0]);
425                         PRIM_INT__s_p_s_d[n * 18 + 0] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_p_s_p[(n+1) * 9 + 0], PRIM_INT__s_p_s_d[n * 18 + 0]);
426                         PRIM_INT__s_p_s_d[n * 18 + 0] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_p_s_s[n * 3 + 0]), PRIM_INT__s_p_s_d[n * 18 + 0]);
427                         PRIM_INT__s_p_s_d[n * 18 + 0] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_p[(n+1) * 3 + 0], PRIM_INT__s_p_s_d[n * 18 + 0]);
428 
429                         PRIM_INT__s_p_s_d[n * 18 + 1] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_p_s_p[n * 9 + 0]);
430                         PRIM_INT__s_p_s_d[n * 18 + 1] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_p_s_p[(n+1) * 9 + 0], PRIM_INT__s_p_s_d[n * 18 + 1]);
431 
432                         PRIM_INT__s_p_s_d[n * 18 + 3] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_p_s_p[n * 9 + 1]);
433                         PRIM_INT__s_p_s_d[n * 18 + 3] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_p_s_p[(n+1) * 9 + 1], PRIM_INT__s_p_s_d[n * 18 + 3]);
434                         PRIM_INT__s_p_s_d[n * 18 + 3] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_p_s_s[n * 3 + 0]), PRIM_INT__s_p_s_d[n * 18 + 3]);
435 
436                         PRIM_INT__s_p_s_d[n * 18 + 5] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_p_s_p[n * 9 + 2]);
437                         PRIM_INT__s_p_s_d[n * 18 + 5] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_p_s_p[(n+1) * 9 + 2], PRIM_INT__s_p_s_d[n * 18 + 5]);
438                         PRIM_INT__s_p_s_d[n * 18 + 5] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_p_s_s[n * 3 + 0]), PRIM_INT__s_p_s_d[n * 18 + 5]);
439 
440                         PRIM_INT__s_p_s_d[n * 18 + 6] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_p_s_p[n * 9 + 3]);
441                         PRIM_INT__s_p_s_d[n * 18 + 6] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_p_s_p[(n+1) * 9 + 3], PRIM_INT__s_p_s_d[n * 18 + 6]);
442                         PRIM_INT__s_p_s_d[n * 18 + 6] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_p_s_s[n * 3 + 1]), PRIM_INT__s_p_s_d[n * 18 + 6]);
443 
444                         PRIM_INT__s_p_s_d[n * 18 + 7] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_p_s_p[n * 9 + 3]);
445                         PRIM_INT__s_p_s_d[n * 18 + 7] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_p_s_p[(n+1) * 9 + 3], PRIM_INT__s_p_s_d[n * 18 + 7]);
446                         PRIM_INT__s_p_s_d[n * 18 + 7] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_p[(n+1) * 3 + 0], PRIM_INT__s_p_s_d[n * 18 + 7]);
447 
448                         PRIM_INT__s_p_s_d[n * 18 + 9] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_p_s_p[n * 9 + 4]);
449                         PRIM_INT__s_p_s_d[n * 18 + 9] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_p_s_p[(n+1) * 9 + 4], PRIM_INT__s_p_s_d[n * 18 + 9]);
450                         PRIM_INT__s_p_s_d[n * 18 + 9] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_p_s_s[n * 3 + 1]), PRIM_INT__s_p_s_d[n * 18 + 9]);
451                         PRIM_INT__s_p_s_d[n * 18 + 9] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_p[(n+1) * 3 + 1], PRIM_INT__s_p_s_d[n * 18 + 9]);
452 
453                         PRIM_INT__s_p_s_d[n * 18 + 11] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_p_s_p[n * 9 + 5]);
454                         PRIM_INT__s_p_s_d[n * 18 + 11] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_p_s_p[(n+1) * 9 + 5], PRIM_INT__s_p_s_d[n * 18 + 11]);
455                         PRIM_INT__s_p_s_d[n * 18 + 11] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_p_s_s[n * 3 + 1]), PRIM_INT__s_p_s_d[n * 18 + 11]);
456 
457                         PRIM_INT__s_p_s_d[n * 18 + 12] = SIMINT_MUL(Q_PB[0], PRIM_INT__s_p_s_p[n * 9 + 6]);
458                         PRIM_INT__s_p_s_d[n * 18 + 12] = SIMINT_FMADD( aoq_PQ[0], PRIM_INT__s_p_s_p[(n+1) * 9 + 6], PRIM_INT__s_p_s_d[n * 18 + 12]);
459                         PRIM_INT__s_p_s_d[n * 18 + 12] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_p_s_s[(n+1) * 3 + 2], PRIM_INT__s_p_s_s[n * 3 + 2]), PRIM_INT__s_p_s_d[n * 18 + 12]);
460 
461                         PRIM_INT__s_p_s_d[n * 18 + 13] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_p_s_p[n * 9 + 6]);
462                         PRIM_INT__s_p_s_d[n * 18 + 13] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_p_s_p[(n+1) * 9 + 6], PRIM_INT__s_p_s_d[n * 18 + 13]);
463 
464                         PRIM_INT__s_p_s_d[n * 18 + 15] = SIMINT_MUL(Q_PB[1], PRIM_INT__s_p_s_p[n * 9 + 7]);
465                         PRIM_INT__s_p_s_d[n * 18 + 15] = SIMINT_FMADD( aoq_PQ[1], PRIM_INT__s_p_s_p[(n+1) * 9 + 7], PRIM_INT__s_p_s_d[n * 18 + 15]);
466                         PRIM_INT__s_p_s_d[n * 18 + 15] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_p_s_s[(n+1) * 3 + 2], PRIM_INT__s_p_s_s[n * 3 + 2]), PRIM_INT__s_p_s_d[n * 18 + 15]);
467 
468                         PRIM_INT__s_p_s_d[n * 18 + 17] = SIMINT_MUL(Q_PB[2], PRIM_INT__s_p_s_p[n * 9 + 8]);
469                         PRIM_INT__s_p_s_d[n * 18 + 17] = SIMINT_FMADD( aoq_PQ[2], PRIM_INT__s_p_s_p[(n+1) * 9 + 8], PRIM_INT__s_p_s_d[n * 18 + 17]);
470                         PRIM_INT__s_p_s_d[n * 18 + 17] = SIMINT_FMADD( vrr_const_1_over_2q, SIMINT_FMADD(a_over_q, PRIM_INT__s_p_s_s[(n+1) * 3 + 2], PRIM_INT__s_p_s_s[n * 3 + 2]), PRIM_INT__s_p_s_d[n * 18 + 17]);
471                         PRIM_INT__s_p_s_d[n * 18 + 17] = SIMINT_FMADD( vrr_const_1_over_2pq, PRIM_INT__s_s_s_p[(n+1) * 3 + 2], PRIM_INT__s_p_s_d[n * 18 + 17]);
472 
473                     }
474 
475 
476                     VRR_L_s_d_s_f(
477                             PRIM_INT__s_d_s_f,
478                             PRIM_INT__s_d_s_d,
479                             PRIM_INT__s_d_s_p,
480                             PRIM_INT__s_p_s_d,
481                             Q_PB,
482                             a_over_q,
483                             aoq_PQ,
484                             one_over_2pq,
485                             one_over_2q,
486                             1);
487 
488 
489 
490                     // Forming PRIM_INT__s_f_s_s[4 * 10];
491                     for(n = 0; n < 4; ++n)  // loop over orders of auxiliary function
492                     {
493 
494                         PRIM_INT__s_f_s_s[n * 10 + 0] = SIMINT_MUL(P_PB[0], PRIM_INT__s_d_s_s[n * 6 + 0]);
495                         PRIM_INT__s_f_s_s[n * 10 + 0] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_d_s_s[(n+1) * 6 + 0], PRIM_INT__s_f_s_s[n * 10 + 0]);
496                         PRIM_INT__s_f_s_s[n * 10 + 0] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_p_s_s[(n+1) * 3 + 0], PRIM_INT__s_p_s_s[n * 3 + 0]), PRIM_INT__s_f_s_s[n * 10 + 0]);
497 
498                         PRIM_INT__s_f_s_s[n * 10 + 1] = SIMINT_MUL(P_PB[1], PRIM_INT__s_d_s_s[n * 6 + 0]);
499                         PRIM_INT__s_f_s_s[n * 10 + 1] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_d_s_s[(n+1) * 6 + 0], PRIM_INT__s_f_s_s[n * 10 + 1]);
500 
501                         PRIM_INT__s_f_s_s[n * 10 + 2] = SIMINT_MUL(P_PB[2], PRIM_INT__s_d_s_s[n * 6 + 0]);
502                         PRIM_INT__s_f_s_s[n * 10 + 2] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 0], PRIM_INT__s_f_s_s[n * 10 + 2]);
503 
504                         PRIM_INT__s_f_s_s[n * 10 + 3] = SIMINT_MUL(P_PB[0], PRIM_INT__s_d_s_s[n * 6 + 3]);
505                         PRIM_INT__s_f_s_s[n * 10 + 3] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_d_s_s[(n+1) * 6 + 3], PRIM_INT__s_f_s_s[n * 10 + 3]);
506 
507                         PRIM_INT__s_f_s_s[n * 10 + 4] = SIMINT_MUL(P_PB[2], PRIM_INT__s_d_s_s[n * 6 + 1]);
508                         PRIM_INT__s_f_s_s[n * 10 + 4] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 1], PRIM_INT__s_f_s_s[n * 10 + 4]);
509 
510                         PRIM_INT__s_f_s_s[n * 10 + 5] = SIMINT_MUL(P_PB[0], PRIM_INT__s_d_s_s[n * 6 + 5]);
511                         PRIM_INT__s_f_s_s[n * 10 + 5] = SIMINT_FMADD( aop_PQ[0], PRIM_INT__s_d_s_s[(n+1) * 6 + 5], PRIM_INT__s_f_s_s[n * 10 + 5]);
512 
513                         PRIM_INT__s_f_s_s[n * 10 + 6] = SIMINT_MUL(P_PB[1], PRIM_INT__s_d_s_s[n * 6 + 3]);
514                         PRIM_INT__s_f_s_s[n * 10 + 6] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_d_s_s[(n+1) * 6 + 3], PRIM_INT__s_f_s_s[n * 10 + 6]);
515                         PRIM_INT__s_f_s_s[n * 10 + 6] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_p_s_s[(n+1) * 3 + 1], PRIM_INT__s_p_s_s[n * 3 + 1]), PRIM_INT__s_f_s_s[n * 10 + 6]);
516 
517                         PRIM_INT__s_f_s_s[n * 10 + 7] = SIMINT_MUL(P_PB[2], PRIM_INT__s_d_s_s[n * 6 + 3]);
518                         PRIM_INT__s_f_s_s[n * 10 + 7] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 3], PRIM_INT__s_f_s_s[n * 10 + 7]);
519 
520                         PRIM_INT__s_f_s_s[n * 10 + 8] = SIMINT_MUL(P_PB[1], PRIM_INT__s_d_s_s[n * 6 + 5]);
521                         PRIM_INT__s_f_s_s[n * 10 + 8] = SIMINT_FMADD( aop_PQ[1], PRIM_INT__s_d_s_s[(n+1) * 6 + 5], PRIM_INT__s_f_s_s[n * 10 + 8]);
522 
523                         PRIM_INT__s_f_s_s[n * 10 + 9] = SIMINT_MUL(P_PB[2], PRIM_INT__s_d_s_s[n * 6 + 5]);
524                         PRIM_INT__s_f_s_s[n * 10 + 9] = SIMINT_FMADD( aop_PQ[2], PRIM_INT__s_d_s_s[(n+1) * 6 + 5], PRIM_INT__s_f_s_s[n * 10 + 9]);
525                         PRIM_INT__s_f_s_s[n * 10 + 9] = SIMINT_FMADD( vrr_const_2_over_2p, SIMINT_FMADD(a_over_p, PRIM_INT__s_p_s_s[(n+1) * 3 + 2], PRIM_INT__s_p_s_s[n * 3 + 2]), PRIM_INT__s_f_s_s[n * 10 + 9]);
526 
527                     }
528 
529 
530                     VRR_L_s_f_s_p(
531                             PRIM_INT__s_f_s_p,
532                             PRIM_INT__s_f_s_s,
533                             PRIM_INT__s_d_s_s,
534                             Q_PB,
535                             aoq_PQ,
536                             one_over_2pq,
537                             3);
538 
539 
540                     VRR_L_s_f_s_d(
541                             PRIM_INT__s_f_s_d,
542                             PRIM_INT__s_f_s_p,
543                             PRIM_INT__s_f_s_s,
544                             PRIM_INT__s_d_s_p,
545                             Q_PB,
546                             a_over_q,
547                             aoq_PQ,
548                             one_over_2pq,
549                             one_over_2q,
550                             2);
551 
552 
553                     ostei_general_vrr_L(0, 3, 0, 3, 1,
554                             one_over_2q, a_over_q, one_over_2pq, aoq_PQ, Q_PB,
555                             PRIM_INT__s_f_s_d, NULL, PRIM_INT__s_f_s_p, NULL, PRIM_INT__s_d_s_d, PRIM_INT__s_f_s_f);
556 
557 
558 
559 
560                     ////////////////////////////////////
561                     // Accumulate contracted integrals
562                     ////////////////////////////////////
563                     if(lastoffset == 0)
564                     {
565                         contract_all(36, PRIM_INT__s_d_s_d, PRIM_PTR_INT__s_d_s_d);
566                         contract_all(60, PRIM_INT__s_d_s_f, PRIM_PTR_INT__s_d_s_f);
567                         contract_all(60, PRIM_INT__s_f_s_d, PRIM_PTR_INT__s_f_s_d);
568                         contract_all(100, PRIM_INT__s_f_s_f, PRIM_PTR_INT__s_f_s_f);
569                     }
570                     else
571                     {
572                         contract(36, shelloffsets, PRIM_INT__s_d_s_d, PRIM_PTR_INT__s_d_s_d);
573                         contract(60, shelloffsets, PRIM_INT__s_d_s_f, PRIM_PTR_INT__s_d_s_f);
574                         contract(60, shelloffsets, PRIM_INT__s_f_s_d, PRIM_PTR_INT__s_f_s_d);
575                         contract(100, shelloffsets, PRIM_INT__s_f_s_f, PRIM_PTR_INT__s_f_s_f);
576                         PRIM_PTR_INT__s_d_s_d += lastoffset*36;
577                         PRIM_PTR_INT__s_d_s_f += lastoffset*60;
578                         PRIM_PTR_INT__s_f_s_d += lastoffset*60;
579                         PRIM_PTR_INT__s_f_s_f += lastoffset*100;
580                     }
581 
582                 }  // close loop over j
583             }  // close loop over i
584 
585             //Advance to the next batch
586             jstart = SIMINT_SIMD_ROUND(jend);
587 
588             //////////////////////////////////////////////
589             // Contracted integrals: Horizontal recurrance
590             //////////////////////////////////////////////
591 
592 
593             const double hAB[3] = { P.AB_x[ab], P.AB_y[ab], P.AB_z[ab] };
594 
595 
596             for(abcd = 0; abcd < nshellbatch; ++abcd, ++real_abcd)
597             {
598                 const double hCD[3] = { Q.AB_x[cd+abcd], Q.AB_y[cd+abcd], Q.AB_z[cd+abcd] };
599 
600                 // set up HRR pointers
601                 double const * restrict HRR_INT__s_d_s_d = INT__s_d_s_d + abcd * 36;
602                 double const * restrict HRR_INT__s_d_s_f = INT__s_d_s_f + abcd * 60;
603                 double const * restrict HRR_INT__s_f_s_d = INT__s_f_s_d + abcd * 60;
604                 double const * restrict HRR_INT__s_f_s_f = INT__s_f_s_f + abcd * 100;
605                 double * restrict HRR_INT__p_d_p_d = INT__p_d_p_d + real_abcd * 324;
606 
607                 // form INT__p_d_s_d
608                 for(iket = 0; iket < 6; ++iket)
609                 {
610                     HRR_INT__p_d_s_d[0 * 6 + iket] = HRR_INT__s_f_s_d[0 * 6 + iket] - ( hAB[0] * HRR_INT__s_d_s_d[0 * 6 + iket] );
611 
612                     HRR_INT__p_d_s_d[1 * 6 + iket] = HRR_INT__s_f_s_d[1 * 6 + iket] - ( hAB[0] * HRR_INT__s_d_s_d[1 * 6 + iket] );
613 
614                     HRR_INT__p_d_s_d[2 * 6 + iket] = HRR_INT__s_f_s_d[2 * 6 + iket] - ( hAB[0] * HRR_INT__s_d_s_d[2 * 6 + iket] );
615 
616                     HRR_INT__p_d_s_d[3 * 6 + iket] = HRR_INT__s_f_s_d[3 * 6 + iket] - ( hAB[0] * HRR_INT__s_d_s_d[3 * 6 + iket] );
617 
618                     HRR_INT__p_d_s_d[4 * 6 + iket] = HRR_INT__s_f_s_d[4 * 6 + iket] - ( hAB[0] * HRR_INT__s_d_s_d[4 * 6 + iket] );
619 
620                     HRR_INT__p_d_s_d[5 * 6 + iket] = HRR_INT__s_f_s_d[5 * 6 + iket] - ( hAB[0] * HRR_INT__s_d_s_d[5 * 6 + iket] );
621 
622                     HRR_INT__p_d_s_d[6 * 6 + iket] = HRR_INT__s_f_s_d[1 * 6 + iket] - ( hAB[1] * HRR_INT__s_d_s_d[0 * 6 + iket] );
623 
624                     HRR_INT__p_d_s_d[7 * 6 + iket] = HRR_INT__s_f_s_d[3 * 6 + iket] - ( hAB[1] * HRR_INT__s_d_s_d[1 * 6 + iket] );
625 
626                     HRR_INT__p_d_s_d[8 * 6 + iket] = HRR_INT__s_f_s_d[4 * 6 + iket] - ( hAB[1] * HRR_INT__s_d_s_d[2 * 6 + iket] );
627 
628                     HRR_INT__p_d_s_d[9 * 6 + iket] = HRR_INT__s_f_s_d[6 * 6 + iket] - ( hAB[1] * HRR_INT__s_d_s_d[3 * 6 + iket] );
629 
630                     HRR_INT__p_d_s_d[10 * 6 + iket] = HRR_INT__s_f_s_d[7 * 6 + iket] - ( hAB[1] * HRR_INT__s_d_s_d[4 * 6 + iket] );
631 
632                     HRR_INT__p_d_s_d[11 * 6 + iket] = HRR_INT__s_f_s_d[8 * 6 + iket] - ( hAB[1] * HRR_INT__s_d_s_d[5 * 6 + iket] );
633 
634                     HRR_INT__p_d_s_d[12 * 6 + iket] = HRR_INT__s_f_s_d[2 * 6 + iket] - ( hAB[2] * HRR_INT__s_d_s_d[0 * 6 + iket] );
635 
636                     HRR_INT__p_d_s_d[13 * 6 + iket] = HRR_INT__s_f_s_d[4 * 6 + iket] - ( hAB[2] * HRR_INT__s_d_s_d[1 * 6 + iket] );
637 
638                     HRR_INT__p_d_s_d[14 * 6 + iket] = HRR_INT__s_f_s_d[5 * 6 + iket] - ( hAB[2] * HRR_INT__s_d_s_d[2 * 6 + iket] );
639 
640                     HRR_INT__p_d_s_d[15 * 6 + iket] = HRR_INT__s_f_s_d[7 * 6 + iket] - ( hAB[2] * HRR_INT__s_d_s_d[3 * 6 + iket] );
641 
642                     HRR_INT__p_d_s_d[16 * 6 + iket] = HRR_INT__s_f_s_d[8 * 6 + iket] - ( hAB[2] * HRR_INT__s_d_s_d[4 * 6 + iket] );
643 
644                     HRR_INT__p_d_s_d[17 * 6 + iket] = HRR_INT__s_f_s_d[9 * 6 + iket] - ( hAB[2] * HRR_INT__s_d_s_d[5 * 6 + iket] );
645 
646                 }
647 
648 
649                 // form INT__p_d_s_f
650                 for(iket = 0; iket < 10; ++iket)
651                 {
652                     HRR_INT__p_d_s_f[0 * 10 + iket] = HRR_INT__s_f_s_f[0 * 10 + iket] - ( hAB[0] * HRR_INT__s_d_s_f[0 * 10 + iket] );
653 
654                     HRR_INT__p_d_s_f[1 * 10 + iket] = HRR_INT__s_f_s_f[1 * 10 + iket] - ( hAB[0] * HRR_INT__s_d_s_f[1 * 10 + iket] );
655 
656                     HRR_INT__p_d_s_f[2 * 10 + iket] = HRR_INT__s_f_s_f[2 * 10 + iket] - ( hAB[0] * HRR_INT__s_d_s_f[2 * 10 + iket] );
657 
658                     HRR_INT__p_d_s_f[3 * 10 + iket] = HRR_INT__s_f_s_f[3 * 10 + iket] - ( hAB[0] * HRR_INT__s_d_s_f[3 * 10 + iket] );
659 
660                     HRR_INT__p_d_s_f[4 * 10 + iket] = HRR_INT__s_f_s_f[4 * 10 + iket] - ( hAB[0] * HRR_INT__s_d_s_f[4 * 10 + iket] );
661 
662                     HRR_INT__p_d_s_f[5 * 10 + iket] = HRR_INT__s_f_s_f[5 * 10 + iket] - ( hAB[0] * HRR_INT__s_d_s_f[5 * 10 + iket] );
663 
664                     HRR_INT__p_d_s_f[6 * 10 + iket] = HRR_INT__s_f_s_f[1 * 10 + iket] - ( hAB[1] * HRR_INT__s_d_s_f[0 * 10 + iket] );
665 
666                     HRR_INT__p_d_s_f[7 * 10 + iket] = HRR_INT__s_f_s_f[3 * 10 + iket] - ( hAB[1] * HRR_INT__s_d_s_f[1 * 10 + iket] );
667 
668                     HRR_INT__p_d_s_f[8 * 10 + iket] = HRR_INT__s_f_s_f[4 * 10 + iket] - ( hAB[1] * HRR_INT__s_d_s_f[2 * 10 + iket] );
669 
670                     HRR_INT__p_d_s_f[9 * 10 + iket] = HRR_INT__s_f_s_f[6 * 10 + iket] - ( hAB[1] * HRR_INT__s_d_s_f[3 * 10 + iket] );
671 
672                     HRR_INT__p_d_s_f[10 * 10 + iket] = HRR_INT__s_f_s_f[7 * 10 + iket] - ( hAB[1] * HRR_INT__s_d_s_f[4 * 10 + iket] );
673 
674                     HRR_INT__p_d_s_f[11 * 10 + iket] = HRR_INT__s_f_s_f[8 * 10 + iket] - ( hAB[1] * HRR_INT__s_d_s_f[5 * 10 + iket] );
675 
676                     HRR_INT__p_d_s_f[12 * 10 + iket] = HRR_INT__s_f_s_f[2 * 10 + iket] - ( hAB[2] * HRR_INT__s_d_s_f[0 * 10 + iket] );
677 
678                     HRR_INT__p_d_s_f[13 * 10 + iket] = HRR_INT__s_f_s_f[4 * 10 + iket] - ( hAB[2] * HRR_INT__s_d_s_f[1 * 10 + iket] );
679 
680                     HRR_INT__p_d_s_f[14 * 10 + iket] = HRR_INT__s_f_s_f[5 * 10 + iket] - ( hAB[2] * HRR_INT__s_d_s_f[2 * 10 + iket] );
681 
682                     HRR_INT__p_d_s_f[15 * 10 + iket] = HRR_INT__s_f_s_f[7 * 10 + iket] - ( hAB[2] * HRR_INT__s_d_s_f[3 * 10 + iket] );
683 
684                     HRR_INT__p_d_s_f[16 * 10 + iket] = HRR_INT__s_f_s_f[8 * 10 + iket] - ( hAB[2] * HRR_INT__s_d_s_f[4 * 10 + iket] );
685 
686                     HRR_INT__p_d_s_f[17 * 10 + iket] = HRR_INT__s_f_s_f[9 * 10 + iket] - ( hAB[2] * HRR_INT__s_d_s_f[5 * 10 + iket] );
687 
688                 }
689 
690 
691                 // form INT__p_d_p_d
692                 for(ibra = 0; ibra < 18; ++ibra)
693                 {
694                     HRR_INT__p_d_p_d[ibra * 18 + 0] = HRR_INT__p_d_s_f[ibra * 10 + 0] - ( hCD[0] * HRR_INT__p_d_s_d[ibra * 6 + 0] );
695 
696                     HRR_INT__p_d_p_d[ibra * 18 + 1] = HRR_INT__p_d_s_f[ibra * 10 + 1] - ( hCD[0] * HRR_INT__p_d_s_d[ibra * 6 + 1] );
697 
698                     HRR_INT__p_d_p_d[ibra * 18 + 2] = HRR_INT__p_d_s_f[ibra * 10 + 2] - ( hCD[0] * HRR_INT__p_d_s_d[ibra * 6 + 2] );
699 
700                     HRR_INT__p_d_p_d[ibra * 18 + 3] = HRR_INT__p_d_s_f[ibra * 10 + 3] - ( hCD[0] * HRR_INT__p_d_s_d[ibra * 6 + 3] );
701 
702                     HRR_INT__p_d_p_d[ibra * 18 + 4] = HRR_INT__p_d_s_f[ibra * 10 + 4] - ( hCD[0] * HRR_INT__p_d_s_d[ibra * 6 + 4] );
703 
704                     HRR_INT__p_d_p_d[ibra * 18 + 5] = HRR_INT__p_d_s_f[ibra * 10 + 5] - ( hCD[0] * HRR_INT__p_d_s_d[ibra * 6 + 5] );
705 
706                     HRR_INT__p_d_p_d[ibra * 18 + 6] = HRR_INT__p_d_s_f[ibra * 10 + 1] - ( hCD[1] * HRR_INT__p_d_s_d[ibra * 6 + 0] );
707 
708                     HRR_INT__p_d_p_d[ibra * 18 + 7] = HRR_INT__p_d_s_f[ibra * 10 + 3] - ( hCD[1] * HRR_INT__p_d_s_d[ibra * 6 + 1] );
709 
710                     HRR_INT__p_d_p_d[ibra * 18 + 8] = HRR_INT__p_d_s_f[ibra * 10 + 4] - ( hCD[1] * HRR_INT__p_d_s_d[ibra * 6 + 2] );
711 
712                     HRR_INT__p_d_p_d[ibra * 18 + 9] = HRR_INT__p_d_s_f[ibra * 10 + 6] - ( hCD[1] * HRR_INT__p_d_s_d[ibra * 6 + 3] );
713 
714                     HRR_INT__p_d_p_d[ibra * 18 + 10] = HRR_INT__p_d_s_f[ibra * 10 + 7] - ( hCD[1] * HRR_INT__p_d_s_d[ibra * 6 + 4] );
715 
716                     HRR_INT__p_d_p_d[ibra * 18 + 11] = HRR_INT__p_d_s_f[ibra * 10 + 8] - ( hCD[1] * HRR_INT__p_d_s_d[ibra * 6 + 5] );
717 
718                     HRR_INT__p_d_p_d[ibra * 18 + 12] = HRR_INT__p_d_s_f[ibra * 10 + 2] - ( hCD[2] * HRR_INT__p_d_s_d[ibra * 6 + 0] );
719 
720                     HRR_INT__p_d_p_d[ibra * 18 + 13] = HRR_INT__p_d_s_f[ibra * 10 + 4] - ( hCD[2] * HRR_INT__p_d_s_d[ibra * 6 + 1] );
721 
722                     HRR_INT__p_d_p_d[ibra * 18 + 14] = HRR_INT__p_d_s_f[ibra * 10 + 5] - ( hCD[2] * HRR_INT__p_d_s_d[ibra * 6 + 2] );
723 
724                     HRR_INT__p_d_p_d[ibra * 18 + 15] = HRR_INT__p_d_s_f[ibra * 10 + 7] - ( hCD[2] * HRR_INT__p_d_s_d[ibra * 6 + 3] );
725 
726                     HRR_INT__p_d_p_d[ibra * 18 + 16] = HRR_INT__p_d_s_f[ibra * 10 + 8] - ( hCD[2] * HRR_INT__p_d_s_d[ibra * 6 + 4] );
727 
728                     HRR_INT__p_d_p_d[ibra * 18 + 17] = HRR_INT__p_d_s_f[ibra * 10 + 9] - ( hCD[2] * HRR_INT__p_d_s_d[ibra * 6 + 5] );
729 
730                 }
731 
732 
733             }  // close HRR loop
734 
735 
736         }   // close loop cdbatch
737 
738         istart = iend;
739     }  // close loop over ab
740 
741     return P.nshell12_clip * Q.nshell12_clip;
742 }
743 
744