MADNESS 0.10.1
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Private Types | Friends | List of all members
madness::SRConf< T > Class Template Reference

#include <srconf.h>

Inheritance diagram for madness::SRConf< T >:
Inheritance graph
[legend]
Collaboration diagram for madness::SRConf< T >:
Collaboration graph
[legend]

Public Types

typedef Tensor< TtensorT
 

Public Member Functions

 SRConf ()
 default ctor
 
 SRConf (const long &ndim, const long *dimensions, const long nci)
 
 SRConf (const long &ndim, const std::array< long, TENSOR_MAXDIM > &dimensions, const long nci)
 
 SRConf (const SRConf &rhs)=default
 copy ctor (tested); shallow copy
 
 SRConf (const Tensor< double > &weights, const std::vector< Tensor< T > > &vectors, const long &ndim, const long &dims, const long nci)
 ctor with provided weights and effective vectors; shallow copy
 
 SRConf (const Tensor< double > &weights, const tensorT &vector1, const tensorT &vector2, const long &ndim, const long *dims, const long nci)
 explicit ctor with two vectors (aka SVD), shallow
 
 ~SRConf ()
 dtor
 
void add_SVD (const SRConf< T > &rhs, const double &thresh)
 add two orthonormal configurations, yielding an optimal SVD decomposition
 
void append (const SRConf< T > &rhs, const double fac=1.0)
 append configurations of rhs to this
 
void append (const SRConf< T > &rhs, const double_complex fac=1.0)
 
const std::vector< Slice > & c0 (const int idim) const
 return a Slice that corresponds the that part of vector_ that holds coefficients
 
void clear ()
 
SRConf< Tcopy_slice (const std::array< Slice, TENSOR_MAXDIM > &s) const
 return a slice of this (deep copy)
 
int dim_per_vector (int idim) const
 return the number of physical dimensions
 
SRConf< T > & emul (const SRConf< T > &other)
 perform elementwise Hadamard product
 
Tensor< Tflat_vector (const unsigned int &idim)
 return shallow copy of a slice of one of the vectors, flattened to (r,kVec)
 
const Tensor< Tflat_vector (const unsigned int &idim) const
 return shallow copy of a slice of one of the vectors, flattened to (r,kVec)
 
Tensor< Tflat_vector_with_weights (const int dim) const
 return flat (r,i) view of the tensor with the weights multiplied in
 
template<typename Q >
SRConf< TENSOR_RESULT_TYPE(T, Q) > general_transform (const Tensor< Q > c[]) const
 
const SRConf get_configs (const int &start, const int &end) const
 
bool has_data () const
 does this have any data?
 
bool has_no_data () const
 does this have any data?
 
bool has_structure () const
 return if this has a tensor structure (has not been flattened)
 
long kVec (const int idim) const
 
void make_empty_vectors_and_weights (const long rank)
 
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
 
Tensor< Tmake_vector_with_weights (const int dim) const
 
SRConfoperator= (const SRConf &rhs)
 assignment operator (tested), shallow copy of vectors
 
SRConfoperator= (const T &number)
 assign a number to this;
 
long rank () const
 return the logicalrank
 
Tensor< Treconstruct () const
 reconstruct this to return a full tensor
 
Tensor< T > & ref_vector (const unsigned int &idim)
 return reference to one of the vectors F
 
const Tensor< T > & ref_vector (const unsigned int &idim) const
 return reference to one of the vectors F
 
template<typename Archive >
void serialize (Archive &ar)
 
void set_size_and_dim (long ndim, long k)
 
void set_vectors_and_weights (const Tensor< typename Tensor< T >::scalar_type > &weights, const Tensor< T > &vector1, const Tensor< T > &vector2)
 
SRConf< Ttransform_dir (const Tensor< T > &c, const int &axis) const
 
double weights (const unsigned int &i) const
 return the weight
 
- Public Member Functions inherited from madness::BaseTensor
 BaseTensor ()
 
virtual ~BaseTensor ()
 
bool conforms (const BaseTensor *t) const
 Returns true if this and *t are the same shape and size.
 
