You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RAW_File_Stats.cc 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**********************************************************
  2. This software is part of J.-S. Caux's ABACUS library.
  3. Copyright (c) J.-S. Caux.
  4. -----------------------------------------------------------
  5. File: RAW_File_stats.cc
  6. Purpose: Analyzes the distribution of matrix element values in a RAW file,
  7. to help with optimization of the scanning procedure.
  8. ***********************************************************/
  9. #include "ABACUS.h"
  10. using namespace std;
  11. using namespace ABACUS;
  12. int main(int argc, char* argv[])
  13. {
  14. if (argc != 3) { // provide some info
  15. cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
  16. cout << endl << "Usage of RAW_File_Stats executable: " << endl;
  17. cout << endl << "Provide the following arguments:" << endl << endl;
  18. cout << endl << "string RAW file name" << endl;
  19. cout << "int Aggregate size" << endl;
  20. }
  21. else { // correct nr of arguments
  22. const char* rawfilename = argv[1];
  23. int AgSize = atoi(argv[2]);
  24. if (AgSize < 2) ABACUSerror("Give an aggregate size > 1 in LiebLin_RAW_File_Stats.");
  25. ifstream RAW_infile;
  26. RAW_infile.open(rawfilename);
  27. if (RAW_infile.fail()) {
  28. cout << rawfilename << endl;
  29. ABACUSerror("Could not open RAW_infile... ");
  30. }
  31. stringstream STAT_stringstream; string STAT_string;
  32. STAT_stringstream << rawfilename << "_AgS_" << AgSize << "_stat";
  33. STAT_string = STAT_stringstream.str(); const char* STAT_Cstr = STAT_string.c_str();
  34. ofstream STATfile;
  35. STATfile.open(STAT_Cstr);
  36. if (STATfile.fail()) {
  37. cout << STAT_Cstr << endl; ABACUSerror("Could not open STATfile.");
  38. }
  39. DP omega;
  40. int iK;
  41. DP ME;
  42. DP dev;
  43. string label;
  44. int nread = 0;
  45. DP srcont = 0.0;
  46. DP abssrcont = 0.0;
  47. DP maxsrcont = 0.0;
  48. DP totsrcont = 0.0;
  49. DP accumulatedsrcont = 0.0;
  50. int naccounted = 0;
  51. while (RAW_infile.peek() != EOF) {
  52. RAW_infile >> omega >> iK >> ME >> dev >> label;
  53. nread++;
  54. srcont = ME * ME;
  55. abssrcont = fabs(srcont);
  56. maxsrcont = ABACUS::max(maxsrcont, abssrcont);
  57. totsrcont += srcont;
  58. accumulatedsrcont += srcont;
  59. naccounted++;
  60. if (naccounted >= AgSize) {
  61. STATfile << nread << "\t" << maxsrcont << "\t" << totsrcont/AgSize << "\t" << totsrcont/(AgSize * (maxsrcont > 0.0 ? maxsrcont : 1.0)) << "\t" << accumulatedsrcont << endl;
  62. naccounted = 0;
  63. maxsrcont = 0.0;
  64. totsrcont = 0.0;
  65. }
  66. }
  67. RAW_infile.close();
  68. STATfile.close();
  69. }
  70. return(0);
  71. }