28 #ifndef _chemistry_qc_scf_lgbuild_h
29 #define _chemistry_qc_scf_lgbuild_h
36 #undef SCF_CHECK_BOUNDS
37 #undef SCF_DONT_USE_BOUNDS
40 #include <chemistry/qc/scf/gbuild.h>
55 signed char * restrictxx pmax;
63 signed char *pm,
double acc,
int nt=1,
int tn=0) :
65 pmax(pm), nthread_(nt), threadno_(tn), accuracy_(acc)
75 int tol = (int) (log(accuracy_)/log(2.0));
77 int nproc = grp_->
n();
85 const double *intbuf = tbi.
buffer();
88 sc_int_least64_t threadind=0;
89 sc_int_least64_t ijklind=0;
91 for (
int i=0; i < gbs.
nshell(); i++) {
96 int ni=gbs(i).nfunction();
98 for (
int j=0; j <= i; j++) {
99 int oij = i_offset(i)+j;
105 int nj=gbs(j).nfunction();
106 int pmaxij = pmax[oij];
108 for (
int k=0; k <= i; k++, ijklind++) {
109 if (ijklind%nproc != me)
113 if (threadind % nthread_ != threadno_)
117 int nk=gbs(k).nfunction();
119 int pmaxijk=pmaxij, ptmp;
120 if ((ptmp=pmax[i_offset(i)+k]-1) > pmaxijk) pmaxijk=ptmp;
121 if ((ptmp=pmax[ij_offset(j,k)]-1) > pmaxijk) pmaxijk=ptmp;
123 int okl = i_offset(k);
124 for (
int l=0; l <= (k==i?j:k); l++,okl++) {
125 int pmaxijkl = pmaxijk;
126 if ((ptmp=pmax[okl]) > pmaxijkl) pmaxijkl=ptmp;
127 if ((ptmp=pmax[i_offset(i)+l]-1) > pmaxijkl) pmaxijkl=ptmp;
128 if ((ptmp=pmax[ij_offset(j,l)]-1) > pmaxijkl) pmaxijkl=ptmp;
130 int qijkl = pl.in_p4(oij,okl,i,j,k,l);
134 #ifdef SCF_CHECK_BOUNDS
136 double pbound = pow(2.0,
double(pmaxijkl));
140 # ifndef SCF_DONT_USE_BOUNDS
152 int e13e24 = (i==k) && (j==l);
153 int e_any = e12||e34||e13e24;
156 int nl=gbs(l).nfunction();
162 for (I=0, ii=fi; I < ni; I++, ii++) {
163 for (J=0, jj=fj; J <= (e12 ? I : nj-1); J++, jj++) {
164 for (K=0, kk=fk; K <= (e13e24 ? I : nk-1); K++, kk++) {
165 int lend = (e34 ? ((e13e24)&&(K==I) ? J : K)
166 : ((e13e24)&&(K==I)) ? J : nl-1);
168 for (L=0, ll=fl; L <= lend; L++, ll++, index++) {
170 double pki_int = intbuf[index];
172 if ((pki_int>0?pki_int:-pki_int) < 1.0e-15)
175 #ifdef SCF_CHECK_INTS
196 if (ii == jj || kk == ll) {
197 ij = i_offset(ii)+jj;
198 kl = i_offset(kk)+ll;
199 val = (ij==kl) ? 0.5*pki_int : pki_int;
211 ij = i_offset(ii)+jj;
212 kl = i_offset(kk)+ll;
213 val = (ij==kl) ? 0.5*pki_int : pki_int;
224 ij = ij_offset(ii,ll);
225 kl = ij_offset(kk,jj);
226 val = (ij==kl) ? 0.5*pki_int : pki_int;
230 }
else if (ii == kk || jj == ll) {
238 ij = i_offset(ii)+jj;
239 kl = i_offset(kk)+ll;
240 val = (ij==kl) ? 0.5*pki_int : pki_int;
251 ij = ij_offset(ii,kk);
252 kl = ij_offset(jj,ll);
253 val = (ij==kl) ? 0.5*pki_int : pki_int;
263 ij = i_offset(ii)+jj;
264 kl = i_offset(kk)+ll;
265 val = (ij==kl) ? 0.5*pki_int : pki_int;
274 ij = ij_offset(ii,kk);
275 kl = ij_offset(jj,ll);
276 val = (ij==kl) ? 0.5*pki_int : pki_int;
280 if ((ii != jj) && (kk != ll)) {
290 ij = ij_offset(ii,ll);
291 kl = ij_offset(kk,jj);
316 }
else if (ii == kk || jj == ll) {
363 tnint += (double) ni*nj*nk*nl;