long dim (int i) const
 Returns the size of dimension i.
 
const long * dims () const
 Returns the array of tensor dimensions.
 
long id () const
 Returns the typeid of the tensor (c.f., TensorTypeData<T> )
 
bool iscontiguous () const
 Returns true if the tensor refers to contiguous memory locations.
 
long ndim () const
 Returns the number of dimensions in the tensor.
 
long size () const
 Returns the number of elements in the tensor.
 
long stride (int i) const
 Returns the stride associated with dimension i.
 
const long * strides () const
 Returns the array of tensor strides.
 

Static Public Member Functions

static int max_sigma (const double &thresh, const long &rank, const Tensor< double > &w)
 
- Static Public Member Functions inherited from madness::BaseTensor
static int get_instance_count ()
 Returns the count of all current instances of tensors & slice tensors of all types.
 

Public Attributes

long nci_left =-1
 separation dimensions: A(n,m) -> A(r,n) B(r,m), with n={k1,k2},m={k3,k4,k5..) multi-indices
 
std::vector< Slices0
 
std::vector< Slices1
 
std::array< Tensor< T >, 2 > vector_
 
Tensor< typename Tensor< T >::scalar_typeweights_
 for each configuration the weight; length should be r
 

Static Public Attributes

static const bool check_orthonormality =false
 check orthonormality at low rank additions
 

Protected Member Functions

bool check_dimensions () const
 
bool check_right_orthonormality () const
 check if the terms are orthogonal
 
void fillWithRandom (const long &rank=1)
 fill this SRConf with 1 flattened random configurations (tested)
 
void inplace_add (const SRConf< T > &rhs, std::array< Slice, TENSOR_MAXDIM > lhs_s, std::array< Slice, TENSOR_MAXDIM > rhs_s, const double alpha, const double beta)
 alpha * this(lhs_s) + beta * rhs(rhs_s)
 
bool is_flat () const
 return if this has only one additional dimension (apart from rank)
 
Tensor< Tmake_left_vector_with_weights () const
 
void make_slices ()
 redo the Slices for getting direct access to the configurations
 
std::array< std::vector< Slice >, 2 > make_slices (const std::array< Slice, TENSOR_MAXDIM > &s) const
 
void make_structure (bool force=false)
 
unsigned int nCoeff () const
 return the number of coefficients
 
void normalize ()
 normalize the vectors (tested)
 
TensorTypeData< T >::float_scalar_type normf () const
 calculate the Frobenius norm
 
size_t real_size () const
 return the real size of this
 
void scale (const double &fac)
 scale this by a number
 
void scale (const double_complex &fac)
 
TensorTypeData< T >::float_scalar_type svd_normf () const
 calculate the Frobenius norm, if this is in SVD form
 
template<typename Q >
std::enable_if<(TensorTypeData< T >::iscomplexorTensorTypeData< Q >::iscomplex), TENSOR_RESULT_TYPE(T, Q)>::type friend trace (const SRConf< T > &rhs, const SRConf< Q > &lhs)
 
template<typename Q >
std::enable_if<!(TensorTypeData< T >::iscomplexorTensorTypeData< Q >::iscomplex), TENSOR_RESULT_TYPE(T, Q)>::type friend trace (const SRConf< T > &rhs, const SRConf< Q > &lhs)
 calculate the Frobenius inner product (tested)
 
SRConf< Ttransform (const Tensor< T > &c) const
 
- Protected Member Functions inherited from madness::BaseTensor
void cycledim_inplace (long shift, long start, long end)
 Cyclic shift of dimensions.
 
void flat_inplace ()
 Reshapes the tensor inplace into 1D.
 
void fusedim_inplace (long i)
 Fuses dimensions i and i+1.
 
void mapdim_inplace (const std::vector< long > &map)
 General permutation of dimensions.
 
void reshape_inplace (const std::vector< long > &d)
 Reshapes the tensor inplace.
 
void reshape_inplace (int ndimnew, const long *d)
 Reshapes the tensor inplace.
 
void set_dims_and_size (long nd, const long d[])
 
