mptensor  v0.3.0
Parallel Library for Tensor Network Methods
common.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iomanip>
4 #include <sstream>
5 #include <string>
6 
7 #include <mptensor/mptensor.hpp>
8 
9 using namespace mptensor;
12 
13 #ifdef _NO_MPI
16 #else
19 #endif
20 
21 template <typename tensor>
22 tensor initialize(size_t n) {
23  tensor t(Shape(n, n + 1, n + 2, n + 3));
24  for (size_t i = 0; i < t.local_size(); ++i) {
25  Index idx = t.global_index(i);
26  t[i] = idx[0] + idx[1] * 100 + idx[2] * 10000 + idx[3] * 1000000;
27  }
28  t.transpose({3, 1, 0, 2});
29  return t;
30 }
31 
32 std::string filename(const std::string &prefix, int proc_size) {
33  std::ostringstream ss;
34  ss << prefix << "_mpi";
35  ss << std::setw(4) << std::setfill('0') << proc_size;
36  return ss.str();
37 }
Definition: index.hpp:39
Tensor class. The main object of mptensor.
Definition: tensor.hpp:54
tensor initialize(size_t n)
Definition: common.hpp:22
std::string filename(const std::string &prefix, int proc_size)
Definition: common.hpp:32
Top header file of mptensor.
Tensor< scalapack::Matrix, double > tensor
Definition: atrg.cc:50
Definition: complex.hpp:34
Index Shape
Definition: tensor.hpp:46