MADNESS  version 0.9
Public Member Functions | List of all members
madness::TensorTrain< T > Class Template Reference

#include <tensortrain.h>

Public Member Functions

 TensorTrain (const Tensor< T > &t, double eps)
 ctor for a TensorTrain, with the tolerance eps More...
 
 TensorTrain (const Tensor< T > &t, double eps, const std::vector< long > dims)
 ctor for a TensorTrain, with the tolerance eps More...
 
void decompose (const Tensor< T > &t, double eps, const std::vector< long > &dims)
 decompose the input tensor into a TT representation More...
 
TensorTrain< T > & operator+= (const TensorTrain< T > &rhs)
 inplace addition of two Tensortrains; will increase ranks of this More...
 
void fusedim (const long i)
 merge two dimensions into one More...
 
Tensor< T > reconstruct (const bool flat=false) const
 reconstruct this to a full representation More...
 
void two_mode_representation (Tensor< T > &U, Tensor< T > &VT, Tensor< typename Tensor< T >::scalar_type > &s)
 construct a two-mode representation (aka unnormalized SVD) More...
 
void truncate (double eps)
 recompress and truncate this TT representation More...
 
long ndim () const
 return the number of dimensions More...
 
long size () const
 return the number of coefficients in all core tensors More...
 
long real_size () const
 return the size of this instance, including static memory for vectors and such More...
 
long dim (const int i) const
 return the number of entries in dimension i More...
 
bool is_zero_rank () const
 if rank is zero More...
 
std::vector< long > ranks () const
 return the TT ranks More...
 

Detailed Description

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

A tensor train is a multi-modal representation of a tensor t

t(i,j,k,l) = \sum G^1_{a1,i,a2} G^2_{a2,j,a3} G^3_{a3,k,a4} G^4_{a4,l,a5}

The "core" tensors G are connected via a linear index network, where the first index a1 and the last index a5 are boundary indices and are set to 1.

The tensor train representation is suited for any number of dimensions and in general at least as fast as the 2-way decomposition SVD. If the tensor has full rank it will need about twice the storage space of the full tensor

Constructor & Destructor Documentation

template<typename T>
madness::TensorTrain< T >::TensorTrain ( const Tensor< T > &  t,
double  eps 
)
inline

ctor for a TensorTrain, with the tolerance eps

The tensor train will represent the input tensor with accuracy || t - this ||_2 < eps

Note that we rely on specific layout of the memory in the tensors, e.g. we pass SliceTensors on to lapack. This will only work if the slices are contiguous.

Parameters
[in]tfull representation of a tensor
[in]epsthe accuracy threshold

References madness::TensorTrain< T >::decompose().

template<typename T>
madness::TensorTrain< T >::TensorTrain ( const Tensor< T > &  t,
double  eps,
const std::vector< long >  dims 
)
inline

ctor for a TensorTrain, with the tolerance eps

The tensor train will represent the input tensor with accuracy || t - this ||_2 < eps

Note that we rely on specific layout of the memory in the tensors, e.g. we pass SliceTensors on to lapack. This will only work if the slices are contiguous.

Parameters
[in]tfull representation of a tensor
[in]epsthe accuracy threshold
[in]dimsthe tt structure

References madness::TensorTrain< T >::decompose().

Member Function Documentation

template<typename T>
void madness::TensorTrain< T >::decompose ( const Tensor< T > &  t,
double  eps,
const std::vector< long > &  dims 
)
inline

decompose the input tensor into a TT representation

Parameters
[in]ttensor in full rank
[in]epsthe precision threshold
[in]dimsthe tt structure

References b(), c, madness::copy(), k, max, madness::SRConf< T >::max_sigma(), mpfr::min(), madness::print(), sqrt(), madness::svd_result(), and std::tr1::T().

Referenced by madness::TensorTrain< T >::TensorTrain().

template<typename T>
long madness::TensorTrain< T >::dim ( const int  i) const
inline
template<typename T>
void madness::TensorTrain< T >::fusedim ( const long  i)
inline

merge two dimensions into one

merge dimension i and i+1 into new dimension i

Parameters
[in]ithe first dimension

References madness::inner().

template<typename T>
bool madness::TensorTrain< T >::is_zero_rank ( ) const
inline

if rank is zero

template<typename T>
long madness::TensorTrain< T >::ndim ( ) const
inline
template<typename T>
TensorTrain<T>& madness::TensorTrain< T >::operator+= ( const TensorTrain< T > &  rhs)
inline

inplace addition of two Tensortrains; will increase ranks of this

inefficient if many additions are performed, since it requires many calls of new.

Parameters
[in]rhsa TensorTrain to be added

References k, and madness::TensorTrain< T >::ndim().

template<typename T>
std::vector<long> madness::TensorTrain< T >::ranks ( ) const
inline

return the TT ranks

References madness::TensorTrain< T >::dim().

template<typename T>
long madness::TensorTrain< T >::real_size ( ) const
inline

return the size of this instance, including static memory for vectors and such

References madness::TensorTrain< T >::size(), and std::tr1::T().

template<typename T>
Tensor<T> madness::TensorTrain< T >::reconstruct ( const bool  flat = false) const
inline

reconstruct this to a full representation

Parameters
[in]flatreturn this in flat representation
Returns
this in full rank representation

References madness::TensorTrain< T >::dim(), madness::inner(), madness::TensorTrain< T >::ndim(), and madness::TensorTrain< T >::size().

template<typename T>
long madness::TensorTrain< T >::size ( ) const
inline

return the number of coefficients in all core tensors

Referenced by madness::TensorTrain< T >::real_size(), madness::TensorTrain< T >::reconstruct(), and madness::TensorTrain< T >::truncate().

template<typename T>
void madness::TensorTrain< T >::truncate ( double  eps)
inline

recompress and truncate this TT representation

Parameters
[in]epsthe truncation threshold
Returns
this in recompressed TT form with optimal rank

References madness::copy(), madness::TensorTrain< T >::dim(), madness::inner(), madness::lq(), madness::SRConf< T >::max_sigma(), mpfr::min(), madness::TensorTrain< T >::ndim(), R, madness::TensorTrain< T >::size(), sqrt(), madness::svd(), and TENSOR_MAXDIM.

template<typename T>
void madness::TensorTrain< T >::two_mode_representation ( Tensor< T > &  U,
Tensor< T > &  VT,
Tensor< typename Tensor< T >::scalar_type > &  s 
)
inline

construct a two-mode representation (aka unnormalized SVD)

Parameters
[out]U({i},rank)the left singular vectors
[out]VT(rank,{i})the right singular vectors
[out]s(rank)vector holding 1's

References madness::inner(), and madness::TensorTrain< T >::ndim().


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