void splitdim_inplace (long i, long dimi0, long dimi1)
 Splits dimension i.
 
void swapdim_inplace (long i, long j)
 Swaps the dimensions.
 

Private Types

typedef TensorTypeData< T >::float_scalar_type float_scalar_type
 
typedef Tensor< T >::scalar_type scalar_type
 the scalar type of T
 

Friends

bool compatible (const SRConf &lhs, const SRConf &rhs)
 check compatibility
 
SRConf< Tcopy (const SRConf< T > &rhs)
 deep copy of rhs, shrink
 
class GenTensor< T >
 
class SliceLowRankTensor< T >
 

Additional Inherited Members

- Protected Attributes inherited from madness::BaseTensor
long _dim [TENSOR_MAXDIM]
 Size of each dimension.
 
long _id
 Id from TensorTypeData<T> in type_data.h.
 
long _ndim
 Number of dimensions (-1=invalid; 0=no supported; >0=tensor)
 
long _size
 Number of elements in the tensor.
 
long _stride [TENSOR_MAXDIM]
 Increment between elements in each dimension.
 

Detailed Description

template<typename T>
class madness::SRConf< T >

A SRConf handles all the configurations in a Separated Representation.

Member Typedef Documentation

◆ float_scalar_type

template<typename T >
typedef TensorTypeData<T>::float_scalar_type madness::SRConf< T >::float_scalar_type
private

◆ scalar_type

template<typename T >
typedef Tensor<T>::scalar_type madness::SRConf< T >::scalar_type
private

the scalar type of T

◆ tensorT

template<typename T >
typedef Tensor<T> madness::SRConf< T >::tensorT

Constructor & Destructor Documentation

◆ SRConf() [1/6]

template<typename T >
madness::SRConf< T >::SRConf ( )
inline

default ctor

◆ SRConf() [2/6]

template<typename T >
madness::SRConf< T >::SRConf ( const long &  ndim,
const long *  dimensions,
const long  nci 
)
inline

◆ SRConf() [3/6]

template<typename T >
madness::SRConf< T >::SRConf ( const long &  ndim,
const std::array< long, TENSOR_MAXDIM > &  dimensions,
const long  nci 
)
inline

◆ SRConf() [4/6]

template<typename T >
madness::SRConf< T >::SRConf ( const SRConf< T > &  rhs)
default

copy ctor (tested); shallow copy

◆ SRConf() [5/6]

template<typename T >
madness::SRConf< T >::SRConf ( const Tensor< double > &  weights,
const std::vector< Tensor< T > > &  vectors,
const long &  ndim,
const long &  dims,
const long  nci 
)
inline

◆ SRConf() [6/6]

template<typename T >
madness::SRConf< T >::SRConf ( const Tensor< double > &  weights,
const tensorT vector1,
const tensorT vector2,
const long &  ndim,
const long *  dims,
const long  nci 
)
inline

◆ ~SRConf()

template<typename T >
madness::SRConf< T >::~SRConf ( )
inline

dtor

Member Function Documentation

◆ add_SVD()

template<typename T >
void madness::SRConf< T >::add_SVD ( const SRConf< T > &  rhs,
const double &  thresh 
)
inline

◆ append() [1/2]

template<typename T >
void madness::SRConf< T >::append ( const SRConf< T > &  rhs,
const double  fac = 1.0 
)
inline

◆ append() [2/2]

template<typename T >
void madness::SRConf< T >::append ( const SRConf< T > &  rhs,
const double_complex  fac = 1.0 
)
inline

References MADNESS_EXCEPTION.

◆ c0()

template<typename T >
const std::vector< Slice > & madness::SRConf< T >::c0 ( const int  idim) const
inline

return a Slice that corresponds the that part of vector_ that holds coefficients

References MADNESS_EXCEPTION, madness::SRConf< T >::s0, and madness::SRConf< T >::s1.

Referenced by madness::SRConf< T >::append(), and madness::SRConf< T >::check_right_orthonormality().

◆ check_dimensions()

template<typename T >
bool madness::SRConf< T >::check_dimensions ( ) const
inlineprotected

