3 #ifndef SRC_MADNESS_TENSOR_RANDOMIZEDMATRIXDECOMPOSITION_H_
4 #define SRC_MADNESS_TENSOR_RANDOMIZEDMATRIXDECOMPOSITION_H_
63 const double& eps, std::array<long,2> matrixdim={0,0});
73 Tensor<T>
compute_range(
const Tensor<T>& columnspace,
const Tensor<T>& rowspace,
90 for (
long i=0; i<s.size(); ++i) {
100 if (vectordim[0]==0) {
101 long dim1=
matrix.ndim()/2;
102 vectordim[0]=vectordim[1]=1;
103 for (
long i=0; i<dim1; ++i) vectordim[0]*=
matrix.dim(i);
104 for (
long i=dim1; i<
matrix.ndim(); ++i) vectordim[1]*=
matrix.dim(i);
107 Tensor<T> values_eff=
matrix.reshape(vectordim[0],vectordim[1]);
136 if (
algo==
"matrix")
return mat1.dim(0);
137 if (
algo==
"col_row")
return mat1.dim(1);
143 if (
algo==
"matrix")
return mat1.dim(1);
144 if (
algo==
"col_row")
return mat2.dim(1);
150 if (
algo==
"matrix")
return std::min(
mat1.dim(0),
mat1.dim(1));
151 if (
algo==
"col_row")
return mat1.dim(0);
158 if (
algo==
"matrix") {
161 }
else if (
algo==
"col_row") {
Definition: RandomizedMatrixDecomposition.h:31
Tensor< T > range
the range that spans the input matrix
Definition: RandomizedMatrixDecomposition.h:125
static Tensor< T > resize_to_matrix(const Tensor< T > &matrix, std::array< long, 2 > vectordim={0, 0})
resize Tensor to a matrix
Definition: RandomizedMatrixDecomposition.h:98
void set_maxrank(const long max_rank)
Definition: RandomizedMatrixDecomposition.h:112
RandomizedMatrixDecomposition()=default
Tensor< T > do_compute_range(const Y_former &Y, const double &eps) const
perform the actual computation of the range
Definition: RandomizedMatrixDecomposition.cc:31
RandomizedMatrixDecomposition(const RandomizedMatrixDecomposition &other)=default
Tensor< T > compute_range(const Tensor< T > &tensor, const double &eps, std::array< long, 2 > matrixdim={0, 0})
compute the range of the matrix
Definition: RandomizedMatrixDecomposition.cc:12
long oversampling
oversampling parameter
Definition: RandomizedMatrixDecomposition.h:122
bool exceeds_maxrank() const
check if the computed rank is too large
Definition: RandomizedMatrixDecomposition.h:49
TensorTypeData< T >::scalar_type scalar_type
Definition: RandomizedMatrixDecomposition.h:34
RandomizedMatrixDecomposition(const RMDFactory &factory)
Definition: RandomizedMatrixDecomposition.h:40
Tensor< T > get_range() const
Definition: RandomizedMatrixDecomposition.h:51
static Tensor< T > make_SVD_decaying_matrix(const Tensor< T > &matrix, const int n=1)
helper function
Definition: RandomizedMatrixDecomposition.h:86
static scalar_type check_range(const Tensor< T > &matrix, const Tensor< T > &range)
return the error of the range Q
Definition: RandomizedMatrixDecomposition.h:79
long maxrank
maximum rank to abort the decomposition
Definition: RandomizedMatrixDecomposition.h:119
RandomizedMatrixDecomposition(const Tensor< T > &matrix, const double thresh)
Definition: RandomizedMatrixDecomposition.h:44
Traits class to specify support of numeric types.
Definition: type_data.h:56
A tensor is a multidimension array.
Definition: tensor.h:317
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition: madness_exception.h:134
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
Function< T, NDIM > conj(const Function< T, NDIM > &f, bool fence=true)
Return the complex conjugate of the input function with the same distribution and optional fence.
Definition: mra.h:2046
static const Slice _(0,-1, 1)
void svd(const Tensor< T > &a, Tensor< T > &U, Tensor< typename Tensor< T >::scalar_type > &s, Tensor< T > &VT)
Compute the singluar value decomposition of an n-by-m matrix using *gesvd.
Definition: lapack.cc:739
double inner(response_space &a, response_space &b)
Definition: response_functions.h:442
static const double thresh
Definition: rk.cc:45
simple factory pattern for the RandomizedMatrixDecomposition
Definition: RandomizedMatrixDecomposition.h:12
long maxrank_
Definition: RandomizedMatrixDecomposition.h:13
long oversampling_
Definition: RandomizedMatrixDecomposition.h:14
RMDFactory & maxrank(const long mr)
Definition: RandomizedMatrixDecomposition.h:18
RMDFactory & oversampling(const long os)
Definition: RandomizedMatrixDecomposition.h:22
RMDFactory()
Definition: RandomizedMatrixDecomposition.h:16
Defines and implements most of Tensor.
F residual(const F &f)
Definition: testcomplexfunctionsolver.cc:69