53 template <
template <
typename>
class Matrix,
typename C>
89 size_t &local_idx)
const;
97 void print_info(std::ostream &out,
const std::string &tag =
"")
const;
98 void print_info_mpi(std::ostream &,
const std::string &tag =
"")
const;
105 template <
typename D>
107 template <
typename D0,
typename D1>
110 const std::vector<D1> &vec1,
112 template <
typename D0,
typename D1,
typename D2>
114 const std::vector<D0> &vec0,
size_t n_axes0,
const std::vector<D1> &vec1,
115 size_t n_axes1,
const std::vector<D2> &vec2,
size_t n_axes2);
116 template <
typename D0,
typename D1,
typename D2,
typename D3>
118 const std::vector<D0> &vec0,
size_t n_axes0,
const std::vector<D1> &vec1,
119 size_t n_axes1,
const std::vector<D2> &vec2,
size_t n_axes2,
120 const std::vector<D3> &vec3,
size_t n_axes3);
125 const Index &index_end);
136 template <
typename UnaryOperation>
145 size_t index_new[])
const;
148 size_t &local_idx)
const;
164 void init(
const Shape &,
size_t upper_rank);
165 void init(
const Shape &,
size_t upper_rank,
const Axes &
map);
166 void change_configuration(
const size_t new_upper_rank,
167 const Axes &new_axes_map);
168 bool local_index(
const Index &,
size_t &i)
const;
170 mutable std::vector<size_t> l2g_map_row;
171 mutable std::vector<size_t> l2g_map_col;
173 void save_ver_0_2(
const char *
filename)
const;
174 void load_ver_0_2(
const char *
filename);
180 template <
template <
typename>
class Matrix,
typename C>
182 template <
template <
typename>
class Matrix,
typename C>
185 template <
template <
typename>
class Matrix,
typename C>
187 template <
template <
typename>
class Matrix,
typename C>
189 size_t i_begin,
size_t i_end);
190 template <
template <
typename>
class Matrix,
typename C>
192 const Index &index_end);
193 template <
template <
typename>
class Matrix,
typename C>
199 template <
template <
typename>
class Matrix,
typename C>
201 template <
template <
typename>
class Matrix,
typename C>
203 template <
template <
typename>
class Matrix,
typename C>
205 const Axes &axes_a,
const Axes &axes_b);
206 template <
template <
typename>
class Matrix,
typename C>
209 template <
template <
typename>
class Matrix,
typename C>
213 template <
template <
typename>
class Matrix,
typename C>
220 template <
template <
typename>
class Matrix,
typename C>
222 template <
template <
typename>
class Matrix,
typename C>
225 template <
template <
typename>
class Matrix,
typename C>
227 std::vector<double> &s);
228 template <
template <
typename>
class Matrix,
typename C>
232 template <
template <
typename>
class Matrix,
typename C>
234 const size_t target_rank);
235 template <
template <
typename>
class Matrix,
typename C>
238 const size_t target_rank);
239 template <
template <
typename>
class Matrix,
typename C>
241 std::vector<double> &s,
const size_t target_rank);
242 template <
template <
typename>
class Matrix,
typename C>
245 const size_t target_rank);
247 template <
template <
typename>
class Matrix,
typename C>
249 template <
template <
typename>
class Matrix,
typename C>
253 template <
template <
typename>
class Matrix,
typename C>
256 template <
template <
typename>
class Matrix,
typename C>
258 template <
template <
typename>
class Matrix,
typename C>
261 template <
template <
typename>
class Matrix,
typename C>
263 std::vector<double> &eigval);
264 template <
template <
typename>
class Matrix,
typename C>
267 const Axes &axes_row_b,
const Axes &axes_col_b,
271 template <
template <
typename>
class Matrix,
typename C>
274 template <
template <
typename>
class Matrix,
typename C>
276 template <
template <
typename>
class Matrix,
typename C>
279 template <
template <
typename>
class Matrix,
typename C>
281 std::vector<complex> &eigval);
286 template <
template <
typename>
class Matrix,
typename C>
289 template <
template <
typename>
class Matrix,
typename C>
292 template <
template <
typename>
class Matrix,
typename C>
295 const Axes &axes_row_b,
const Axes &axes_col_b);
300 template <
template <
typename>
class Matrix,
typename C>
302 template <
template <
typename>
class Matrix,
typename C>
304 template <
template <
typename>
class Matrix,
typename C>
307 template <
template <
typename>
class Matrix,
typename C>
310 template <
template <
typename>
class Matrix,
typename C,
typename D>
312 template <
template <
typename>
class Matrix,
typename C,
typename D>
314 template <
template <
typename>
class Matrix,
typename C,
typename D>
320 template <
template <
typename>
class Matrix,
typename C>
323 template <
template <
typename>
class Matrix,
typename C>
327 template <
template <
typename>
class Matrix,
typename C>
329 template <
template <
typename>
class Matrix,
typename C>
331 template <
template <
typename>
class Matrix,
typename C>
333 template <
template <
typename>
class Matrix,
typename C>
339 template <
template <
typename>
class Matrix,
typename C>
Tensor class. The main object of mptensor.
Definition: tensor.hpp:54
void set_value(const Index &idx, C val)
Set an element.
Definition: tensor_impl.hpp:570
void print_info(std::ostream &out, const std::string &tag="") const
Output information of tensor.
Definition: tensor_impl.hpp:424
size_t rank() const
Rank of tensor.
Definition: tensor_impl.hpp:164
void global_index_fast(size_t i, Index &idx) const
Convert local index to global index fast.
Definition: tensor_impl.hpp:525
void print_info_mpi(std::ostream &, const std::string &tag="") const
Output information of tensor.
Definition: tensor_impl.hpp:442
size_t ndim() const
Rank of tensor.
Definition: tensor_impl.hpp:173
void load(const std::string &filename)
Load a tensor from files.
Definition: load.hpp:53
void prep_local_to_global() const
Preprocess for fast conversion from local index to global one.
Definition: tensor_impl.hpp:258
Tensor< Matrix, C > & operator/=(C rhs)
Scalar-division assignment.
Definition: tensor_impl.hpp:1006
void local_position_fast(size_t g_row, size_t g_col, int &comm_rank, size_t &local_idx) const
Definition: tensor_impl.hpp:376
Tensor< Matrix, C > & map(UnaryOperation op)
Apply a unary operation to each element.
Definition: tensor_impl.hpp:1026
void prep_global_to_local() const
Preprocess for fast conversion from global index to local one.
Definition: tensor_impl.hpp:252
const Matrix< C > & get_matrix() const
distributed Matrix
Definition: tensor_impl.hpp:203
Tensor< Matrix, C > & set_slice(const Tensor &a, size_t n_axes, size_t i_begin, size_t i_end)
Inverse of slice().
Definition: tensor_impl.hpp:846
void local_position(const Index &idx, int &comm_rank, size_t &local_idx) const
Calculate rank which has the given global index and its local index.
Definition: tensor_impl.hpp:584
Tensor< Matrix, C > & operator=(C rhs)
Initialize all elements by rhs.
Definition: tensor_impl.hpp:1013
C value_type
double or complex
Definition: tensor.hpp:56
Tensor< lapack::Matrix, C > gather()
Gather all elements into a non-distributed tensor.
Definition: tensor_impl.hpp:955
void make_l2g_map() const
Preprocess for fast conversion from local index to global one.
Definition: tensor_impl.hpp:264
size_t local_size() const
Size of local storage.
Definition: tensor_impl.hpp:179
void global_index_l2g_map(size_t lindex, size_t gindex[]) const
Convert local index to global index using l2g_map.
Definition: tensor_impl.hpp:320
std::vector< C > flatten()
Return a copy of the flattened vector.
Definition: tensor_impl.hpp:971
int get_comm_rank() const
Rank of process.
Definition: tensor_impl.hpp:228
Tensor< Matrix, C > & multiply_vector(const std::vector< D > &vec, size_t n_axes)
Element-wise vector multiplication.
Definition: tensor_impl.hpp:700
int get_comm_size() const
Size of communicator.
Definition: tensor_impl.hpp:222
Tensor< Matrix, C > & operator*=(C rhs)
Scalar-multiplication assignment.
Definition: tensor_impl.hpp:999
const Axes & get_axes_map() const
Map of axes for lazy evaluation of transpose.
Definition: tensor_impl.hpp:197
Index global_index(size_t i) const
Convert local index to global index.
Definition: tensor_impl.hpp:495
const comm_type & get_comm() const
Communicator.
Definition: tensor_impl.hpp:216
Tensor< Matrix, C > & transpose(const Axes &axes)
Transposition of tensor with lazy evaluation.
Definition: tensor_impl.hpp:667
Matrix< C >::comm_type comm_type
type of communicator.
Definition: tensor.hpp:58
const Shape & shape() const
Shape of tensor.
Definition: tensor_impl.hpp:158
Tensor< Matrix, C > & operator-=(const Tensor &rhs)
Subtraction assignment.
Definition: tensor_impl.hpp:990
size_t get_upper_rank() const
Upper rank for matrix representation.
Definition: tensor_impl.hpp:185
Tensor< Matrix, C > & operator+=(const Tensor &rhs)
Addition assignment.
Definition: tensor_impl.hpp:981
void save(const std::string &filename) const
Save a tensor to files.
Definition: save.hpp:53
void global_index_l2g_map_transpose(size_t lindex, const size_t axes_trans[], size_t index_new[]) const
Convert local index to global index of transposed tensor using l2g_map.
Definition: tensor_impl.hpp:353
Matrix< C > matrix_type
type of Matrix class
Definition: tensor.hpp:57
const C & operator[](size_t local_idx) const
Const array subscript operator.
Definition: tensor_impl.hpp:237
bool get_value(const Index &idx, C &val) const
Get an element.
Definition: tensor_impl.hpp:552
std::string filename(const std::string &prefix, int proc_size)
Definition: common.hpp:32
Define the type of a complex number.
Tensor< Matrix, C > operator*(Tensor< Matrix, C > lhs, D rhs)
Tensor-scalar multiplication.
Definition: tensor_impl.hpp:2579
Tensor< Matrix, C > operator-(Tensor< Matrix, C > rhs)
Unary minus.
Definition: tensor_impl.hpp:2562
Tensor< Matrix, C > operator/(Tensor< Matrix, C > lhs, D rhs)
Scalar division.
Definition: tensor_impl.hpp:2584
int eig(const Tensor< Matrix, C > &a, std::vector< complex > &eigval, Tensor< Matrix, complex > &eigvec)
Compute the eigenvalues and eigenvectors of a general matrix (rank-2 tensor)
Definition: tensor_impl.hpp:2295
int svd(const Tensor< Matrix, C > &a, std::vector< double > &s)
Singular value decomposition for rank-2 tensor (matrix)
Definition: tensor_impl.hpp:1722
int eigh(const Tensor< Matrix, C > &a, std::vector< double > &eigval, Tensor< Matrix, C > &eigvec)
Definition: tensor_impl.hpp:2071
int qr(const Tensor< Matrix, C > &a, Tensor< Matrix, C > &q, Tensor< Matrix, C > &r)
QR decomposition of matrix (rank-2 tensor)
Definition: tensor_impl.hpp:1974
int psvd(const Tensor< Matrix, C > &a, std::vector< double > &s, const size_t target_rank)
Partial SVD for rank-2 tensor (matrix)
Definition: tensor_impl.hpp:1866
Tensor< Matrix, C > tensordot(const Tensor< Matrix, C > &a, const Tensor< Matrix, C > &b, const Axes &axes_a, const Axes &axes_b)
Compute tensor dot product.
Definition: tensor_impl.hpp:1648
Tensor< Matrix, C > contract(const Tensor< Matrix, C > &a, const Axes &axes_1, const Axes &axes_2)
Partial trace of tensor.
Definition: tensor_impl.hpp:1519
Tensor< Matrix, C > kron(const Tensor< Matrix, C > &a, const Tensor< Matrix, C > &b)
Compute the Kronecker product.
Definition: tensor_impl.hpp:1612
C trace(const Tensor< Matrix, C > &a)
Trace of matrix (rank-2 tensor)
Definition: tensor_impl.hpp:1409
int solve(const Tensor< Matrix, C > &a, const std::vector< C > &b, std::vector< C > &x)
Solve linear equation .
Definition: tensor_impl.hpp:2447
double max(const Tensor< Matrix, C > &t)
Return the maximum element. For complex, same as max_abs().
Definition: tensor_impl.hpp:2595
double min_abs(const Tensor< Matrix, C > &t)
Return minimum of the absolute value of an element.
Definition: tensor_impl.hpp:2610
Tensor< Matrix, C > sqrt(Tensor< Matrix, C > t)
Take square-root of each element.
Tensor< Matrix, C > conj(Tensor< Matrix, C > t)
Take conjugate of each element.
double max_abs(const Tensor< Matrix, C > &t)
Return maximum of the absolute value of an element.
Definition: tensor_impl.hpp:2605
double min(const Tensor< Matrix, C > &t)
Return the minimum element. For complex, same as min_abs().
Definition: tensor_impl.hpp:2600
Tensor< Matrix, C > transpose(Tensor< Matrix, C > a, const Axes &axes)
Transposition of tensor with lazy evaluation.
Definition: tensor_impl.hpp:1041
Tensor< Matrix, C > slice(const Tensor< Matrix, C > &a, size_t n_axes, size_t i_begin, size_t i_end)
Slice a tensor.
Definition: tensor_impl.hpp:1215
Tensor< Matrix, C > reshape(const Tensor< Matrix, C > &a, const Shape &shape_new)
Change the shape of tensor.
Definition: tensor_impl.hpp:1149
Tensor< Matrix, C > extend(const Tensor< Matrix, C > &a, const Shape &shape_new)
Extend the size of a tensor.
Definition: tensor_impl.hpp:1363
Tensor()
Default constructor of tensor.
Definition: tensor_impl.hpp:70
header file of Index class
Header file of load function.
List of header files for matrix classes.
Definition: complex.hpp:34
Index Shape
Definition: tensor.hpp:46
std::ostream & operator<<(std::ostream &os, const Index &idx)
Index Axes
Definition: tensor.hpp:45
Index operator+(const Index &, const Index &)
Implementation of tensor class.