◆ check_right_orthonormality()

template<typename T >
bool madness::SRConf< T >::check_right_orthonormality ( ) const
inlineprotected

◆ clear()

template<typename T >
void madness::SRConf< T >::clear ( )
inline

◆ copy_slice()

template<typename T >
SRConf< T > madness::SRConf< T >::copy_slice ( const std::array< Slice, TENSOR_MAXDIM > &  s) const
inline

◆ dim_per_vector()

template<typename T >
int madness::SRConf< T >::dim_per_vector ( int  idim) const
inline

◆ emul()

template<typename T >
SRConf< T > & madness::SRConf< T >::emul ( const SRConf< T > &  other)
inline

◆ fillWithRandom()

template<typename T >
void madness::SRConf< T >::fillWithRandom ( const long &  rank = 1)
inlineprotected

◆ flat_vector() [1/2]

template<typename T >
Tensor< T > madness::SRConf< T >::flat_vector ( const unsigned int &  idim)
inline

return shallow copy of a slice of one of the vectors, flattened to (r,kVec)

References madness::SRConf< T >::kVec(), MADNESS_ASSERT, madness::SRConf< T >::rank(), madness::Tensor< T >::reshape(), and madness::SRConf< T >::vector_.

◆ flat_vector() [2/2]

template<typename T >
const Tensor< T > madness::SRConf< T >::flat_vector ( const unsigned int &  idim) const
inline

◆ flat_vector_with_weights()

template<typename T >
Tensor< T > madness::SRConf< T >::flat_vector_with_weights ( const int  dim) const
inline

return flat (r,i) view of the tensor with the weights multiplied in

return a(r,i) = vec(dim)(r,i) * w(r)

References madness::BaseTensor::dim(), madness::SRConf< T >::make_vector_with_weights(), madness::SRConf< T >::rank(), madness::BaseTensor::size(), and madness::SRConf< T >::vector_.

◆ general_transform()

