1 #include "simint/ostei/ostei_general.h"
2 #include "simint/recur_lookup.h"
3 
4 
ostei_general_hrr_I(int i,int j,int k,int l,const double AB[3],const double * theta1,const double * theta2,double * output)5 void ostei_general_hrr_I(int i, int j, int k, int l,
6                          const double AB[3],
7                          const double * theta1,
8                          const double * theta2,
9                          double * output)
10 {
11     const int ncart_i = ((i+1)*(i+2))/2;
12     const int ncart_j = ((j+1)*(j+2))/2;
13     const int ncart_k = ((k+1)*(k+2))/2;
14     const int ncart_l = ((l+1)*(l+2))/2;
15 
16     const int ncart_kl = ncart_k * ncart_l;
17 
18     const int ncart_j_p1 = ((j+2)*(j+3))/2;
19 
20     const int arrstart_i = am_recur_map[i];
21     const int arrstart_j = am_recur_map[j];
22     struct RecurInfo const * aminfo_i = &recurinfo_array[arrstart_i];
23     struct RecurInfo const * aminfo_j = &recurinfo_array[arrstart_j];
24 
25     int outidx = 0;
26     for(int idx_i = 0; idx_i < ncart_i; idx_i++)
27     {
28         struct RecurInfo const * ri = aminfo_i + idx_i;
29 
30         for(int idx_j = 0; idx_j < ncart_j; idx_j++)
31         {
32             struct RecurInfo const * rj = aminfo_j + idx_j;
33             const int dir = ri->dir;
34 
35             const int idx_i_m1 = ri->idx[dir][0];
36             const int idx_j_p1 = rj->idx[dir][2];
37 
38             const int idx1 = idx_i_m1 * ncart_j_p1 * ncart_kl +
39                              idx_j_p1 * ncart_kl;
40 
41             const int idx2 = idx_i_m1 * ncart_j    * ncart_kl +
42                              idx_j    * ncart_kl;
43 
44             for(int idx_kl = 0; idx_kl < ncart_kl; idx_kl++)
45             {
46                 const int idx1_full = idx1 + idx_kl;
47                 const int idx2_full = idx2 + idx_kl;
48                 output[outidx] = theta1[idx1_full] - AB[dir]*theta2[idx2_full];
49                 outidx++;
50             }
51         }
52     }
53 }
54 
55 
56 
ostei_general_hrr_J(int i,int j,int k,int l,const double AB[3],const double * theta1,const double * theta2,double * output)57 void ostei_general_hrr_J(int i, int j, int k, int l,
58                          const double AB[3],
59                          const double * theta1,
60                          const double * theta2,
61                          double * output)
62 {
63     const int ncart_i = ((i+1)*(i+2))/2;
64     const int ncart_j = ((j+1)*(j+2))/2;
65     const int ncart_k = ((k+1)*(k+2))/2;
66     const int ncart_l = ((l+1)*(l+2))/2;
67 
68     const int ncart_kl = ncart_k * ncart_l;
69 
70     const int ncart_j_m1 = ((j)*(j+1))/2;
71 
72     const int arrstart_i = am_recur_map[i];
73     const int arrstart_j = am_recur_map[j];
74     struct RecurInfo const * aminfo_i = &recurinfo_array[arrstart_i];
75     struct RecurInfo const * aminfo_j = &recurinfo_array[arrstart_j];
76 
77     int outidx = 0;
78     for(int idx_i = 0; idx_i < ncart_i; idx_i++)
79     {
80         struct RecurInfo const * ri = aminfo_i + idx_i;
81 
82         for(int idx_j = 0; idx_j < ncart_j; idx_j++)
83         {
84             struct RecurInfo const * rj = aminfo_j + idx_j;
85             const int dir = rj->dir;
86 
87             const int idx_i_p1 = ri->idx[dir][2];
88             const int idx_j_m1 = rj->idx[dir][0];
89 
90             const int idx1 = idx_i_p1 * ncart_j_m1 * ncart_kl +
91                              idx_j_m1 * ncart_kl;
92 
93             const int idx2 = idx_i    * ncart_j_m1 * ncart_kl +
94                              idx_j_m1 * ncart_kl;
95 
96             for(int idx_kl = 0; idx_kl < ncart_kl; idx_kl++)
97             {
98                 const int idx1_full = idx1 + idx_kl;
99                 const int idx2_full = idx2 + idx_kl;
100                 output[outidx] = theta1[idx1_full] + AB[dir]*theta2[idx2_full];
101                 outidx++;
102             }
103         }
104     }
105 }
106 
107 
ostei_general_hrr_K(int i,int j,int k,int l,const double CD[3],const double * theta1,const double * theta2,double * output)108 void ostei_general_hrr_K(int i, int j, int k, int l,
109                          const double CD[3],
110                          const double * theta1,
111                          const double * theta2,
112                          double * output)
113 {
114     const int ncart_i = ((i+1)*(i+2))/2;
115     const int ncart_j = ((j+1)*(j+2))/2;
116     const int ncart_k = ((k+1)*(k+2))/2;
117     const int ncart_l = ((l+1)*(l+2))/2;
118 
119     const int ncart_ij = ncart_i * ncart_j;
120 
121     const int ncart_k_m1 = ((k)*(k+1))/2;
122     const int ncart_l_p1 = ((l+2)*(l+3))/2;
123 
124     const int arrstart_k = am_recur_map[k];
125     const int arrstart_l = am_recur_map[l];
126     struct RecurInfo const * aminfo_k = &recurinfo_array[arrstart_k];
127     struct RecurInfo const * aminfo_l = &recurinfo_array[arrstart_l];
128 
129     int outidx = 0;
130     for(int idx_ij = 0; idx_ij < ncart_ij; idx_ij++)
131     {
132         for(int idx_k = 0; idx_k < ncart_k; idx_k++)
133         {
134             struct RecurInfo const * rk = aminfo_k + idx_k;
135 
136             for(int idx_l = 0; idx_l < ncart_l; idx_l++)
137             {
138                 struct RecurInfo const * rl = aminfo_l + idx_l;
139                 const int dir = rk->dir;
140                 const int idx_k_m1 = rk->idx[dir][0];
141                 const int idx_l_p1 = rl->idx[dir][2];
142 
143                 const int idx1_full = idx_ij   * ncart_k_m1 * ncart_l_p1 +
144                                       idx_k_m1 * ncart_l_p1 +
145                                       idx_l_p1;
146 
147                 const int idx2_full = idx_ij   * ncart_k_m1 * ncart_l +
148                                       idx_k_m1 * ncart_l +
149                                       idx_l;
150 
151                 output[outidx] = theta1[idx1_full] - CD[dir]*theta2[idx2_full];
152                 outidx++;
153             }
154         }
155     }
156 }
157 
ostei_general_hrr_L(int i,int j,int k,int l,const double CD[3],const double * theta1,const double * theta2,double * output)158 void ostei_general_hrr_L(int i, int j, int k, int l,
159                          const double CD[3],
160                          const double * theta1,
161                          const double * theta2,
162                          double * output)
163 {
164     const int ncart_i = ((i+1)*(i+2))/2;
165     const int ncart_j = ((j+1)*(j+2))/2;
166     const int ncart_k = ((k+1)*(k+2))/2;
167     const int ncart_l = ((l+1)*(l+2))/2;
168 
169     const int ncart_ij = ncart_i * ncart_j;
170 
171     const int ncart_k_p1 = ((k+2)*(k+3))/2;
172     const int ncart_l_m1 = ((l)*(l+1))/2;
173 
174     const int arrstart_k = am_recur_map[k];
175     const int arrstart_l = am_recur_map[l];
176     struct RecurInfo const * aminfo_k = &recurinfo_array[arrstart_k];
177     struct RecurInfo const * aminfo_l = &recurinfo_array[arrstart_l];
178 
179     int outidx = 0;
180     for(int idx_ij = 0; idx_ij < ncart_ij; idx_ij++)
181     {
182         for(int idx_k = 0; idx_k < ncart_k; idx_k++)
183         {
184             struct RecurInfo const * rk = aminfo_k + idx_k;
185 
186             for(int idx_l = 0; idx_l < ncart_l; idx_l++)
187             {
188                 struct RecurInfo const * rl = aminfo_l + idx_l;
189                 const int dir = rl->dir;
190                 const int idx_k_p1 = rk->idx[dir][2];
191                 const int idx_l_m1 = rl->idx[dir][0];
192 
193                 const int idx1_full = idx_ij   * ncart_k_p1 * ncart_l_m1 +
194                                       idx_k_p1 * ncart_l_m1 +
195                                       idx_l_m1;
196 
197                 const int idx2_full = idx_ij   * ncart_k  * ncart_l_m1 +
198                                       idx_k    * ncart_l_m1 +
199                                       idx_l_m1;
200 
201                 output[outidx] = theta1[idx1_full] + CD[dir]*theta2[idx2_full];
202                 outidx++;
203             }
204         }
205     }
206 }
207