53template <
typename MatrixType>
107 template <
typename D>
109 template <
typename D0,
typename D1>
112 const std::vector<D1> &
vec1,
114 template <
typename D0,
typename D1,
typename D2>
116 const std::vector<D0> &
vec0,
size_t n_axes0,
const std::vector<D1> &
vec1,
118 template <
typename D0,
typename D1,
typename D2,
typename D3>
120 const std::vector<D0> &
vec0,
size_t n_axes0,
const std::vector<D1> &
vec1,
130 std::vector<value_type>
flatten();
138 template <
typename UnaryOperation>
166 void init(
const Shape &,
size_t upper_rank);
167 void init(
const Shape &,
size_t upper_rank,
const Axes &
map);
170 bool local_index(
const Index &,
size_t &
i)
const;
172 mutable std::vector<size_t> l2g_map_row;
173 mutable std::vector<size_t> l2g_map_col;
175 void save_ver_0_2(
const char *
filename)
const;
176 void load_ver_0_2(
const char *
filename);
182template <
typename MatrixType>
184template <
typename MatrixType>
187template <
typename MatrixType>
189template <
typename MatrixType>
192template <
typename MatrixType>
195template <
typename MatrixType>
201template <
typename MatrixType>
203template <
typename MatrixType>
205template <
typename MatrixType>
208template <
typename MatrixType>
211template <
typename MatrixType>
215template <
typename MatrixType>
222template <
typename MatrixType>
224template <
typename MatrixType>
227template <
typename MatrixType>
229 std::vector<double> &
s);
230template <
typename MatrixType>
234template <
typename MatrixType>
237template <
typename MatrixType>
241template <
typename MatrixType>
244template <
typename MatrixType>
249template <
typename MatrixType>
251template <
typename MatrixType>
255template <
typename MatrixType>
258template <
typename MatrixType>
260template <
typename MatrixType>
263template <
typename MatrixType>
265 std::vector<double> &
eigval);
266template <
typename MatrixType>
273template <
typename MatrixType>
276template <
typename MatrixType>
278template <
typename MatrixType>
280 std::vector<complex> &
eigval,
282template <
typename MatrixType>
284 std::vector<complex> &
eigval);
289template <
typename MatrixType>
291 const std::vector<typename MatrixType::value_type> &
b,
292 std::vector<typename MatrixType::value_type> &
x);
293template <
typename MatrixType>
296template <
typename MatrixType>
304template <
typename MatrixType>
306template <
typename MatrixType>
308template <
typename MatrixType>
311template <
typename MatrixType>
314template <
typename MatrixType,
typename D>
316template <
typename MatrixType,
typename D>
318template <
typename MatrixType,
typename D>
324template <
typename MatrixType>
327template <
typename MatrixType>
331template <
typename MatrixType>
333template <
typename MatrixType>
335template <
typename MatrixType>
337template <
typename MatrixType>
343template <
typename MatrixType>
Tensor class. The main object of mptensor.
Definition tensor.hpp:54
Tensor< MatrixType > & transpose(const Axes &axes)
Transposition of tensor with lazy evaluation.
Definition tensor_impl.hpp:681
typename MatrixType::value_type value_type
double or complex
Definition tensor.hpp:56
size_t rank() const
Rank of tensor.
Definition tensor_impl.hpp:165
const comm_type & get_comm() const
Communicator.
Definition tensor_impl.hpp:217
const Axes & get_axes_map() const
Map of axes for lazy evaluation of transpose.
Definition tensor_impl.hpp:198
size_t local_size() const
Size of local storage.
Definition tensor_impl.hpp:180
std::vector< value_type > flatten()
Return a copy of the flattened vector.
Definition tensor_impl.hpp:985
Tensor< MatrixType > & map(UnaryOperation op)
Apply a unary operation to each element.
Definition tensor_impl.hpp:1040
void make_l2g_map() const
Preprocess for fast conversion from local index to global one.
Definition tensor_impl.hpp:265
const value_type & operator[](size_t local_idx) const
Const array subscript operator.
Definition tensor_impl.hpp:238
void global_index_fast(size_t i, Index &idx) const
Convert local index to global index fast.
Definition tensor_impl.hpp:539
Tensor< MatrixType > & operator=(value_type rhs)
Initialize all elements by rhs.
Definition tensor_impl.hpp:1027
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:365
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:598
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:330
Tensor< lapack::Matrix< value_type > > gather()
Gather all elements into a non-distributed tensor.
Definition tensor_impl.hpp:969
bool get_value(const Index &idx, value_type &val) const
Get an element.
Definition tensor_impl.hpp:566
Tensor< typename MatrixType::template rebind< D > > rebind
Tensor with scalar type replaced by D.
Definition tensor.hpp:61
Tensor< MatrixType > & operator-=(const Tensor &rhs)
Subtraction assignment.
Definition tensor_impl.hpp:1004
void prep_local_to_global() const
Preprocess for fast conversion from local index to global one.
Definition tensor_impl.hpp:259
void print_info_mpi(std::ostream &, const std::string &tag="") const
Output information of tensor.
Definition tensor_impl.hpp:456
void print_info(std::ostream &out, const std::string &tag="") const
Output information of tensor.
Definition tensor_impl.hpp:438
size_t ndim() const
Rank of tensor.
Definition tensor_impl.hpp:174
Tensor< MatrixType > & multiply_vector(const std::vector< D > &vec, size_t n_axes)
Element-wise vector multiplication.
Definition tensor_impl.hpp:714
void set_value(const Index &idx, value_type val)
Set an element.
Definition tensor_impl.hpp:584
Tensor< MatrixType > & operator/=(value_type rhs)
Scalar-division assignment.
Definition tensor_impl.hpp:1020
int get_comm_rank() const
Rank of process.
Definition tensor_impl.hpp:229
void local_position_fast(size_t g_row, size_t g_col, int &comm_rank, size_t &local_idx) const
Definition tensor_impl.hpp:390
Index global_index(size_t i) const
Convert local index to global index.
Definition tensor_impl.hpp:509
void prep_global_to_local() const
Preprocess for fast conversion from global index to local one.
Definition tensor_impl.hpp:253
Tensor< MatrixType > & operator*=(value_type rhs)
Scalar-multiplication assignment.
Definition tensor_impl.hpp:1013
Tensor< MatrixType > & set_slice(const Tensor &a, size_t n_axes, size_t i_begin, size_t i_end)
Inverse of slice().
Definition tensor_impl.hpp:860
const Shape & shape() const
Shape of tensor.
Definition tensor_impl.hpp:159
MatrixType matrix_type
type of Matrix class
Definition tensor.hpp:57
void load(const std::string &filename)
Load a tensor from files.
Definition load.hpp:53
size_t get_upper_rank() const
Upper rank for matrix representation.
Definition tensor_impl.hpp:186
Tensor< MatrixType > & operator+=(const Tensor &rhs)
Addition assignment.
Definition tensor_impl.hpp:995
const MatrixType & get_matrix() const
distributed Matrix
Definition tensor_impl.hpp:204
int get_comm_size() const
Size of communicator.
Definition tensor_impl.hpp:223
typename MatrixType::comm_type comm_type
type of communicator. MPI_Comm or int.
Definition tensor.hpp:58
std::string filename(const std::string &prefix, int proc_size)
Definition common.hpp:32
Define the type of a complex number.
Tensor< MatrixType > operator/(Tensor< MatrixType > lhs, D rhs)
Scalar division.
Definition tensor_impl.hpp:2598
Tensor< MatrixType > operator-(Tensor< MatrixType > rhs)
Unary minus.
Definition tensor_impl.hpp:2576
Tensor< MatrixType > operator*(Tensor< MatrixType > lhs, D rhs)
Tensor-scalar multiplication.
Definition tensor_impl.hpp:2593
std::complex< double > complex
Definition complex.hpp:38
int eig(const Tensor< MatrixType > &a, std::vector< complex > &eigval, typename Tensor< MatrixType >::template rebind< complex > &eigvec)
Compute the eigenvalues and eigenvectors of a general matrix (rank-2 tensor)
Definition tensor_impl.hpp:2309
int psvd(const Tensor< MatrixType > &a, std::vector< double > &s, const size_t target_rank)
Partial SVD for rank-2 tensor (matrix)
Definition tensor_impl.hpp:1880
int eigh(const Tensor< MatrixType > &a, std::vector< double > &eigval, Tensor< MatrixType > &eigvec)
Definition tensor_impl.hpp:2085
int qr(const Tensor< MatrixType > &a, Tensor< MatrixType > &q, Tensor< MatrixType > &r)
QR decomposition of matrix (rank-2 tensor)
Definition tensor_impl.hpp:1988
int svd(const Tensor< MatrixType > &a, std::vector< double > &s)
Singular value decomposition for rank-2 tensor (matrix)
Definition tensor_impl.hpp:1736
MatrixType::value_type trace(const Tensor< MatrixType > &a)
Trace of matrix (rank-2 tensor)
Definition tensor_impl.hpp:1423
Tensor< MatrixType > contract(const Tensor< MatrixType > &a, const Axes &axes_1, const Axes &axes_2)
Partial trace of tensor.
Definition tensor_impl.hpp:1533
Tensor< MatrixType > tensordot(const Tensor< MatrixType > &a, const Tensor< MatrixType > &b, const Axes &axes_a, const Axes &axes_b)
Compute tensor dot product.
Definition tensor_impl.hpp:1662
Tensor< MatrixType > kron(const Tensor< MatrixType > &a, const Tensor< MatrixType > &b)
Compute the Kronecker product.
Definition tensor_impl.hpp:1626
int solve(const Tensor< MatrixType > &a, const std::vector< typename MatrixType::value_type > &b, std::vector< typename MatrixType::value_type > &x)
Solve linear equation .
Definition tensor_impl.hpp:2461
Tensor< MatrixType > conj(Tensor< MatrixType > t)
Take conjugate of each element.
double min_abs(const Tensor< MatrixType > &t)
Return minimum of the absolute value of an element.
Definition tensor_impl.hpp:2624
Tensor< MatrixType > sqrt(Tensor< MatrixType > t)
Take square-root of each element.
double min(const Tensor< MatrixType > &t)
Return the minimum element. For complex, same as min_abs().
Definition tensor_impl.hpp:2614
double max_abs(const Tensor< MatrixType > &t)
Return maximum of the absolute value of an element.
Definition tensor_impl.hpp:2619
double max(const Tensor< MatrixType > &t)
Return the maximum element. For complex, same as max_abs().
Definition tensor_impl.hpp:2609
Tensor< MatrixType > extend(const Tensor< MatrixType > &a, const Shape &shape_new)
Extend the size of a tensor.
Definition tensor_impl.hpp:1377
Tensor< MatrixType > transpose(Tensor< MatrixType > a, const Axes &axes)
Transposition of tensor with lazy evaluation.
Definition tensor_impl.hpp:1055
Tensor< MatrixType > reshape(const Tensor< MatrixType > &a, const Shape &shape_new)
Change the shape of tensor.
Definition tensor_impl.hpp:1163
Tensor< MatrixType > slice(const Tensor< MatrixType > &a, size_t n_axes, size_t i_begin, size_t i_end)
Slice a tensor.
Definition tensor_impl.hpp:1229
Tensor()
Default constructor of tensor.
Definition tensor_impl.hpp:71
header file of Index class
List of header files for matrix classes.
Definition complex.hpp:34
std::ostream & operator<<(std::ostream &os, const Index &idx)
Index operator+(const Index &, const Index &)
Implementation of tensor class.