template<typename T >
template<typename Q >
SRConf< TENSOR_RESULT_TYPE(T, Q) > madness::SRConf< T >::general_transform ( const Tensor< Q c[]) const
inline
result(i,j,k,...) <-- sum(i',j', k',...) t(i',j',k',...) c(i',i) c(j',j) c(k',k) ...
static const double c
Definition relops.cc:10
static const long k
Definition rk.cc:44
AtomicInt sum
Definition test_atomicint.cc:46

The input dimensions of t must all be the same .

References c, madness::SRConf< T >::copy, madness::BaseTensor::dims(), madness::SRConf< T >::has_no_data(), madness::SRConf< T >::has_structure(), madness::inner(), MADNESS_ASSERT, madness::SRConf< T >::nci_left, madness::BaseTensor::ndim(), madness::SRConf< T >::rank(), madness::SRConf< T >::set_vectors_and_weights(), madness::SRConf< T >::vector_, and madness::SRConf< T >::weights_.

◆ get_configs()

template<typename T >
const SRConf madness::SRConf< T >::get_configs ( const int &  start,
const int &  end 
) const
inline

◆ has_data()

template<typename T >
bool madness::SRConf< T >::has_data ( ) const
inline

does this have any data?

References madness::BaseTensor::size().

Referenced by madness::SRConf< T >::has_no_data().

◆ has_no_data()

template<typename T >
bool madness::SRConf< T >::has_no_data ( ) const
inline

◆ has_structure()

template<typename T >
bool madness::SRConf< T >::has_structure ( ) const
inline

◆ inplace_add()

template<typename T >
void madness::SRConf< T >::inplace_add ( const SRConf< T > &  rhs,
std::array< Slice, TENSOR_MAXDIM lhs_s,
std::array< Slice, TENSOR_MAXDIM rhs_s,
const double  alpha,
const double  beta 
)
inlineprotected

◆ is_flat()

template<typename T >
bool madness::SRConf< T >::is_flat ( ) const
inlineprotected

return if this has only one additional dimension (apart from rank)

References madness::BaseTensor::ndim(), and madness::SRConf< T >::vector_.

◆ kVec()

template<typename T >
long madness::SRConf< T >::kVec ( const int  idim) const
inline

◆ make_empty_vectors_and_weights()

template<typename T >
void madness::SRConf< T >::make_empty_vectors_and_weights ( const long  rank)
inline

◆ make_left_vector_with_weights()

template<typename T >
Tensor< T > madness::SRConf< T >::make_left_vector_with_weights ( ) const
inlineprotected

◆ make_slices() [1/2]

template<typename T >
void madness::SRConf< T >::make_slices ( )
inlineprotected

◆ make_slices() [2/2]

template<typename T >
std::array< std::vector< Slice >, 2 > madness::SRConf< T >::make_slices ( const std::array< Slice, TENSOR_MAXDIM > &  s) const
inlineprotected

◆ make_structure()

template<typename T >
void madness::SRConf< T >::make_structure ( bool  force = false)
inlineprotected

◆ make_vector_dimensions()

template<typename T >
std::array< std::array< long, TENSOR_MAXDIM >, 2 > madness::SRConf< T >::make_vector_dimensions ( const long  rank) const
inline

◆ make_vector_with_weights()

template<typename T >
Tensor< T > madness::SRConf< T >::make_vector_with_weights ( const int  dim) const
inline

◆ max_sigma()

template<typename T >
static int madness::SRConf< T >::max_sigma ( const double &  thresh,
const long &  rank,
const Tensor< double > &  w 
)
inlinestatic

return the index of the last singular vector/value to meet the threshold (returns -1 if all meet threshold, i.e. || A ||_2 < threshold) given a matrix A in SVD form, truncate the singular values such that the accuracy threshold is still met.

Parameters
[in]threshthe threshold eps: || A - A(truncated) || < eps
[in]rankthe number of singular values in w
[in]wthe weights/singular values of A
Returns
i the index of s_max to contribute: w(Slice(0,i)); i.e. inclusive!

References madness::SRConf< T >::rank(), residual(), thresh, and w().

Referenced by madness::SeparatedConvolution< Q, NDIM >::apply2(), madness::SVDTensor< T >::compute_svd(), madness::TensorTrain< T >::decompose(), madness::SeparatedConvolution< Q, NDIM >::estimate_costs(), madness::ortho3(), madness::rank_revealing_decompose(), madness::TensorTrain< T >::splitdim(), test_stuff(), madness::TensorTrain< T >::truncate(), and madness::SVDTensor< T >::truncate_svd().

◆ nCoeff()

template<typename T >
unsigned int madness::SRConf< T >::nCoeff ( ) const
inlineprotected

return the number of coefficients

References madness::SRConf< T >::vector_, and madness::SRConf< T >::weights_.

Referenced by madness::SVDTensor< T >::nCoeff().

◆ normalize()

template<typename T >
void madness::SRConf< T >::normalize ( )
inlineprotected

◆ normf()

template<typename T >
TensorTypeData< T >::float_scalar_type madness::SRConf< T >::normf ( ) const
inlineprotected

◆ operator=() [1/2]

template<typename T >
SRConf & madness::SRConf< T >::operator= ( const SRConf< T > &  rhs)
inline

◆ operator=() [2/2]

template<typename T >
SRConf & madness::SRConf< T >::operator= ( const T number)
inline

◆ rank()

template<typename T >
long madness::SRConf< T >::rank ( ) const
inline

◆ real_size()

template<typename T >
size_t madness::SRConf< T >::real_size ( ) const
inlineprotected

◆ reconstruct()

template<typename T >
Tensor< T > madness::SRConf< T >::reconstruct ( ) const
inline

◆ ref_vector() [1/2]

template<typename T >
Tensor< T > & madness::SRConf< T >::ref_vector ( const unsigned int &  idim)
inline

◆ ref_vector() [2/2]

template<typename T >
const Tensor< T > & madness::SRConf< T >::ref_vector ( const unsigned int &  idim) const
inline

return reference to one of the vectors F

References madness::SRConf< T >::vector_.

◆ scale() [1/2]

template<typename T >
void madness::SRConf< T >::scale ( const double &  fac)
inlineprotected

◆ scale() [2/2]

template<typename T >
void madness::SRConf< T >::scale ( const double_complex fac)
inlineprotected

References MADNESS_EXCEPTION.

◆ serialize()

template<typename T >
template<typename Archive >
void madness::SRConf< T >::serialize ( Archive &  ar)
inline

◆ set_size_and_dim()

template<typename T >
void madness::SRConf< T >::set_size_and_dim ( long  ndim,
long  k 
)
inline

◆ set_vectors_and_weights()

template<typename T >
void madness::SRConf< T >::set_vectors_and_weights ( const Tensor< typename Tensor< T >::scalar_type > &  weights,
const Tensor< T > &  vector1,
const Tensor< T > &  vector2 
)
inline

◆ svd_normf()

template<typename T >
TensorTypeData< T >::float_scalar_type madness::SRConf< T >::svd_normf ( ) const
inlineprotected

calculate the Frobenius norm, if this is in SVD form

References madness::SRConf< T >::has_no_data(), madness::SRConf< T >::rank(), and madness::SRConf< T >::weights_.

◆ trace() [1/2]

template<typename T >
template<typename Q >
std::enable_if<(TensorTypeData< T >::iscomplexorTensorTypeData< Q >::iscomplex), TENSOR_RESULT_TYPE(T, Q)>::type friend madness::SRConf< T >::trace ( const SRConf< T > &  rhs,
const SRConf< Q > &  lhs 
)
inlineprotected

References MADNESS_EXCEPTION, and T().

◆ trace() [2/2]

template<typename T >
template<typename Q >
std::enable_if<!(TensorTypeData< T >::iscomplexorTensorTypeData< Q >::iscomplex), TENSOR_RESULT_TYPE(T, Q)>::type friend madness::SRConf< T >::trace ( const SRConf< T > &  rhs,
const SRConf< Q > &  lhs 
)
inlineprotected

◆ transform()

template<typename T >
SRConf< T > madness::SRConf< T >::transform ( const Tensor< T > &  c) const
inlineprotected

◆ transform_dir()

template<typename T >
SRConf< T > madness::SRConf< T >::transform_dir ( const Tensor< T > &  c,
const int &  axis 
) const
inline

◆ weights()

template<typename T >
double madness::SRConf< T >::weights ( const unsigned int &  i) const
inline

return the weight

References madness::SRConf< T >::weights_.

Referenced by madness::FunctionImpl< T, NDIM >::tnorm().

Friends And Related Symbol Documentation

◆ compatible

template<typename T >
bool compatible ( const SRConf< T > &  lhs,
const SRConf< T > &  rhs 
)
friend

◆ copy

template<typename T >
SRConf< T > copy ( const SRConf< T > &  rhs)
friend

◆ GenTensor< T >

template<typename T >
friend class GenTensor< T >
friend

◆ SliceLowRankTensor< T >

template<typename T >
friend class SliceLowRankTensor< T >
friend

Member Data Documentation

◆ check_orthonormality

template<typename T >
const bool madness::SRConf< T >::check_orthonormality =false
static

check orthonormality at low rank additions

Referenced by madness::SRConf< T >::add_SVD().

◆ nci_left

template<typename T >
long madness::SRConf< T >::nci_left =-1

◆ s0

template<typename T >
std::vector<Slice> madness::SRConf< T >::s0

Slice containing the actual data in each vector, ignoring "empty" configurations; will maintain contiguity of the data.

Referenced by madness::SRConf< T >::append(), madness::SRConf< T >::c0(), madness::SRConf< T >::inplace_add(), madness::SRConf< T >::make_slices(), madness::SRConf< T >::operator=(), and madness::SRConf< T >::serialize().

◆ s1

template<typename T >
std::vector<Slice> madness::SRConf< T >::s1

◆ vector_

template<typename T >
std::array<Tensor<T>,2> madness::SRConf< T >::vector_

◆ weights_

template<typename T >
Tensor< typename Tensor<T>::scalar_type > madness::SRConf< T >::weights_

The documentation for this class was generated from the following files: