/********************************************************** This software is part of J.-S. Caux's ABACUS library. Copyright (c) J.-S. Caux. ----------------------------------------------------------- File: RAW_File_stats.cc Purpose: Analyzes the distribution of matrix element values in a RAW file, to help with optimization of the scanning procedure. ***********************************************************/ #include "ABACUS.h" using namespace std; using namespace ABACUS; int main(int argc, char* argv[]) { if (argc != 3) { // provide some info cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl; cout << endl << "Usage of RAW_File_Stats executable: " << endl; cout << endl << "Provide the following arguments:" << endl << endl; cout << endl << "string RAW file name" << endl; cout << "int Aggregate size" << endl; } else { // correct nr of arguments const char* rawfilename = argv[1]; int AgSize = atoi(argv[2]); if (AgSize < 2) ABACUSerror("Give an aggregate size > 1 in LiebLin_RAW_File_Stats."); ifstream RAW_infile; RAW_infile.open(rawfilename); if (RAW_infile.fail()) { cout << rawfilename << endl; ABACUSerror("Could not open RAW_infile... "); } stringstream STAT_stringstream; string STAT_string; STAT_stringstream << rawfilename << "_AgS_" << AgSize << "_stat"; STAT_string = STAT_stringstream.str(); const char* STAT_Cstr = STAT_string.c_str(); ofstream STATfile; STATfile.open(STAT_Cstr); if (STATfile.fail()) { cout << STAT_Cstr << endl; ABACUSerror("Could not open STATfile."); } DP omega; int iK; DP ME; DP dev; string label; int nread = 0; DP srcont = 0.0; DP abssrcont = 0.0; DP maxsrcont = 0.0; DP totsrcont = 0.0; DP accumulatedsrcont = 0.0; int naccounted = 0; while (RAW_infile.peek() != EOF) { RAW_infile >> omega >> iK >> ME >> dev >> label; nread++; srcont = ME * ME; abssrcont = fabs(srcont); maxsrcont = ABACUS::max(maxsrcont, abssrcont); totsrcont += srcont; accumulatedsrcont += srcont; naccounted++; if (naccounted >= AgSize) { STATfile << nread << "\t" << maxsrcont << "\t" << totsrcont/AgSize << "\t" << totsrcont/(AgSize * (maxsrcont > 0.0 ? maxsrcont : 1.0)) << "\t" << accumulatedsrcont << endl; naccounted = 0; maxsrcont = 0.0; totsrcont = 0.0; } } RAW_infile.close(); STATfile.close(); } return(0); }