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

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)
11 {
12 if(argc < 2) {
13 std::cerr << "Usage: 1.This 2.Matrix file (opt1).UPLO" << std::endl;
14 std::exit(EX_USAGE);
15 }
16 std::string InFilename(argv[1]);
17 std::ifstream InFile(InFilename); checkIsFileOpen(InFile, InFilename);
18 debug_print("Input: " << InFilename);
19
20 matrix<Complex_t<double>> mat;
21 auto [dim1, dim2, inUPLO] = readMatrix(InFile, mat); InFile.close();
22 if(dim1 != dim2) {
23 std::cerr << "Error: dim1(" << dim1 <<") != dim2(" << dim2 << ")" << std::endl;
24 std::exit(EX_USAGE);
25 }
26
27 debug_print(inUPLO);
28 for(int i = 0;i < dim1; ++i) mat.at(i,i) = real(mat.at(i,i));
29 if(inUPLO=="Upper") {
30 #pragma omp parallel for schedule(dynamic, 1)
31 for(int i = 0;i < dim1; ++i) for(int j = 0;j < i; ++j) mat.at(i,j) = conj(mat.at(j,i));
32 } else if (inUPLO=="Lower") {
33 #pragma omp parallel for schedule(dynamic, 1)
34 for(int i = 0;i < dim1; ++i) for(int j = i+1;j < dim1; ++j) mat.at(i,j) = conj(mat.at(j,i));
35 } else {
36 #pragma omp parallel for schedule(dynamic, 1)
37 for(Integer_t i = 0;i < dim1; ++i) for(Integer_t j = i+1;j < dim1; ++j) {
38 mat.at(i,j) = ( mat.at(i,j) + conj(mat.at(j,i)) )/2.0;
39 mat.at(j,i) = conj(mat.at(i,j));
40 }
41 }
42
43 std::string outUPLO(argc>=3 ? argv[2]: "All");
44 std::cout << std::scientific; mat.print(std::cout, dim1, dim2, outUPLO);
45
46 return 0;
47}
bool checkIsFileOpen(std::ifstream &file, std::string const &filename)
Definition file_util.hpp:22
debug_print("# Determining GPU configuration.")
MKL_INT Integer_t
Definition mytypes.hpp:359