/* 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" static spinorbindex *spinorb_begin; static int spinorb_compare(const int i, const int j) { int xx=spinorb_begin[i]<0? -2*spinorb_begin[i]-1:2*spinorb_begin[i]-2; int yy=spinorb_begin[j]<0? -2*spinorb_begin[j]-1:2*spinorb_begin[j]-2; return xx-yy; } static void spinorb_swap(const int i, const int j) { spinorbindex t; t=spinorb_begin[i]; spinorb_begin[i]=spinorb_begin[j]; spinorb_begin[j]=t; } void canonicalize(slaterbasis &sl, NRMat &ci) { sl.copyonwrite(); ci.copyonwrite(); if(sl.nrows()!=ci.ncols()) laerror("inconsistent ci size in canonicalize"); lexindex cisize=ci.ncols(); int nelec=sl.ncols(); int nci=ci.nrows(); //put the spinorbitals in the order 1 -1 2 -2 ... for(lexindex l=0; l=2 && !strcmp(argv[1],"-f")) { flip1=1; ++argv; --argc; } if(argc>=2 && !strcmp(argv[1],"-g")) { flip2=1; ++argv; --argc; } } if(argc<5) laerror("civeccompare [-f] [-g] civec1 slaterfile1 civec2 slaterfile2 >freeze1 >>freeze2 >>nelec >>thres; //read ci vectors NRMat civec1,civec2; f=open(argv[1],O_RDONLY|O_LARGEFILE); if(f<0) perror("cannot open file"); civec1.get(f,true); close(f); f=open(argv[3],O_RDONLY|O_LARGEFILE); if(f<0) perror("cannot open file"); civec2.get(f,true); close(f); int ncivec=min(civec1.nrows(),civec2.nrows()); if(civec1.ncols()!=civec2.ncols()) laerror("ci vector length mismatch"); lexindex cisize=civec1.ncols(); //read slaterfiles int nelec1=2*freeze1+nelec; int nelec2=2*freeze2+nelec; slaterbasis sl1(cisize,nelec1),sl2(cisize,nelec2); f=open(argv[2],O_RDONLY|O_LARGEFILE); if(f<0) perror("cannot open file"); sl1.get(f,false); if(sl1.checkzero()) laerror("malformed slaterfile encountered, perhaps cipc/mcpc was compiled without --assume byterecl"); if(flip1) sl1 *= -1; close(f); f=open(argv[4],O_RDONLY|O_LARGEFILE); if(f<0) perror("cannot open file"); sl2.get(f,false); if(sl2.checkzero()) laerror("malformed slaterfile encountered, perhaps cipc/mcpc was compiled without --assume byterecl"); if(flip2) sl2 *= -1; close(f); //perform freezing first canonicalize(sl1,civec1); canonicalize(sl2,civec2); slaterbasis sl1f(cisize,nelec),sl2f(cisize,nelec); for(lexindex l=0; l0?t-freeze1:t+freeze1; t=sl2(l,2*freeze2+i); sl2f(l,i)=t>0?t-freeze2:t+freeze2; } } //free memory sl1.resize(0,0); sl2.resize(0,0); //reorder slater basis and ci vectors to common order canonicalize(sl1f,civec1); canonicalize(sl2f,civec2); NRVec slperm1(cisize); for(lexindex i=0; i slperm2(cisize); for(lexindex i=0; i civec1s(ncivec,cisize); NRMat civec2s(ncivec,cisize); //apply permutation slaterbasis sl1fs(cisize,nelec),sl2fs(cisize,nelec); for(lexindex i=0; i amax) { lm=l; amax=t; } if(civec1s(i,lm)*civec2s(i,lm)<0) { for(lexindex l=0; l thres && abs(civec2s(i,l)) > thres) { if(civec1s(i,l)*civec2s(i,l)<0) ++ndev; } if((t=abs(civec1s(i,l)-civec2s(i,l))) >maxdev) maxdev=t; u+=t; } if(ndev) cout <<"number of deviations>thr in CI vector "<thres) cout<< " DIFFERENCE "<