33 #ifndef SRC_MADNESS_TENSOR_SVDTENSOR_H_
34 #define SRC_MADNESS_TENSOR_SVDTENSOR_H_
81 const double& eps, std::array<long,2> vectordim={0,0});
85 const double& eps, std::array<long,2> vectordim={0,0});
104 SRConf<T> result(addends.front().ndim(),addends.front().dims(),addends.front().nci_left);
107 for (
auto a : addends) totalrank+=
a.rank();
108 if (totalrank==0)
return result;
115 vector0=vector0.
reshape(totalrank,vector0.
size()/totalrank);
117 vector1=vector1.
reshape(totalrank,vector1.
size()/totalrank);
120 for (
auto a: addends) {
122 long end=start+
a.rank()-1;
123 vector0(
Slice(start,end),
_)=
a.flat_vector(0);
124 vector1(
Slice(start,end),
_)=
a.flat_vector(1);
162 template <
typename R,
typename Q>
166 template <
typename R,
typename Q>
170 template <
typename R,
typename Q>
174 template <
typename R,
typename Q>
206 template <
typename R,
typename Q>
212 template <
typename R,
typename Q>
218 template <
typename R,
typename Q>
const long * dims() const
Returns the array of tensor dimensions.
Definition: basetensor.h:153
long ndim() const
Returns the number of dimensions in the tensor.
Definition: basetensor.h:144
long size() const
Returns the number of elements in the tensor.
Definition: basetensor.h:138
long nci_left
separation dimensions: A(n,m) -> A(r,n) B(r,m), with n={k1,k2},m={k3,k4,k5..) multi-indices
Definition: srconf.h:93
TensorTypeData< T >::float_scalar_type float_scalar_type
Definition: srconf.h:73
unsigned int nCoeff() const
return the number of coefficients
Definition: srconf.h:709
Tensor< T > reconstruct() const
reconstruct this to return a full tensor
Definition: srconf.h:674
double weights(const unsigned int &i) const
return the weight
Definition: srconf.h:671
SRConf< T > & emul(const SRConf< T > &other)
perform elementwise Hadamard product
Definition: srconf.h:457
void set_vectors_and_weights(const Tensor< typename Tensor< T >::scalar_type > &weights, const Tensor< T > &vector1, const Tensor< T > &vector2)
Definition: srconf.h:234
long rank() const
return the logicalrank
Definition: srconf.h:661
friend bool compatible(const SRConf &lhs, const SRConf &rhs)
check compatibility
Definition: srconf.h:819
void append(const SRConf< T > &rhs, const double fac=1.0)
append configurations of rhs to this
Definition: srconf.h:300
void scale(const double &fac)
scale this by a number
Definition: srconf.h:812
std::array< std::array< long, TENSOR_MAXDIM >, 2 > make_vector_dimensions(const long rank) const
deduce the dimensions of the left and right singular vectors from the tensor dimensions
Definition: srconf.h:216
Definition: SVDTensor.h:42
long nCoeff() const
Definition: SVDTensor.h:73
SVDTensor(const std::vector< long > &dims)
Definition: SVDTensor.h:59
void truncate_svd(const double &thresh)
Definition: SVDTensor.cc:239
friend SVDTensor< TENSOR_RESULT_TYPE(R, Q)> general_transform(const SVDTensor< R > &t, const Tensor< Q > c[])
Definition: SVDTensor.h:213
void divide_and_conquer_reduce(const double &thresh)
reduce the rank using a divide-and-conquer approach
Definition: SVDTensor.cc:172
void recompute_from_range(const Tensor< T > &range)
compute an SVD from a given matrix and its range
Definition: SVDTensor.cc:148
SVDTensor(const long ndims, const long *dims)
Definition: SVDTensor.h:61
static SVDTensor compute_svd(const Tensor< T > &tensor, const double &eps, std::array< long, 2 > vectordim={0, 0})
reduce the rank using SVD
Definition: SVDTensor.cc:63
SVDTensor()
Definition: SVDTensor.h:46
SVDTensor(const SRConf< T > &rhs)
Definition: SVDTensor.h:57
friend SVDTensor< TENSOR_RESULT_TYPE(R, Q)> transform(const SVDTensor< R > &t, const Tensor< Q > &c)
Definition: SVDTensor.h:207
static SVDTensor compute_svd_from_range(const Tensor< T > &range, const Tensor< T > &matrix)
compute an SVD from a given matrix and its range
Definition: SVDTensor.cc:130
SVDTensor(const Tensor< double > &weights, const Tensor< T > &vector1, const Tensor< T > &vector2, const long &ndim, const long *dims)
Definition: SVDTensor.h:63
SVDTensor & operator=(const T &number)
Definition: SVDTensor.h:67
SVDTensor(const SVDTensor< T > &rhs)=default
static void set_reduction_algorithm(const std::string alg)
Definition: SVDTensor.cc:47
SVDTensor(const Tensor< T > &rhs, const double eps)
Definition: SVDTensor.h:48
SVDTensor< T > & gaxpy(T alpha, const SVDTensor< T > &rhs, T beta)
Definition: SVDTensor.h:140
friend SVDTensor< TENSOR_RESULT_TYPE(R, Q)> outer(const SVDTensor< R > &t1, const SVDTensor< Q > &t2)
friend SVDTensor< T > reduce(std::list< SVDTensor< T > > &addends, double eps)
Definition: SVDTensor.h:178
SVDTensor< T > & emul(const SVDTensor< T > &other)
Definition: SVDTensor.h:134
static std::string reduction_algorithm()
Definition: SVDTensor.cc:52
long rank() const
Definition: SVDTensor.h:77
static SVDTensor compute_randomized_svd(const Tensor< T > &tensor, const double &eps, std::array< long, 2 > vectordim={0, 0})
reduce the rank using SVD
Definition: SVDTensor.cc:97
friend SVDTensor< T > copy(const SVDTensor< T > &rhs)
Definition: SVDTensor.h:199
void orthonormalize_random(const double &thresh)
Definition: SVDTensor.cc:220
void orthonormalize(const double &thresh)
Definition: SVDTensor.cc:201
static SVDTensor< T > concatenate(const std::list< SVDTensor< T > > &addends)
concatenate all arguments into a single SRConf (i.e. adding them all up)
Definition: SVDTensor.h:99
friend SVDTensor< TENSOR_RESULT_TYPE(R, Q)> transform_dir(const SVDTensor< R > &t, const Tensor< Q > &c, const int axis)
Definition: SVDTensor.h:219
A slice defines a sub-range or patch of a dimension.
Definition: slice.h:103
Traits class to specify support of numeric types.
Definition: type_data.h:56
A tensor is a multidimension array.
Definition: tensor.h:317
Tensor< T > reshape(int ndimnew, const long *d)
Returns new view/tensor reshaping size/number of dimensions to conforming tensor.
Definition: tensor.h:1384
bool has_data() const
Definition: tensor.h:1886
static const double R
Definition: csqrt.cc:46
auto T(World &world, response_space &f) -> response_space
Definition: global_functions.cc:34
const double beta
Definition: gygi_soltion.cc:62
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition: madness_exception.h:119
#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
GenTensor< TENSOR_RESULT_TYPE(R, Q)> general_transform(const GenTensor< R > &t, const Tensor< Q > c[])
Definition: gentensor.h:274
GenTensor< TENSOR_RESULT_TYPE(R, Q)> transform_dir(const GenTensor< R > &t, const Tensor< Q > &c, const int axis)
Definition: lowranktensor.h:1099
static const Slice _(0,-1, 1)
TENSOR_RESULT_TYPE(T, R) inner(const Function< T
Computes the scalar/inner product between two functions.
Definition: vmra.h:1059
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform(World &world, const std::vector< Function< T, NDIM > > &v, const Tensor< R > &c, bool fence=true)
Transforms a vector of functions according to new[i] = sum[j] old[j]*c[j,i].
Definition: vmra.h:689
static const double a
Definition: nonlinschro.cc:118
double Q(double a)
Definition: relops.cc:20
static const double c
Definition: relops.cc:10
static const double thresh
Definition: rk.cc:45
Definition: test_ccpairfunction.cc:22
const double alpha
Definition: test_coulomb.cc:54
std::size_t axis
Definition: testpdiff.cc:59