|
MADNESS 0.10.1
|
#include <tensortrain.h>


Public Member Functions | |
| TensorTrain () | |
| empty constructor | |
| TensorTrain (const long &ndims, const long *dims) | |
| ctor for a TensorTrain, set up only the dimensions, no data | |
| TensorTrain (const std::vector< long > &dims) | |
| ctor for a TensorTrain, set up only the dimensions, no data | |
| TensorTrain (const std::vector< Tensor< T > > &c) | |
| ctor for a TensorTrain, with core tensors explicitly given | |
| TensorTrain (const Tensor< T > &t, double eps) | |
| ctor for a TensorTrain, with the tolerance eps | |
| TensorTrain (const Tensor< T > &t, double eps, const std::vector< long > dims) | |
| ctor for a TensorTrain, with the tolerance eps | |
| TensorTrain (const TensorTrain &other) | |
| copy constructor, shallow | |
| void | decompose (const Tensor< T > &t, double eps, const std::vector< long > &dims) |
| decompose the input tensor into a TT representation | |
| TensorTrain< T > & | emul (const TensorTrain< T > &other) |
| compute the Hadamard product of two TensorTrains | |
| void | fusedim (const long i) |
| merge two dimensions into one | |
| TensorTrain< T > & | gaxpy (const std::array< Slice, TENSOR_MAXDIM > &s1, const TensorTrain< T > &rhs, T beta, const std::array< Slice, TENSOR_MAXDIM > &s2) |
| Inplace generalized saxpy with slices and without alpha. | |
| TensorTrain< T > & | gaxpy (T alpha, const TensorTrain< T > &rhs, T beta) |
| Inplace generalized saxpy ... this = this*alpha + other*beta. | |
| Tensor< T > & | get_core (const int i) |
| reference to the internal core | |
| const Tensor< T > & | get_core (const int i) const |
| const reference to the internal core | |
| bool | is_operator () const |
| check if this is an operator (r,k',k,r) | |
| bool | is_tensor () const |
| check if this is a tensor (r,k,r) | |
| bool | is_zero_rank () const |
| if rank is zero | |
| TensorTrain< T > & | make_operator () |
| convert this into an operator representation (r,k',k,r) | |
| TensorTrain< T > & | make_tensor () |
| convert this into a tensor representation (r,k,r) | |
| float_scalar_type | normf () const |
| returns the Frobenius norm | |
| template<class Q> | |
| operator TensorTrain< Q > () const | |
| Type conversion makes a deep copy. | |
| TensorTrain< T > | operator* (const T &factor) const |
| return this multiplied by a scalar | |
| TensorTrain< T > & | operator+= (const TensorTrain< T > &rhs) |
| inplace addition of two Tensortrains; will increase ranks of this | |
| TensorTrain< T > & | operator-= (const TensorTrain< T > &rhs) |
| inplace subtraction of two Tensortrains; will increase ranks of this | |
| TensorTrain< T > & | operator= (const T &number) |
| assign a number to this tensor | |
| TensorTrain & | operator= (const TensorTrain &other) |
| assigment operator | |
| T * | ptr (const int ivec=0) |
| Returns a pointer to the internal data. | |
| const T * | ptr (const int ivec=0) const |
| Returns a pointer to the internal data. | |
| std::vector< long > | ranks () const |
| return the TT ranks | |
| long | ranks (const int i) const |
| return the TT ranks for dimension i (to i+1) | |
| long | real_size () const |
| return the size of this instance, including static memory for vectors and such | |
| Tensor< T > | reconstruct (const bool flat=false) const |
| reconstruct this to a full representation | |
| void | scale (T fac) |
| scale this by a number | |
| template<typename Archive> | |
| void | serialize (Archive &ar) |
| serialize this | |
| void | set_size_and_dim (std::vector< long > dims) |
| long | size () const |
| return the number of coefficients in all core tensors | |
| TensorTrain< T > | splitdim (long idim, long k1, long k2, const double eps) const |
| template<class Q> | |
| std::enable_if<!(TensorTypeData< T >::iscomplexorTensorTypeData< Q >::iscomplex), TENSOR_RESULT_TYPE(T, Q)>::type | trace (const TensorTrain< Q > &B) const |
| Return the trace of two tensors, no complex conjugate involved. | |
| template<class Q> | |
| std::enable_if<(TensorTypeData< T >::iscomplexorTensorTypeData< Q >::iscomplex), TENSOR_RESULT_TYPE(T, Q)>::type | trace (const TensorTrain< Q > &B) const |
| template<typename R = T> | |
| std::enable_if< std::is_arithmetic< R >::value, void >::type | truncate (double eps) |
| recompress and truncate this TT representation | |
| template<typename R = T> | |
| std::enable_if<!std::is_arithmetic< R >::value, void >::type | truncate (double eps) |
| recompress and truncate this TT representation | |
| void | two_mode_representation (Tensor< T > &U, Tensor< T > &VT, Tensor< typename Tensor< T >::scalar_type > &s) const |
| construct a two-mode representation (aka unnormalized SVD) | |
| bool | verify () const |
| return the dimensions of this tensor | |
| void | zero_me () |
| turn this into an empty tensor with all cores properly shaped | |
| void | zero_me (const std::vector< long > &dim) |
| turn this into an empty tensor with all cores properly shaped | |
| 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. | |
Private Types | |
| typedef TensorTypeData< T >::float_scalar_type | float_scalar_type |
| C++ typename of the floating point type associated with scalar real type. | |
| typedef TensorTypeData< T >::scalar_type | scalar_type |
| C++ typename of the real type associated with a complex type. | |
| typedef T | type |
| C++ typename of this tensor. | |
Private Attributes | |
| std::vector< Tensor< T > > | core |
| bool | zero_rank |
| true if rank is zero | |
Friends | |
| template<typename Q> | |
| class | TensorTrain |
| TensorTrain | copy (const TensorTrain &other) |
| deep copy of the whole tensor | |
| TensorTrain | copy (const TensorTrain &other, const std::array< Slice, TENSOR_MAXDIM > &s) |
| deep copy of a slice of the tensor | |
| template<typename R, typename Q> | |
| TensorTrain< TENSOR_RESULT_TYPE(R, Q)> | general_transform (const TensorTrain< R > &t, const Tensor< Q > c[]) |
| template<typename R, typename Q> | |
| TensorTrain< TENSOR_RESULT_TYPE(R, Q)> | outer (const TensorTrain< R > &t1, const TensorTrain< Q > &t2) |
| template<typename R, typename Q> | |
| TensorTrain< TENSOR_RESULT_TYPE(R, Q)> | transform (const TensorTrain< R > &t, const Tensor< Q > &c) |
| template<typename R, typename Q> | |
| TensorTrain< TENSOR_RESULT_TYPE(R, Q)> | transform_dir (const TensorTrain< R > &t, const Tensor< Q > &c, const int axis) |
Additional Inherited Members | |
| 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. | |
| 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. | |
| 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. | |
A tensor train is a multi-modal representation of a tensor t
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
|
private |
C++ typename of the floating point type associated with scalar real type.
|
private |
C++ typename of the real type associated with a complex type.
|
private |
C++ typename of this tensor.
|
inline |
empty constructor
References core, set_size_and_dim(), and zero_rank.
|
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.
| [in] | t | full representation of a tensor |
| [in] | eps | the accuracy threshold |
References core, d, decompose(), madness::BaseTensor::dim(), madness::BaseTensor::dims(), madness::Tensor< T >::flat(), MADNESS_ASSERT, madness::BaseTensor::ndim(), madness::BaseTensor::set_dims_and_size(), madness::BaseTensor::size(), and zero_rank.
|
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.
| [in] | t | full representation of a tensor |
| [in] | eps | the accuracy threshold |
| [in] | dims | the tt structure |
References core, decompose(), madness::BaseTensor::dims(), MADNESS_ASSERT, madness::BaseTensor::ndim(), madness::BaseTensor::set_dims_and_size(), madness::BaseTensor::size(), and zero_rank.
|
inline |
ctor for a TensorTrain, set up only the dimensions, no data
References madness::BaseTensor::dims(), madness::BaseTensor::set_dims_and_size(), and zero_rank.
|
inline |
ctor for a TensorTrain, set up only the dimensions, no data
References madness::BaseTensor::dims(), set_size_and_dim(), and zero_rank.
|
inline |
ctor for a TensorTrain, with core tensors explicitly given
the core tensors must have the shape (k1,r1) (r1,k2,r2) .. (r2,k3)
| [in] | core | vector of core tensors, properly shaped |
References c, core, d, madness::BaseTensor::dim(), set_size_and_dim(), zero_me(), and zero_rank.
|
inline |
copy constructor, shallow
References TensorTrain, core, madness::BaseTensor::dims(), madness::BaseTensor::ndim(), madness::BaseTensor::set_dims_and_size(), and zero_rank.
|
inline |
decompose the input tensor into a TT representation
| [in] | t | tensor in full rank |
| [in] | eps | the precision threshold |
| [in] | dims | the tt structure |
References madness::_(), aa, b, c, madness::copy(), copy, core, d, madness::BaseTensor::dims(), madness::FunctionDefaults< NDIM >::k, madness::SRConf< T >::max_sigma(), madness::print(), madness::BaseTensor::size(), madness::svd_result(), u(), and zero_rank.
Referenced by TensorTrain(), and TensorTrain().
|
inline |
compute the Hadamard product of two TensorTrains
see Sec. 4.2 of the TT paper
References TensorTrain, madness::_(), a1, copy, core, madness::BaseTensor::dim(), madness::BaseTensor::dims(), madness::FunctionDefaults< NDIM >::k, fusedim(), MADNESS_ASSERT, MADNESS_CHECK_THROW, madness::BaseTensor::ndim(), outer, ranks(), madness::Tensor< T >::reshape(), size(), and zero_rank.
|
inline |
merge two dimensions into one
merge dimension i and i+1 into new dimension i
| [in] | i | the first dimension |
(r1=0, k1*k2, r2=0)
References core, d, madness::BaseTensor::dim(), madness::BaseTensor::fusedim_inplace(), madness::inner(), and zero_rank.
Referenced by emul(), and make_tensor().
|
inline |
Inplace generalized saxpy with slices and without alpha.
return this = this(s1) + other(s2) * beta
References TensorTrain, madness::_(), beta, core, d, madness::BaseTensor::dim(), madness::FunctionDefaults< NDIM >::k, MADNESS_ASSERT, MADNESS_EXCEPTION, madness::BaseTensor::ndim(), verify(), and zero_rank.
|
inline |
Inplace generalized saxpy ... this = this*alpha + other*beta.
References TensorTrain, madness::_(), alpha, beta, core, d, madness::FunctionDefaults< NDIM >::k, MADNESS_ASSERT, MADNESS_EXCEPTION, madness::BaseTensor::ndim(), scale(), verify(), and zero_rank.
Referenced by operator+=(), and operator-=().
|
inline |
reference to the internal core
References core, MADNESS_ASSERT, and madness::BaseTensor::ndim().
Referenced by madness::apply(), and madness::tt_identity().
|
inline |
const reference to the internal core
References core, MADNESS_ASSERT, and madness::BaseTensor::ndim().
|
inline |
|
inline |
check if this is a tensor (r,k,r)
References core, and madness::BaseTensor::ndim().
Referenced by is_operator(), and make_tensor().
|
inline |
if rank is zero
References zero_rank.
|
inline |
convert this into an operator representation (r,k',k,r)
References TensorTrain, core, is_operator(), k0, k2, MADNESS_ASSERT, and madness::BaseTensor::ndim().
|
inline |
convert this into a tensor representation (r,k,r)
References TensorTrain, core, fusedim(), is_tensor(), and madness::BaseTensor::ndim().
|
inline |
returns the Frobenius norm
References std::abs(), and trace().
|
inline |
Type conversion makes a deep copy.
References TensorTrain, c, core, madness::BaseTensor::dims(), and zero_rank.
|
inline |
|
inline |
inplace addition of two Tensortrains; will increase ranks of this
inefficient if many additions are performed, since it requires many calls of new.
| [in] | rhs | a TensorTrain to be added |
References TensorTrain, and gaxpy().
|
inline |
inplace subtraction of two Tensortrains; will increase ranks of this
inefficient if many subtractions are performed, since it requires many calls of new.
| [in] | rhs | a TensorTrain to be added |
References TensorTrain, and gaxpy().
|
inline |
assign a number to this tensor
References TensorTrain, core, madness::BaseTensor::dim(), madness::BaseTensor::ndim(), and zero_rank.
|
inline |
assigment operator
References TensorTrain, core, madness::BaseTensor::dims(), madness::BaseTensor::ndim(), madness::BaseTensor::set_dims_and_size(), and zero_rank.
|
inline |
Returns a pointer to the internal data.
| [in] | ivec | index of core vector to which the return values points |
References core.
|
inline |
Returns a pointer to the internal data.
| [in] | ivec | index of core vector to which the return values points |
References core.
|
inline |
return the TT ranks
References core, madness::BaseTensor::dim(), madness::BaseTensor::ndim(), and zero_rank.
Referenced by madness::apply(), emul(), splitdim(), and truncate().
|
inline |
return the TT ranks for dimension i (to i+1)
References core, MADNESS_EXCEPTION, madness::BaseTensor::ndim(), madness::print(), and zero_rank.
|
inline |
|
inline |
reconstruct this to a full representation
| [in] | flat | return this in flat representation |
References madness::BaseTensor::_size, core, madness::BaseTensor::dim(), madness::BaseTensor::dims(), madness::Tensor< T >::fusedim(), madness::inner(), MADNESS_ASSERT, madness::BaseTensor::ndim(), size(), and zero_rank.
|
inline |
scale this by a number
| [in] | fac | the factor to multiply |
References core, and zero_rank.
Referenced by gaxpy(), and operator*().
|
inline |
serialize this
References madness::BaseTensor::_dim, madness::BaseTensor::_id, madness::BaseTensor::_ndim, madness::BaseTensor::_size, madness::BaseTensor::_stride, core, TENSOR_MAXDIM, madness::archive::wrap(), and zero_rank.
|
inline |
References madness::BaseTensor::dims(), and madness::BaseTensor::set_dims_and_size().
Referenced by TensorTrain(), TensorTrain(), and TensorTrain().
|
inline |
return the number of coefficients in all core tensors
References core, and zero_rank.
Referenced by emul(), real_size(), reconstruct(), truncate(), and verify().
|
inline |
Returns new view/tensor splitting dimension i as dimi0*dimi1 to produce conforming d+1 dimension tensor
| [in] | idim | the dimension to be split |
| [in] | k1 | new first dimension of idim |
| [in] | k2 | new second dimension of idim |
| [in] | eps | threshold for SVD (choose negative to keep all terms) |
References TensorTrain, madness::_(), copy, core, madness::BaseTensor::dim(), madness::BaseTensor::dims(), k1, k2, MADNESS_ASSERT, madness::SRConf< T >::max_sigma(), madness::BaseTensor::ndim(), madness::r2(), ranks(), madness::BaseTensor::splitdim_inplace(), madness::svd(), and zero_rank.
|
inline |
Return the trace of two tensors, no complex conjugate involved.
References TensorTrain, d, madness::BaseTensor::dim(), madness::Tensor< T >::fusedim(), madness::inner_result(), MADNESS_ASSERT, MADNESS_EXCEPTION, madness::BaseTensor::ndim(), Q(), madness::Tensor< T >::reshape(), and TENSOR_RESULT_TYPE.
|
inline |
References TensorTrain, and MADNESS_EXCEPTION.
Referenced by normf().
|
inline |
recompress and truncate this TT representation
this in recompressed TT form with optimal rank
| [in] | eps | the truncation threshold |
References madness::_(), madness::copy(), core, d, madness::BaseTensor::dim(), madness::Tensor< T >::flat(), madness::FunctionDefaults< NDIM >::k, madness::inner(), madness::kmax, L, madness::lq_result(), m, MADNESS_EXCEPTION, madness::SRConf< T >::max_sigma(), madness::BaseTensor::ndim(), ranks(), madness::Tensor< T >::reshape(), size(), madness::svd_result(), TENSOR_MAXDIM, verify(), zero_me(), and zero_rank.
|
inline |
recompress and truncate this TT representation
this in recompressed TT form with optimal rank
| [in] | eps | the truncation threshold |
References MADNESS_EXCEPTION.
|
inline |
construct a two-mode representation (aka unnormalized SVD)
| [out] | U | The left singular vectors, ({i},rank) |
| [out] | VT | The right singular vectors, (rank,{i}) |
| [out] | s | Vector holding 1's, (rank) |
References core, madness::BaseTensor::dim(), madness::inner(), MADNESS_ASSERT, MADNESS_EXCEPTION, madness::BaseTensor::ndim(), and zero_rank.
|
inline |
return the dimensions of this tensor
check that the ranks of all core tensors are consistent
References c, core, d, madness::BaseTensor::dim(), madness::BaseTensor::ndim(), and size().
Referenced by gaxpy(), gaxpy(), and truncate().
|
inline |
turn this into an empty tensor with all cores properly shaped
References TensorTrain, madness::BaseTensor::dims(), and madness::BaseTensor::ndim().
Referenced by TensorTrain(), and truncate().
|
inline |
turn this into an empty tensor with all cores properly shaped
References TensorTrain, and madness::BaseTensor::dim().
References TensorTrain.
Referenced by TensorTrain(), TensorTrain, copy, copy, emul(), gaxpy(), gaxpy(), general_transform, make_operator(), make_tensor(), operator TensorTrain< Q >(), operator*(), operator+=(), operator-=(), operator=(), operator=(), outer, splitdim(), trace(), transform, transform_dir, zero_me(), and zero_me().
|
friend |
deep copy of the whole tensor
if argument has zero rank return a zero-rank tensor of the same dimensions
References TensorTrain, madness::copy(), core, madness::BaseTensor::dims(), madness::BaseTensor::ndim(), madness::BaseTensor::size(), and zero_rank.
Referenced by copy, decompose(), emul(), operator*(), and splitdim().
|
friend |
deep copy of a slice of the tensor
this operation does not change the ranks, i.e. the resulting tensor is most likely not in an optimal compression state
| [in] | other | tensor to be sliced |
| [in] | s | vector of slices |
References TensorTrain, madness::_(), copy, core, madness::BaseTensor::dims(), madness::BaseTensor::ndim(), and zero_rank.
|
friend |
References TensorTrain, c, Q(), and R.
|
friend |
References TensorTrain, Q(), and R.
Referenced by emul().
|
friend |
References TensorTrain, c, Q(), and R.
|
friend |
References TensorTrain, axis, c, Q(), and R.
|
private |
holding the core tensors of a tensor train the tensors have the shape (k,r0) (r0,k,r1) (r1,k,r2) .. (rn-1,k)
Referenced by TensorTrain(), TensorTrain(), TensorTrain(), TensorTrain(), TensorTrain(), copy, copy, decompose(), emul(), fusedim(), gaxpy(), gaxpy(), madness::general_transform(), get_core(), get_core(), is_tensor(), make_operator(), make_tensor(), operator TensorTrain< Q >(), operator=(), operator=(), madness::outer(), ptr(), ptr(), ranks(), ranks(), real_size(), reconstruct(), scale(), serialize(), size(), splitdim(), madness::transform(), madness::transform_dir(), truncate(), two_mode_representation(), and verify().
|
private |
true if rank is zero
Referenced by TensorTrain(), TensorTrain(), TensorTrain(), TensorTrain(), TensorTrain(), TensorTrain(), TensorTrain(), copy, copy, decompose(), emul(), fusedim(), gaxpy(), gaxpy(), madness::general_transform(), is_zero_rank(), operator TensorTrain< Q >(), operator=(), operator=(), madness::outer(), ranks(), ranks(), reconstruct(), scale(), serialize(), size(), splitdim(), madness::transform(), madness::transform_dir(), truncate(), and two_mode_representation().