44template <
typename MatrixType>
61template <
typename MatrixType>
66template <
typename MatrixType>
81template <
typename MatrixType>
140 template <
typename D>
142 template <
typename D0,
typename D1>
145 const std::vector<D1> &
vec1,
147 template <
typename D0,
typename D1,
typename D2>
149 const std::vector<D0> &
vec0, std::ptrdiff_t
n_axes0,
const std::vector<D1> &
vec1,
151 template <
typename D0,
typename D1,
typename D2,
typename D3>
153 const std::vector<D0> &
vec0, std::ptrdiff_t
n_axes0,
const std::vector<D1> &
vec1,
155 const std::vector<D3> &
vec3, std::ptrdiff_t
n_axes3);
163 std::vector<value_type>
flatten();
171 template <
typename UnaryOperation>
206 mutable std::vector<size_t> l2g_map_row;
207 mutable std::vector<size_t> l2g_map_col;
209 void save_ver_0_2(
const char *
filename)
const;
210 void load_ver_0_2(
const char *
filename);
216template <
typename MatrixType>
218template <
typename MatrixType>
221template <
typename MatrixType>
223template <
typename MatrixType>
226template <
typename MatrixType>
229template <
typename MatrixType>
235template <
typename MatrixType>
237template <
typename MatrixType>
239template <
typename MatrixType>
242template <
typename MatrixType>
245template <
typename MatrixType>
249template <
typename MatrixType>
256template <
typename MatrixType>
258template <
typename MatrixType>
261template <
typename MatrixType>
263 std::vector<double> &
s);
264template <
typename MatrixType>
268template <
typename MatrixType>
271template <
typename MatrixType>
275template <
typename MatrixType>
278template <
typename MatrixType>
283template <
typename MatrixType>
285template <
typename MatrixType>
289template <
typename MatrixType>
292template <
typename MatrixType>
294template <
typename MatrixType>
297template <
typename MatrixType>
299 std::vector<double> &
eigval);
300template <
typename MatrixType>
307template <
typename MatrixType>
310template <
typename MatrixType>
312template <
typename MatrixType>
314 std::vector<complex> &
eigval,
316template <
typename MatrixType>
318 std::vector<complex> &
eigval);
323template <
typename MatrixType>
325 const std::vector<typename MatrixType::value_type> &
b,
326 std::vector<typename MatrixType::value_type> &
x);
327template <
typename MatrixType>
330template <
typename MatrixType>
338template <
typename MatrixType>
340template <
typename MatrixType>
342template <
typename MatrixType>
345template <
typename MatrixType>
348template <
typename MatrixType,
typename D>
350template <
typename MatrixType,
typename D>
352template <
typename MatrixType,
typename D>
358template <
typename MatrixType>
361template <
typename MatrixType>
365template <
typename MatrixType>
367template <
typename MatrixType>
369template <
typename MatrixType>
371template <
typename MatrixType>
377template <
typename MatrixType>
Tensor class. The main object of mptensor.
Definition tensor.hpp:82
Tensor< MatrixType > & transpose(const Axes &axes)
Transposition of tensor with lazy evaluation.
Definition tensor_impl.hpp:685
typename MatrixType::value_type value_type
double or complex
Definition tensor.hpp:84
const internal::UAxes & get_axes_map() const
Map of axes for lazy evaluation of transpose.
Definition tensor_impl.hpp:217
size_t rank() const
Rank of tensor.
Definition tensor_impl.hpp:184
const comm_type & get_comm() const
Communicator.
Definition tensor_impl.hpp:236
size_t local_size() const
Size of local storage.
Definition tensor_impl.hpp:199
std::vector< value_type > flatten()
Return a copy of the flattened vector.
Definition tensor_impl.hpp:1007
Tensor< MatrixType > & map(UnaryOperation op)
Apply a unary operation to each element.
Definition tensor_impl.hpp:1062
void make_l2g_map() const
Preprocess for fast conversion from local index to global one.
Definition tensor_impl.hpp:284
Shape shape() const
Shape of tensor.
Definition tensor_impl.hpp:172
const value_type & operator[](size_t local_idx) const
Const array subscript operator.
Definition tensor_impl.hpp:257
Tensor< MatrixType > & operator=(value_type rhs)
Initialize all elements by rhs.
Definition tensor_impl.hpp:1049
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:384
Tensor< MatrixType > & set_slice(const Tensor &a, std::ptrdiff_t n_axes, std::ptrdiff_t i_begin, std::ptrdiff_t i_end)
Inverse of slice().
Definition tensor_impl.hpp:880
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:349
Tensor< lapack::Matrix< value_type > > gather()
Gather all elements into a non-distributed tensor.
Definition tensor_impl.hpp:989
bool get_value(const Index &idx, value_type &val) const
Get an element.
Definition tensor_impl.hpp:570
Tensor< typename MatrixType::template rebind< D > > rebind
Tensor with scalar type replaced by D.
Definition tensor.hpp:89
Tensor< MatrixType > & operator-=(const Tensor &rhs)
Subtraction assignment.
Definition tensor_impl.hpp:1026
void prep_local_to_global() const
Preprocess for fast conversion from local index to global one.
Definition tensor_impl.hpp:278
void print_info_mpi(std::ostream &, const std::string &tag="") const
Output information of tensor.
Definition tensor_impl.hpp:475
void print_info(std::ostream &out, const std::string &tag="") const
Output information of tensor.
Definition tensor_impl.hpp:457
size_t ndim() const
Rank of tensor.
Definition tensor_impl.hpp:193
void set_value(const Index &idx, value_type val)
Set an element.
Definition tensor_impl.hpp:588
Tensor< MatrixType > & operator/=(value_type rhs)
Scalar-division assignment.
Definition tensor_impl.hpp:1042
int get_comm_rank() const
Rank of process.
Definition tensor_impl.hpp:248
Tensor< MatrixType > & multiply_vector(const std::vector< D > &vec, std::ptrdiff_t n_axes)
Element-wise vector multiplication.
Definition tensor_impl.hpp:724
void local_position_fast(size_t g_row, size_t g_col, int &comm_rank, size_t &local_idx) const
Definition tensor_impl.hpp:409
const internal::UShape & internal_shape() const
Shape as the internal type.
Definition tensor_impl.hpp:178
void local_position(const internal::UIndex &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:602
Index global_index(size_t i) const
Convert local index to global index.
Definition tensor_impl.hpp:528
void prep_global_to_local() const
Preprocess for fast conversion from global index to local one.
Definition tensor_impl.hpp:272
Tensor< MatrixType > & operator*=(value_type rhs)
Scalar-multiplication assignment.
Definition tensor_impl.hpp:1035
MatrixType matrix_type
type of Matrix class
Definition tensor.hpp:85
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:205
Tensor< MatrixType > & operator+=(const Tensor &rhs)
Addition assignment.
Definition tensor_impl.hpp:1017
const MatrixType & get_matrix() const
distributed Matrix
Definition tensor_impl.hpp:223
int get_comm_size() const
Size of communicator.
Definition tensor_impl.hpp:242
void global_index_fast(size_t i, internal::UIndex &idx) const
Convert local index to global index fast.
Definition tensor_impl.hpp:543
typename MatrixType::comm_type comm_type
type of communicator. MPI_Comm or int.
Definition tensor.hpp:86
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:2682
Tensor< MatrixType > operator-(Tensor< MatrixType > rhs)
Unary minus.
Definition tensor_impl.hpp:2660
Tensor< MatrixType > operator*(Tensor< MatrixType > lhs, D rhs)
Tensor-scalar multiplication.
Definition tensor_impl.hpp:2677
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:2381
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:1930
int eigh(const Tensor< MatrixType > &a, std::vector< double > &eigval, Tensor< MatrixType > &eigvec)
Definition tensor_impl.hpp:2149
int qr(const Tensor< MatrixType > &a, Tensor< MatrixType > &q, Tensor< MatrixType > &r)
QR decomposition of matrix (rank-2 tensor)
Definition tensor_impl.hpp:2050
int svd(const Tensor< MatrixType > &a, std::vector< double > &s)
Singular value decomposition for rank-2 tensor (matrix)
Definition tensor_impl.hpp:1782
std::ostream & operator<<(std::ostream &os, const BasicIndex< T > &idx)
Definition index.hpp:192
BasicIndex< T > operator+(const BasicIndex< T > &lhs, const BasicIndex< T > &rhs)
Definition index.hpp:203
UIndex UShape
Definition index.hpp:227
Tensor< MatrixType > transpose_impl(const Tensor< MatrixType > &a, const UAxes &axes, size_t urank_new)
Definition tensor_impl.hpp:1116
constexpr normalized_t normalized
Definition tensor.hpp:55
UIndex UAxes
Definition index.hpp:224
Tensor< MatrixType > reshape_impl(const Tensor< MatrixType > &a, const UShape &shape_new)
Definition tensor_impl.hpp:1197
MatrixType::value_type trace(const Tensor< MatrixType > &a)
Trace of matrix (rank-2 tensor)
Definition tensor_impl.hpp:1459
Tensor< MatrixType > contract(const Tensor< MatrixType > &a, const Axes &axes_1, const Axes &axes_2)
Partial trace of tensor.
Definition tensor_impl.hpp:1573
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:1706
Tensor< MatrixType > kron(const Tensor< MatrixType > &a, const Tensor< MatrixType > &b)
Compute the Kronecker product.
Definition tensor_impl.hpp:1669
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:2541
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:2708
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:2698
double max_abs(const Tensor< MatrixType > &t)
Return maximum of the absolute value of an element.
Definition tensor_impl.hpp:2703
double max(const Tensor< MatrixType > &t)
Return the maximum element. For complex, same as max_abs().
Definition tensor_impl.hpp:2693
Tensor< MatrixType > extend(const Tensor< MatrixType > &a, const Shape &shape_new)
Extend the size of a tensor.
Definition tensor_impl.hpp:1411
Tensor< MatrixType > transpose(Tensor< MatrixType > a, const Axes &axes)
Transposition of tensor with lazy evaluation.
Definition tensor_impl.hpp:1077
Tensor< MatrixType > reshape(const Tensor< MatrixType > &a, const Shape &shape_new)
Change the shape of tensor.
Definition tensor_impl.hpp:1110
Tensor< MatrixType > slice(const Tensor< MatrixType > &a, std::ptrdiff_t n_axes, std::ptrdiff_t i_begin, std::ptrdiff_t i_end)
Slice a tensor.
Definition tensor_impl.hpp:1265
Tensor()
Default constructor of tensor.
Definition tensor_impl.hpp:71
header file of BasicIndex class template
List of header files for matrix classes.
Definition complex.hpp:34
Implementation of tensor class.