7#define IZ(x) int x = 0;
8#define SZ(x) std::size_t x = 0;
12 using TC = std::array<int, 3>;
13 using TAC = std::pair<int, TC>;
15 using TLRI = std::map<int, std::map<TAC, RI::Tensor<T>>>;;
21 for (
int i = 0;i < t.get_shape_all();++i)
23 double v = std::abs(std::norm(t.ptr()[i]));
24 if (v > res) { res = v; }
26 return std::sqrt(res);
35 infile.open(file_path);
36 infile >> natom >> ncell;
39 while (infile.peek() != EOF)
41 infile >> ia1 >> ia2 >> ic_1 >> ic_2 >> ic_3 >> nw1 >> nw2 >> nabf;
42 const TC& box = { ic_1, ic_2, ic_3 };
44 for (std::size_t i = 0; i != nw1; i++) {
45 for (std::size_t j = 0; j != nw2; j++) {
46 for (std::size_t mu = 0; mu != nabf; mu++) {
47 infile >> tensor_cs(mu, i, j);
52 if (
absmax(tensor_cs) >=
threshold) { Cs[ia1 - 1][{ia2 - 1, box}] = tensor_cs; }
61 std::ofstream outfile;
62 outfile.open(file_path);
65 outfile <<
" Empty Cs " << std::endl;
69 outfile << Cs.size() <<
" " << Cs.begin()->second.size() / Cs.size() << std::endl;
72 const int& ia1 = it1.first;
73 for (
auto& it2 : it1.second)
75 const int& ia2 = it2.first.first;
76 const auto& box = it2.first.second;
77 const auto& tensor_cs = it2.second;
78 outfile << ia1 + 1 <<
" " << ia2 + 1 <<
" " << box[0] <<
" " << box[1] <<
" " << box[2] << std::endl;
79 const int& nw1 = tensor_cs.shape[1], nw2 = tensor_cs.shape[2], nabf = tensor_cs.shape[0];
80 outfile << nw1 <<
" " << nw2 <<
" " << nabf << std::endl;
81 for (
int i = 0; i != nw1; i++)
83 for (
int j = 0; j != nw2; j++)
85 for (
int mu = 0; mu != nabf; mu++) { outfile << tensor_cs(mu, i, j) <<
" "; }
103 dir = opendir(path.c_str());
104 while ((ptr = readdir(dir)) != NULL){
105 std::string fm(ptr->d_name);
106 if (fm.find(
"Cs_data_") == 0)
109 std::ifstream infile(path + fm);
110 infile >> natom >> ncell;
112 while (infile.peek() != EOF)
114 if(!(infile >> ia1 >> ia2 >> ic_1 >> ic_2 >> ic_3 >> nw1 >> nw2 >> nabf)){
break;}
115 const TC& box = { ic_1, ic_2, ic_3 };
117 for (std::size_t i = 0; i != nw1; i++) {
118 for (std::size_t j = 0; j != nw2; j++) {
119 for (std::size_t mu = 0; mu != nabf; mu++) {
120 infile >> tensor_cs(mu, i, j);
125 if (
absmax(tensor_cs) >=
threshold) { Cs[ia1 - 1][{ia2 - 1, box}] = tensor_cs; }
140 std::ifstream infile;
141 infile.open(file_path);
142 infile >> natom >> ncell;
145 while (infile.peek() != EOF)
147 infile >> ia1 >> ia2 >> ic_1 >> ic_2 >> ic_3 >> nabf1 >> nabf2;
148 const TC& box = { ic_1, ic_2, ic_3 };
150 for (std::size_t i = 0; i != nabf1; i++) {
151 for (std::size_t j = 0; j != nabf2; j++){ infile >> tensor_vs(i, j);}
153 if (
absmax(tensor_vs) >=
threshold) { Vs[ia1 - 1][{ia2 - 1, box}] = tensor_vs; }
160 template <
typename T>
163 std::ofstream outfile;
164 outfile.open(file_path);
167 outfile <<
" Empty Vs " << std::endl;
171 outfile << Vs.size() <<
" " << Vs.begin()->second.size() / Vs.size() << std::endl;
172 for (
const auto& it1 : Vs)
174 const int& ia1 = it1.first;
175 for (
const auto& it2 : it1.second)
177 const int& ia2 = it2.first.first;
178 const auto& box = it2.first.second;
179 const auto& tensor_v = it2.second;
180 outfile << ia1 + 1 <<
" " << ia2 + 1 <<
" " << box[0] <<
" " << box[1] <<
" " << box[2] << std::endl;
181 outfile << tensor_v.shape[0] <<
" " << tensor_v.shape[1] << std::endl;
182 for (
int i = 0; i != tensor_v.shape[0]; i++)
184 for (
int j = 0; j != tensor_v.shape[1]; j++) {outfile << tensor_v(i, j) <<
" ";}
185 outfile << std::endl;
Definition rpa_lri_coeff_v1.h:11
std::ofstream ofs_running
Definition global_variable.cpp:38
void DONE(std::ofstream &ofs, const std::string &description, const bool only_rank0)
Definition global_function.cpp:78
void TITLE(const std::string &class_name, const std::string &function_name, const bool disable)
Definition tool_title.cpp:18
#define threshold
Definition sph_bessel_rec_test.cpp:4
std::array< int, 3 > TC
Definition test_write_ri_cv.cpp:9
std::pair< int, TC > TAC
Definition test_write_ri_cv.cpp:10
std::map< int, std::map< TAC, RI::Tensor< T > > > TLRI
Definition test_write_ri_cv.cpp:12
#define SZ(x)
Definition write_ri_cv.hpp:8
#define IZ(x)
Definition write_ri_cv.hpp:7