StatMech
Loading...
Searching...
No Matches
constructGlobal_h.cpp File Reference

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)
11 {
12 if(argc != 6) {
13 std::cerr << "Usage: constructGlobal_h 1.N 2.Momentum 3.Type 4.Param 5.InputFile for matLoc"
14 << std::endl;
15 std::exit(EX_USAGE);
16 }
17 Integer_t N = (Integer_t)std::atoi(argv[1]);
18 Integer_t momentum = (Integer_t)std::atoi(argv[2]);
19
20 char* initStr[9];
21 initStr[1] = argv[1];
22 initStr[2] = argv[1];
23 initStr[7] = argv[3];
24 initStr[8] = argv[4];
25 Initialize(9, (char**)initStr);
26
27 std::string InFName(argv[5]);
28 std::ifstream Infs(InFName);
29 Infs.exceptions(std::ios::badbit);
30 if(!Infs.is_open()) {
31 std::cerr << "Can't open a file \"" << InFName << "\"" << std::endl;
32 std::exit(EX_NOINPUT);
33 }
34 try {
35 skip_header(Infs);
36 }
37 catch(std::exception& e) {
38 std::cerr << "Error(skip_header): " << e.what() << std::endl;
39 std::cerr << "File: \"" << InFName << "\" is empty." << std::endl;
40 std::exit(EX_NOINPUT);
41 }
42 Infs.exceptions(std::ifstream::badbit);
43
44 std::cout << "########## Input ##########" << std::endl;
45 bool dimLocFlag = false, numLocFlag = false;
46 Integer_t dimLoc = 0, numLoc = 0, dimLocMat = 0;
47 matrix<Complex_t<double>> matLoc;
48 std::string str;
49 std::stringstream ss;
50 auto oldPos = Infs.tellg();
51 while(std::getline(Infs, str)) {
52 ss.str(str);
53 ss.clear(std::stringstream::goodbit);
54 ss >> str;
55 if(str.find("dimLoc") != std::string::npos) {
56 ss >> str;
57 dimLoc = std::atoi(str.c_str());
58 dimLocFlag = true;
59 }
60 else if(str.find("numLoc") != std::string::npos) {
61 ss >> str;
62 numLoc = std::atoi(str.c_str());
63 numLocFlag = true;
64 }
65 else if(str.find("mat") != std::string::npos) {
66 if(dimLocFlag && numLocFlag != true) {
67 std::cerr << "Error: Invalid data format." << std::endl;
68 std::exit(EX_DATAERR);
69 }
70 dimLocMat = pow(dimLoc, numLoc);
71 Infs.seekg(oldPos);
72 std::cout << "dimLocMat=" << dimLocMat << std::endl;
73 matLoc.resize(dimLocMat, dimLocMat);
74 readMatrix(Infs, dimLocMat, matLoc);
75 std::cout << "matLoc:" << std::endl;
76 matLoc.print(dimLocMat, dimLocMat);
77 }
78 oldPos = Infs.tellg();
79 }
80
82 Sector.initialize(N, momentum, dimLoc);
83
84 std::cout << "########## Output ##########" << std::endl;
85 matrix<Complex_t<double>> matTot(Sector.dim(), Sector.dim());
86 constructGlobal_h(matTot, matLoc, numLoc, Sector);
87
88 std::cout << "# After constructGlobal_h" << std::endl;
89 std::cout << "matTot:" << std::endl;
90 matTot.print(Sector.dim(), Sector.dim());
91
92 return 0;
93}
std::vector< TransSector > Sector(n_max+1)
Translation invariant sector of a many-body Hilbert space.
Definition TransSector.hpp:19
MKL_INT Integer_t
Definition mytypes.hpp:359