28 #ifndef _chemistry_qc_scf_lgbuild_h
29 #define _chemistry_qc_scf_lgbuild_h
32 #undef SCF_CHECK_BOUNDS
33 #undef SCF_DONT_USE_BOUNDS
35 #include <mpqc_config.h>
36 #include <chemistry/qc/scf/gbuild.h>
52 signed char * RESTRICT pmax;
60 signed char *pm,
double acc,
int nt=1,
int tn=0) :
62 pmax(pm), threadno_(tn), nthread_(nt), accuracy_(acc)
72 int tol = (int) (log(accuracy_)/log(2.0));
74 int nproc = grp_->
n();
82 const double *intbuf = tbi.
buffer();
86 sc_int_least64_t threadind=0;
87 sc_int_least64_t ijklind=0;
89 for (
int i=0; i < gbs.
nshell(); i++) {
94 int ni=gbs(i).nfunction();
96 for (
int j=0; j <= i; j++) {
97 int oij = i_offset(i)+j;
103 int nj=gbs(j).nfunction();
104 int pmaxij = pmax[oij];
106 for (
int k=0; k <= i; k++, ijklind++) {
107 if (ijklind%nproc != me)
111 if (threadind % nthread_ != threadno_)
115 int nk=gbs(k).nfunction();
117 int pmaxijk=pmaxij, ptmp;
118 if ((ptmp=pmax[i_offset(i)+k]-1) > pmaxijk) pmaxijk=ptmp;
119 if ((ptmp=pmax[ij_offset(j,k)]-1) > pmaxijk) pmaxijk=ptmp;
121 int okl = i_offset(k);
122 for (
int l=0; l <= (k==i?j:k); l++,okl++) {
123 int pmaxijkl = pmaxijk;
124 if ((ptmp=pmax[okl]) > pmaxijkl) pmaxijkl=ptmp;
125 if ((ptmp=pmax[i_offset(i)+l]-1) > pmaxijkl) pmaxijkl=ptmp;
126 if ((ptmp=pmax[ij_offset(j,l)]-1) > pmaxijkl) pmaxijkl=ptmp;
128 int qijkl = pl.in_p4(oij,okl,i,j,k,l);
132 #ifdef SCF_CHECK_BOUNDS
134 double pbound = pow(2.0,
double(pmaxijkl));
138 # ifndef SCF_DONT_USE_BOUNDS
144 #ifdef MPQC_NEW_FEATURES
145 const auto tstart = sc::RegionTimer::get_time_point();
148 #ifdef MPQC_NEW_FEATURES
149 const auto tstop = RegionTimer::get_time_point();
150 const std::chrono::duration<double> time_elapsed = tstop - tstart;
156 int e13e24 = (i==k) && (j==l);
157 int e_any = e12||e34||e13e24;
160 int nl=gbs(l).nfunction();
166 for (I=0, ii=fi; I < ni; I++, ii++) {
167 for (J=0, jj=fj; J <= (e12 ? I : nj-1); J++, jj++) {
168 for (K=0, kk=fk; K <= (e13e24 ? I : nk-1); K++, kk++) {
169 int lend = (e34 ? ((e13e24)&&(K==I) ? J : K)
170 : ((e13e24)&&(K==I)) ? J : nl-1);
172 for (L=0, ll=fl; L <= lend; L++, ll++, index++) {
174 double pki_int = intbuf[index];
176 if ((pki_int>0?pki_int:-pki_int) < 1.0e-15)
179 #ifdef SCF_CHECK_INTS
200 if (ii == jj || kk == ll) {
201 ij = i_offset(ii)+jj;
202 kl = i_offset(kk)+ll;
203 val = (ij==kl) ? 0.5*pki_int : pki_int;
215 ij = i_offset(ii)+jj;
216 kl = i_offset(kk)+ll;
217 val = (ij==kl) ? 0.5*pki_int : pki_int;
228 ij = ij_offset(ii,ll);
229 kl = ij_offset(kk,jj);
230 val = (ij==kl) ? 0.5*pki_int : pki_int;
234 }
else if (ii == kk || jj == ll) {
242 ij = i_offset(ii)+jj;
243 kl = i_offset(kk)+ll;
244 val = (ij==kl) ? 0.5*pki_int : pki_int;
255 ij = ij_offset(ii,kk);
256 kl = ij_offset(jj,ll);
257 val = (ij==kl) ? 0.5*pki_int : pki_int;
267 ij = i_offset(ii)+jj;
268 kl = i_offset(kk)+ll;
269 val = (ij==kl) ? 0.5*pki_int : pki_int;
278 ij = ij_offset(ii,kk);
279 kl = ij_offset(jj,ll);
280 val = (ij==kl) ? 0.5*pki_int : pki_int;
284 if ((ii != jj) && (kk != ll)) {
294 ij = ij_offset(ii,ll);
295 kl = ij_offset(kk,jj);
320 }
else if (ii == kk || jj == ll) {
367 tnint += (double) ni*nj*nk*nl;