/* Copyright (C) 2008 Jiri Pittner or This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include "options.h" //LA #include "vec.h" #include "mat.h" #include "smat.h" #include "nonclass.h" #include "qsort.h" #include "basic.h" #include "gelfand.h" #include "drt.h" inline short int abs(const short int i) {return i>=0 ? i : -i;} int main(int argc, char **argv) { sigtraceback(SIGSEGV,1); sigtraceback(SIGABRT,1); sigtraceback(SIGBUS,1); sigtraceback(SIGFPE,1); print_version(argc,argv,cout); int f; cout.setf(ios::fixed); //cout.setf(ios::scientific); cout.precision(12); REAL threshold=0.; if(argc>2 && !strcmp(argv[1],"-t")) { sscanf(argv[2],"%lf",&threshold); argc -=2; argv+=2; } //sorts -u the ci vector in slater basis with repeatedly generated slater determinants (from mycipc.x) //assumes that the same slaters are generated in the same orbital order (no canonicalization done here) if(argc<6) laerror("civecconsolidate [-t thr] civecin slaterfilein civecout slaterfileout consolidatelistfile < nelec orbnumshift"); int nelec,orbnumshift=0; cin >>nelec>>orbnumshift ; //read ci vector NRMat civec; f=open(argv[1],O_RDONLY|O_LARGEFILE); if(f<0) perror("cannot open file"); civec.get(f,true); close(f); int ncivec=civec.nrows(); lexindex cisize=civec.ncols(); cout <<"number of CI vectors = "< slperm1(cisize); for(lexindex i=0; i civecnew(0.,ncivec,cisize); int maxlist=1; lexindex nlist=1; int alloclist=64; lexindex *list= new lexindex[alloclist]; unsigned int newcisize=0; memcpy(slnew[newcisize],sl1f[slperm1[0]],nelec*sizeof(spinorbindex)); for(int j=0; j=alloclist) { alloclist*=2; lexindex *list2 = new lexindex[alloclist]; memcpy(list2,list,alloclist/2*sizeof(lexindex)); delete[] list; list=list2; } for(int j=0; jmaxlist) maxlist=nlist; nlist=1; list[0]=slperm1[i]; ++newcisize; memcpy(slnew[newcisize],sl1f[slperm1[i]],nelec*sizeof(spinorbindex)); for(int j=0; jmaxlist) maxlist=nlist; if(write(ff,&nlist,sizeof(nlist))!=sizeof(nlist)) laerror("cannot write"); if(write(ff,list,nlist*sizeof(lexindex))!=nlist*sizeof(lexindex)) laerror("cannot write"); cout <<"Output consolidated CI size (before thresholding) = "< omit(newcisize); omit.clear(); unsigned int newcisizethr=0; if(threshold>0.) for(int j=0; j threshold) goto passed; omit[j]=1; --newcisizethr; passed: ; } else newcisizethr=newcisize; cout <<"Output consolidated CI size (after thresholding) = "<0?1:-1; slnew(j,i) = sgn* (abs(slnew(j,i))-orbnumshift); if(abs(slnew(j,i))-orbnumshift <=0) laerror("wrong orbnumshift specified"); } } if(write(f,slnew[j],nelec*sizeof(spinorbindex))!=nelec*sizeof(spinorbindex)) laerror("cannot write"); } close(f); //rewind consolidatelistfile and write newcisize and maxlist if(threshold>0.) { cout <<"consolidatelistfile not reusable with thresholding, removed\n"; close(ff); unlink(argv[5]); } else { cout <<"consolidatelistfile maxlist = "<