29 #ifndef _MPTENSOR_SAVE_HPP_
30 #define _MPTENSOR_SAVE_HPP_
52 template <
template <
typename>
class Matrix,
typename C>
55 if (get_comm_rank() == 0) {
59 fout <<
"matrix_type= " << Matrix<C>::matrix_type_tag;
60 fout <<
" (" << Matrix<C>::matrix_type_name <<
")\n";
61 fout <<
"value_type= " << value_type_tag<C>();
62 fout <<
" (" << value_type_name<C>() <<
")\n";
63 fout <<
"comm_size= " << get_comm_size() <<
"\n";
64 fout <<
"ndim= " << n <<
"\n";
65 fout <<
"upper_rank= " << upper_rank <<
"\n";
68 for (
size_t i = 0; i < n; ++i) fout <<
" " << Dim[i];
72 for (
size_t i = 0; i < n; ++i) fout <<
" " << axes_map[i];
81 std::ofstream::binary);
82 fout.write(
reinterpret_cast<const char *
>(get_matrix().head()),
83 sizeof(C) * local_size());
89 std::string indexfile;
91 get_matrix().save_index(indexfile.c_str());
105 template <
template <
typename>
class Matrix,
typename C>
110 if (get_comm_rank() == 0) {
113 fout << n <<
"\n" << upper_rank <<
"\n";
114 for (
size_t i = 0; i < n - 1; ++i) fout << Dim[i] <<
" ";
115 fout << Dim[n - 1] <<
"\n";
116 for (
size_t i = 0; i < n - 1; ++i) fout << axes_map[i] <<
" ";
117 fout << axes_map[n - 1] <<
"\n";
123 char *datafile =
new char[std::strlen(
filename) + 16];
124 sprintf(datafile,
"%s.%04d",
filename, get_comm_rank());
127 std::ofstream fout(datafile, std::ofstream::binary);
128 fout.write(
reinterpret_cast<const char *
>(get_matrix().head()),
129 sizeof(C) * local_size());
Tensor class. The main object of mptensor.
Definition: tensor.hpp:54
void save(const std::string &filename) const
Save a tensor to files.
Definition: save.hpp:53
std::string filename(const std::string &prefix, int proc_size)
Definition: common.hpp:32
Header file of helper functions for file io.
List of header files for matrix classes.
std::string index_filename(const std::string &prefix, int comm_rank)
Definition: io_helper.hpp:57
std::string binary_filename(const std::string &prefix, int comm_rank)
Definition: io_helper.hpp:49
Definition: complex.hpp:34
#define MPTENSOR_VERSION_STRING
Definition: version.hpp:35