29#ifndef _TENSOR_RSVD_IMPL_HPP_
30#define _TENSOR_RSVD_IMPL_HPP_
43namespace random_tensor {
49template <
typename tensor_t>
51 const size_t n = t.local_size();
52 for (
size_t i = 0;
i <
n; ++
i) {
81template <
typename MatrixType>
86 throw std::invalid_argument(
"mptensor: rsvd() target_rank must be positive");
94 const size_t rank = a.
rank();
129template <
typename MatrixType>
162 throw std::invalid_argument(
"mptensor: rsvd() target_rank must be positive");
void resize(size_t n)
Definition index.hpp:137
size_t size() const
Definition index.hpp:135
size_t rank() const
Rank of tensor.
Definition tensor_impl.hpp:184
const comm_type & get_comm() const
Communicator.
Definition tensor_impl.hpp:236
Define the type of a complex number.
std::complex< double > complex
Definition complex.hpp:38
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
internal::UShape to_internal_shape(const Shape &s)
Definition index.hpp:366
Index range(const std::ptrdiff_t start, const std::ptrdiff_t stop, const std::ptrdiff_t step)
Arithmetic sequence start, start+step, ... up to (not including) stop.
Definition index.hpp:401
internal::UAxes normalize_axes(const Axes &axes, size_t rank)
Definition index.hpp:323
Index Axes
Definition index.hpp:212
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
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 > conj(Tensor< MatrixType > t)
Take conjugate of each element.
void set_seed(unsigned int seed)
Set seed for random number generator.
Definition rsvd_impl.hpp:206
int rsvd(const Tensor< MatrixType > &a, const Axes &axes_row, const Axes &axes_col, Tensor< MatrixType > &u, std::vector< double > &s, Tensor< MatrixType > &vt, const size_t target_rank, const size_t oversamp)
Singular value decomposition by randomized algorithm.
Definition rsvd_impl.hpp:82
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
header file of BasicIndex class template
List of header files for matrix classes.
mptensor::complex complex
Definition matrix_lapack.cc:36
bool check_svd_axes(const internal::UAxes &axes_row, const internal::UAxes &axes_col, size_t rank)
Definition tensor.cc:76
void set_seed(unsigned int seed)
void fill(tensor_t &t)
Definition rsvd_impl.hpp:50
Definition complex.hpp:34
Randomized algorithm for singular value decomposition.