mptensor  v0.3.0
Parallel Library for Tensor Network Methods
Loading...
Searching...
No Matches
common.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <iomanip>
4#include <sstream>
5#include <string>
6
8
9using namespace mptensor;
12
13#ifdef _NO_MPI
16#else
19#endif
20
21template <typename tensor>
22tensor 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
32std::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< lapack::Matrix, double > sdtensor
Definition common.hpp:10
Tensor< lapack::Matrix, complex > sztensor
Definition common.hpp:11
Tensor< scalapack::Matrix, complex > pztensor
Definition common.hpp:18
tensor initialize(size_t n)
Definition common.hpp:22
std::string filename(const std::string &prefix, int proc_size)
Definition common.hpp:32
std::complex< double > complex
Definition complex.hpp:38
Top header file of mptensor.
Definition complex.hpp:34
Index Shape
Definition tensor.hpp:46