MADNESS 0.10.1
madness::GenTensor< T > Class Template Reference

#include <gentensor.h>

Inheritance diagram for madness::GenTensor< T >:
Collaboration diagram for madness::GenTensor< T >:

Public 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.
Public Types inherited from madness::Tensor< T >
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.

Public Member Functions

 GenTensor ()
 GenTensor ()=default
 empty ctor
 GenTensor (const GenTensor< T > &other)=default
 copy ctor, shallow
 GenTensor (const long ndim, const long *dims, const TensorType &tt)
 GenTensor (const SliceLowRankTensor< T > &other)
 ctor with a SliceLowRankTensor as argument, deep
 GenTensor (const SRConf< T > &)
 GenTensor (const std::vector< long > &dim, const TensorArgs &targs)
 ctor with dimensions; constructs tensor filled with zeros
 GenTensor (const std::vector< long > &dim, const TensorType &tt)
 ctor with dimensions; constructs tensor filled with zeros
 GenTensor (const SVDTensor< T > &other)
 ctor with a SVDTensor as argument, shallow
 GenTensor (const Tensor< T > &other)
 ctor with a regular Tensor, deep
 GenTensor (const Tensor< T > &rhs, const double &thresh, const TensorType &tt)
 ctor with a regular Tensor and arguments, deep
 GenTensor (const Tensor< T > &rhs, const TensorArgs &targs)
 ctor with a regular Tensor and arguments, deep
 GenTensor (const Tensor< T > &t1)
 GenTensor (const Tensor< T > &t1, const TensorArgs &)
 GenTensor (const Tensor< T > &t1, double, const TensorType)
 GenTensor (const TensorTrain< T > &other)
 ctor with a TensorTrain as argument, shallow
 GenTensor (const TensorType &tt, const long k, const long ndim)
 ctor with dimensions; all dims have the same value k
 GenTensor (const TensorType)
 GenTensor (long nd, const long d[], const TensorType &)
 GenTensor (std::vector< long > v, const TensorArgs &)
 GenTensor (std::vector< long > v, const TensorType &)
void add_SVD (const GenTensor &other, const double &thresh)
void add_SVD (const GenTensor< T > &rhs, const double &)
SRConf< T > config () const
GenTensor convert (const TensorArgs &) const
GenTensor convert (const TensorArgs &targs) const
 convert this to a new LowRankTensor of given tensor type
GenTensor & convert_inplace (const TensorArgs &targs)
long dim (const int i) const
 return the number of entries in dimension i
const long * dims () const
 return the number of entries in dimension i
GenTensor< T > & emul (const GenTensor< T > &other)
 Inplace multiply by corresponding elements of argument Tensor.
Tensor< T > & full_tensor ()
Tensor< T > & full_tensor ()
const Tensor< T > & full_tensor () const
Tensor< T > full_tensor () const
Tensor< T > full_tensor_copy ()
Tensor< T > full_tensor_copy () const
Tensor< T > full_tensor_copy () const
GenTensor & gaxpy (const T alpha, const GenTensor &other, const T beta)
GenTensor & gaxpy (const T alpha, std::array< Slice, TENSOR_MAXDIM > s0, const GenTensor &other, const T beta, std::array< Slice, TENSOR_MAXDIM > s1)
SRConf< T > get_configs (const int &, const int &) const
SVDTensor< T > & get_svdtensor ()
SVDTensor< T > & get_svdtensor ()
const SVDTensor< T > & get_svdtensor () const
const SVDTensor< T > & get_svdtensor () const
Tensor< T > & get_tensor ()
Tensor< T > & get_tensor ()
const Tensor< T > & get_tensor () const
const Tensor< T > & get_tensor () const
SVDTensor< T > & get_tensortrain ()
TensorTrain< T > & get_tensortrain ()
const SVDTensor< T > & get_tensortrain () const
const TensorTrain< T > & get_tensortrain () const
bool has_data () const
bool has_data () const
bool has_no_data () const
bool has_no_data () const
int index () const
bool is_assigned () const
bool is_assigned () const
constexpr bool is_full_tensor () const
constexpr bool is_full_tensor () const
bool is_of_tensortype (const TensorType &tt) const
bool is_of_tensortype (const TensorType &tt) const
constexpr bool is_svd_tensor () const
constexpr bool is_svd_tensor () const
constexpr bool is_tensortrain () const
constexpr bool is_tensortrain () const
size_t nCoeff () const
long nCoeff () const
long ndim () const
void normalize ()
void normalize ()
float_scalar_type normf () const
template<class Q>
 operator GenTensor< Q > () const
 Type conversion makes a deep copy.
template<class Q>
 operator GenTensor< Q > () const
 Type conversion makes a deep copy.
SliceLowRankTensor< T > operator() (const std::vector< Slice > &s)
 general slicing, shallow; for temporary use only!
const SliceLowRankTensor< T > operator() (const std::vector< Slice > &s) const
 general slicing, shallow; for temporary use only!
template<typename Q>
GenTensor< TENSOR_RESULT_TYPE(T, Q)> operator* (const Q &x) const
 multiply with a number
GenTensor operator+ (const GenTensor &other)
GenTensor operator+ (const SliceLowRankTensor< T > &other)
GenTensor & operator+= (const GenTensor &other)
GenTensor & operator+= (const SliceLowRankTensor< T > &other)
GenTensor operator- (const GenTensor &other)
GenTensor & operator-= (const GenTensor &other)
GenTensor & operator-= (const SliceLowRankTensor< T > &other)
GenTensor & operator= (const GenTensor< T > &other)
 shallow assignment operator
GenTensor & operator= (const SliceLowRankTensor< T > &other)
 deep assignment with slices: g0 = g1(s)
GenTensor & operator= (const SVDTensor< T > &other)
 deep assignment operator
GenTensor & operator= (const T &number)
 assign a number to this tensor
GenTensor & operator= (const Tensor< T > &other)
 deep assignment operator
GenTensor & operator= (const TensorTrain< T > &other)
 deep assignment operator
const BaseTensor * ptr () const
 might return a NULL pointer!
long rank () const
long rank () const
size_t real_size () const
long real_size () const
Tensor< T > reconstruct_tensor () const
Tensor< T > reconstruct_tensor () const
 reconstruct this to return a full tensor
void reduce_rank (const double &)
void reduce_rank (const double &thresh)
template<typename Q>
IsSupported< TensorTypeData< Q >, GenTensor< T > & >::type scale (Q fac)
 Inplace multiplication by scalar of supported type (legacy name).
long size () const
double svd_normf () const
float_scalar_type svd_normf () const
template<typename Q>
 TENSOR_RESULT_TYPE (T, Q) trace_conj(const GenTensor< Q > &rhs) const
 returns the trace of <this|rhs>
TensorType tensor_type () const
TensorType tensor_type () const
 return the tensor type
std::string what_am_i () const
std::string what_am_i () const
Public Member Functions inherited from madness::Tensor< T >
 Tensor ()
 Default constructor does not allocate any data and sets ndim=-1, size=0, _p=0, and id.
 Tensor (const std::vector< long > &d, bool dozero=true)
 Create and optionally zero new n-d tensor. This is the most general constructor.
 Tensor (const Tensor< T > &t)
 Copy constructor is shallow (same as assignment).
 Tensor (long d0)
 Create and zero new 1-d tensor.
 Tensor (long d0, long d1)
 Create and zero new 2-d tensor.
 Tensor (long d0, long d1, long d2)
 Create and zero new 3-d tensor.
 Tensor (long d0, long d1, long d2, long d3)
 Create and zero new 4-d tensor.
 Tensor (long d0, long d1, long d2, long d3, long d4)
 Create and zero new 5-d tensor.
 Tensor (long d0, long d1, long d2, long d3, long d4, long d5)
 Create and zero new 6-d tensor.
 Tensor (long nd, const long d[], bool dozero=true)
 Politically incorrect general constructor.
virtual ~Tensor ()
scalar_type absmax (long *ind=0) const
 Return the absolute maximum value (and if ind is non-null, its index) in the Tensor.
scalar_type absmin (long *ind=0) const
 Return the absolute minimum value (and if ind is non-null, its index) in the Tensor.
BaseTensor * base ()
 Returns a pointer to the base class.
const BaseTensor * base () const
 Returns a pointer to the base class.
template<class Q>
TensorIterator< T, Q > binary_iterator (const Tensor< Q > &q, long iterlevel=0, bool optimize=true, bool fusedim=true, long jdim=default_jdim) const
 Return iterator over two tensors.
void clear ()
 Frees all memory and resests to state of default constructor.
template<class Q>
bool conforms (const Tensor< Q > &t) const
 Test if *this and t conform.
Tensor< T > & conj ()
 Inplace complex conjugate.
Tensor< T > cycledim (long nshift, long start, long end)
 Returns new view/tensor cycling the sub-dimensions (start,...,end) with shift steps.
const Tensor< T > cycledim (long nshift, long start, long end) const
 Returns new view/tensor cycling the sub-dimensions (start,...,end) with shift steps.
Tensor< T > & emul (const Tensor< T > &t)
 Inplace multiply by corresponding elements of argument Tensor.
const TensorIterator< T > & end () const
 End point for forward iteration.
Tensor< T > & fill (T x)
 Inplace fill with a scalar (legacy name).
Tensor< T > & fillindex ()
 Inplace fill with the index of each element.
Tensor< T > & fillrandom ()
 Inplace fill with random values ( [0,1] for floats, [0,MAXSIZE] for integers).
Tensor< T > flat ()
 Returns new view/tensor rehshaping to flat (1-d) tensor.
const Tensor< T > flat () const
 Returns new view/tensor rehshaping to flat (1-d) tensor.
Tensor< T > fusedim (long i)
 Returns new view/tensor fusing contiguous dimensions i and i+1.
const Tensor< T > fusedim (long i) const
 Returns new view/tensor fusing contiguous dimensions i and i+1.
Tensor< T > & gaxpy (T alpha, const Tensor< T > &other, T beta)
 Inplace generalized saxpy ... this = this*alpha + other*beta.
bool has_data () const
Tensor< T > mapdim (const std::vector< long > &map)
 Returns new view/tensor permuting the dimensions.
const Tensor< T > mapdim (const std::vector< long > &map) const
 Returns new view/tensor permuting the dimensions.
double_complex max (long *ind) const
float_complex max (long *ind) const
double_complex max (long *ind) const
float_complex max (long *ind) const
T max (long *ind=0) const
 Return the maximum value (and if ind is non-null, its index) in the Tensor.
double_complex min (long *ind) const
float_complex min (long *ind) const
double_complex min (long *ind) const
float_complex min (long *ind) const
T min (long *ind=0) const
 Return the minimum value (and if ind is non-null, its index) in the Tensor.
float_scalar_type normf () const
 Returns the Frobenius norm of the tensor.
 operator bool () const noexcept
 convenience for testing if tensor is empty (i.e., has no data)
template<class Q>
 operator Tensor< Q > () const
 Type conversion makes a deep copy.
bool operator! () const noexcept
 convenience for testing if tensor is empty (i.e., has no data)
T & operator() (const long ind[])
 Politically incorrect general indexing operation without bounds checking.
const T & operator() (const long ind[]) const
 Politically incorrect general indexing operation without bounds checking.
SliceTensor< T > operator() (const Slice &s0)
 Return a 1d SliceTensor that views the specified range of the 1d Tensor.
const Tensor< T > operator() (const Slice &s0) const
 Return a 1d SliceTensor that views the specified range of the 1d Tensor.
SliceTensor< T > operator() (const Slice &s0, const Slice &s1)
 Return a 2d SliceTensor that views the specified range of the 2d Tensor.
const Tensor< T > operator() (const Slice &s0, const Slice &s1) const
 Return a 2d constant Tensor that views the specified range of the 2d Tensor.
SliceTensor< T > operator() (const Slice &s0, const Slice &s1, const Slice &s2)
 Return a 3d SliceTensor that views the specified range of the 3d Tensor.
const Tensor< T > operator() (const Slice &s0, const Slice &s1, const Slice &s2) const
 Return a 3d constant Tensor that views the specified range of the 3d Tensor.
SliceTensor< T > operator() (const Slice &s0, const Slice &s1, const Slice &s2, const Slice &s3)
 Return a 1-4d SliceTensor that views the specified range of the 4d Tensor.
const Tensor< T > operator() (const Slice &s0, const Slice &s1, const Slice &s2, const Slice &s3) const
 Return a 1-4d constant Tensor that views the specified range of the 4d Tensor.
SliceTensor< T > operator() (const Slice &s0, const Slice &s1, const Slice &s2, const Slice &s3, const Slice &s4)
 Return a 1-5d SliceTensor that views the specified range of the 5d Tensor.
const Tensor< T > operator() (const Slice &s0, const Slice &s1, const Slice &s2, const Slice &s3, const Slice &s4) const
 Return a 1-5d constant Tensor that views the specified range of the 5d Tensor.
SliceTensor< T > operator() (const Slice &s0, const Slice &s1, const Slice &s2, const Slice &s3, const Slice &s4, const Slice &s5)
 Return a 1-6d SliceTensor that views the specified range of the 6d Tensor.
const Tensor< T > operator() (const Slice &s0, const Slice &s1, const Slice &s2, const Slice &s3, const Slice &s4, const Slice &s5) const
 Return a 1-6d constant Tensor that views the specified range of the 6d Tensor.
SliceTensor< T > operator() (const Slice &s0, const Slice &s1, long k)
 Return a 2d SliceTensor that views the specified range of the 3d Tensor.
const Tensor< T > operator() (const Slice &s0, const Slice &s1, long k) const
 Return a 2d constant Tensor that views the specified range of the 3d Tensor.
SliceTensor< T > operator() (const Slice &s0, long j)
 Return a 1d SliceTensor that views the specified range of the 2d Tensor.
const Tensor< T > operator() (const Slice &s0, long j) const
 Return a 1d constant Tensor that views the specified range of the 2d Tensor.
SliceTensor< T > operator() (const Slice &s0, long j, const Slice &s2)
 Return a 2d SliceTensor that views the specified range of the 3d Tensor.
const Tensor< T > operator() (const Slice &s0, long j, const Slice &s2) const
 Return a 2d constant Tensor that views the specified range of the 3d Tensor.
SliceTensor< T > operator() (const Slice &s0, long j, long k)
 Return a 1d SliceTensor that views the specified range of the 3d Tensor.
const Tensor< T > operator() (const Slice &s0, long j, long k) const
 Return a 1d constant Tensor that views the specified range of the 3d Tensor.
SliceTensor< T > operator() (const std::array< Slice, TENSOR_MAXDIM > &s)
 General slicing operation.
const Tensor< T > operator() (const std::array< Slice, TENSOR_MAXDIM > &s) const
 General slicing operation (const).
T & operator() (const std::vector< long > ind)
 General indexing operation with bounds checking.
const T & operator() (const std::vector< long > ind) const
 General indexing operation with bounds checking.
SliceTensor< T > operator() (const std::vector< Slice > &s)
 General slicing operation.
const Tensor< T > operator() (const std::vector< Slice > &s) const
 General slicing operation (const).
T & operator() (long i)
 1-d indexing operation without bounds checking.
const T & operator() (long i) const
 1-d indexing operation without bounds checking.
SliceTensor< T > operator() (long i, const Slice &s1)
 Return a 1d SliceTensor that views the specified range of the 2d Tensor.
const Tensor< T > operator() (long i, const Slice &s1) const
 Return a 1d SliceTensor that views the specified range of the 2d Tensor.
SliceTensor< T > operator() (long i, const Slice &s1, const Slice &s2)
 Return a 2d SliceTensor that views the specified range of the 3d Tensor.
const Tensor< T > operator() (long i, const Slice &s1, const Slice &s2) const
 Return a 2d constant Tensor that views the specified range of the 3d Tensor.
SliceTensor< T > operator() (long i, const Slice &s1, long k)
 Return a 1d SliceTensor that views the specified range of the 3d Tensor.
const Tensor< T > operator() (long i, const Slice &s1, long k) const
 Return a 1d constant Tensor that views the specified range of the 3d Tensor.
T & operator() (long i, long j)
 2-d indexing operation without bounds checking.
const T & operator() (long i, long j) const
 2-d indexing operation without bounds checking.
SliceTensor< T > operator() (long i, long j, const Slice &s2)
 Return a 1d SliceTensor that views the specified range of the 3d Tensor.
const Tensor< T > operator() (long i, long j, const Slice &s2) const
 Return a 1d constant Tensor that views the specified range of the 3d Tensor.
T & operator() (long i, long j, long k)
 3-d indexing operation without bounds checking.
const T & operator() (long i, long j, long k) const
 3-d indexing operation without bounds checking.
T & operator() (long i, long j, long k, long l)
 4-d indexing operation without bounds checking.
const T & operator() (long i, long j, long k, long l) const
 4-d indexing operation without bounds checking.
T & operator() (long i, long j, long k, long l, long m)
 5-d indexing operation without bounds checking.
const T & operator() (long i, long j, long k, long l, long m) const
 5-d indexing operation without bounds checking.
T & operator() (long i, long j, long k, long l, long m, long n)
 6-d indexing operation without bounds checking.
const T & operator() (long i, long j, long k, long l, long m, long n) const
 6-d indexing operation without bounds checking.
template<typename Q>
IsSupported< TensorTypeData< Q >, Tensor< TENSOR_RESULT_TYPE(T, Q)> >::type operator* (const Q &x) const
 Multiplication of tensor by a scalar of a supported type to produce a new tensor.
template<typename Q>
IsSupported< TensorTypeData< Q >, Tensor< T > & >::type operator*= (const Q &x)
 Inplace multiplication by scalar of supported type.
template<typename Q>
IsSupported< TensorTypeData< Q >, Tensor< TENSOR_RESULT_TYPE(T, Q)> >::type operator+ (const Q &x) const
 Add a scalar of the same type to all elements of a tensor producing a new tensor.
template<typename Q>
Tensor< TENSOR_RESULT_TYPE(T, Q) > operator+ (const Tensor< Q > &t) const
 Addition of two tensors to produce a new tensor.
template<typename Q>
IsSupported< TensorTypeData< Q >, Tensor< T > & >::type operator+= (const Q &x)
 Inplace increment by scalar of supported type.
template<typename Q>
Tensor< T > & operator+= (const Tensor< Q > &t)
 Inplace addition of two tensors.
Tensor< T > operator- () const
 Unary negation producing a new tensor.
template<typename Q>
IsSupported< TensorTypeData< Q >, Tensor< TENSOR_RESULT_TYPE(T, Q)> >::type operator- (const Q &x) const
 Subtract a scalar of the same type from all elements producing a new tensor.
template<typename Q>
Tensor< TENSOR_RESULT_TYPE(T, Q) > operator- (const Tensor< Q > &t) const
 Subtraction of two tensors to produce a new tensor.
template<typename Q>
IsSupported< TensorTypeData< Q >, Tensor< T > & >::type operator-= (const Q &x)
 Inplace decrement by scalar of supported type.
template<typename Q>
Tensor< T > & operator-= (const Tensor< Q > &t)
 Inplace subtraction of two tensors.
template<typename Q>
IsSupported< TensorTypeData< Q >, Tensor< TENSOR_RESULT_TYPE(T, Q)> >::type operator/ (const Q &x) const
 Divide tensor by a scalar of a supported type to produce a new tensor.
Tensor< T > & operator= (const Tensor< T > &t)
 Assignment is shallow (same as copy constructor).
Tensor< T > & operator= (T x)
 Inplace fill tensor with scalar.
T & operator[] (long i)
 1-d indexing operation using [] without bounds checking.
const T & operator[] (long i) const
 1-d indexing operation using [] without bounds checking.
T product () const
 Return the product of all elements of the tensor.
T * ptr ()
 Returns a pointer to the internal data.
const T * ptr () const
 Returns a pointer to the internal data.
Tensor< T > reshape (const std::vector< long > &d)
 Returns new view/tensor reshaping size/number of dimensions to conforming tensor.
const Tensor< T > reshape (const std::vector< long > &d) const
 Returns new view/tensor reshaping size/number of dimensions to conforming tensor.
Tensor< T > reshape (int ndimnew, const long *d)
 Returns new view/tensor reshaping size/number of dimensions to conforming tensor.
const Tensor< T > reshape (int ndimnew, const long *d) const
 Returns new view/tensor reshaping size/number of dimensions to conforming tensor.
Tensor< T > reshape (long dim0)
 Returns new view/tensor rehapings to conforming 1-d tensor with given dimension.
const Tensor< T > reshape (long dim0) const
 Returns new view/tensor rehapings to conforming 1-d tensor with given dimension.
Tensor< T > reshape (long dim0, long dim1)
 Returns new view/tensor rehaping to conforming 2-d tensor with given dimensions.
const Tensor< T > reshape (long dim0, long dim1) const
 Returns new view/tensor rehaping to conforming 2-d tensor with given dimensions.
Tensor< T > reshape (long dim0, long dim1, long dim2)
 Returns new view/tensor rehaping to conforming 3-d tensor with given dimensions.
const Tensor< T > reshape (long dim0, long dim1, long dim2) const
 Returns new view/tensor rehaping to conforming 3-d tensor with given dimensions.
Tensor< T > reshape (long dim0, long dim1, long dim2, long dim3)
 Returns new view/tensor rehaping to conforming 4-d tensor with given dimensions.
const Tensor< T > reshape (long dim0, long dim1, long dim2, long dim3) const
 Returns new view/tensor rehaping to conforming 4-d tensor with given dimensions.
Tensor< T > reshape (long dim0, long dim1, long dim2, long dim3, long dim4)
 Returns new view/tensor rehaping to conforming 5-d tensor with given dimensions.
const Tensor< T > reshape (long dim0, long dim1, long dim2, long dim3, long dim4) const
 Returns new view/tensor rehaping to conforming 5-d tensor with given dimensions.
Tensor< T > reshape (long dim0, long dim1, long dim2, long dim3, long dim4, long dim5)
 Returns new view/tensor rehaping to conforming 6-d tensor with given dimensions.
const Tensor< T > reshape (long dim0, long dim1, long dim2, long dim3, long dim4, long dim5) const
 Returns new view/tensor rehaping to conforming 6-d tensor with given dimensions.
template<typename Q>
IsSupported< TensorTypeData< Q >, Tensor< T > & >::type scale (Q x)
 Inplace multiplication by scalar of supported type (legacy name).
Tensor< T > & screen (double x)
 Inplace set elements of *this less than x in absolute magnitude to zero.
Tensor< T > splitdim (long i, long dimi0, long dimi1)
 Returns new view/tensor splitting dimension i as dimi0*dimi1 to produce conforming d+1 dimension tensor.
const Tensor< T > splitdim (long i, long dimi0, long dimi1) const
 Returns new view/tensor splitting dimension i as dimi0*dimi1 to produce conforming d+1 dimension tensor.
T sum () const
 Returns the sum of all elements of the tensor.
T sumsq () const
 Returns the sum of the squares of the elements.
Tensor< T > swapdim (long idim, long jdim)
 Returns new view/tensor swaping dimensions i and j.
const Tensor< T > swapdim (long idim, long jdim) const
 Returns new view/tensor swaping dimensions i and j.
template<class Q>
 TENSOR_RESULT_TYPE (T, Q) trace(const Tensor< Q > &t) const
 Return the trace of two tensors (no complex conjugate invoked).
template<class Q>
 TENSOR_RESULT_TYPE (T, Q) trace_conj(const Tensor< Q > &t) const
 Return the trace of two tensors with complex conjugate of the leftmost (i.e., this).
template<class Q, class R>
TensorIterator< T, Q, R > ternary_iterator (const Tensor< Q > &q, const Tensor< R > &r, long iterlevel=0, bool optimize=true, bool fusedim=true, long jdim=default_jdim) const
 Return iterator over three tensors.
TensorIterator< T > unary_iterator (long iterlevel=0, bool optimize=true, bool fusedim=true, long jdim=default_jdim) const
 Return iterator over single tensor.
template<typename opT>
Tensor< T > & unaryop (opT &op)
 Inplace apply a unary function to each element of the tensor.
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 double fac_reduce ()
 return the additional safety for rank reduction
static double fac_reduce ()
static double facReduce ()
Static Public Member Functions inherited from madness::Tensor< T >
static bool bounds_checking ()
 Return true if bounds checking was enabled at compile time.
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.

Private Attributes

std::variant< std::shared_ptr< Tensor< T > >, std::shared_ptr< SVDTensor< T > >, std::shared_ptr< TensorTrain< T > > > tensor
 holding the implementation of the low rank tensor representations

Friends

GenTensor copy (const GenTensor &other)
 deep copy
template<typename R, typename Q>
GenTensor< TENSOR_RESULT_TYPE(R, Q)> general_transform (const GenTensor< R > &t, const Tensor< Q > c[])
 Transform all dimensions of the tensor t by distinct matrices c.
template<typename Q, typename R>
bool is_same_tensor_type (const GenTensor< R > &rhs, const GenTensor< Q > &lhs)
class SliceLowRankTensor< T >
template<typename R, typename Q>
GenTensor< TENSOR_RESULT_TYPE(R, Q)> transform (const GenTensor< R > &t, const Tensor< Q > &c)
 Transform all dimensions of the tensor t by the matrix c.
template<typename R, typename Q>
GenTensor< TENSOR_RESULT_TYPE(R, Q)> transform_dir (const GenTensor< R > &t, const Tensor< Q > &c, const int axis)
 Transforms one dimension of the tensor t by the matrix c, returns new contiguous tensor.

Additional Inherited Members

Protected Member Functions inherited from madness::Tensor< T >
void allocate (long nd, const long d[], bool dozero)
void deallocate ()
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::Tensor< T >
T *MADNESS_RESTRICT _p
TENSOR_SHARED_PTR< T > _shptr
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.

Member Typedef Documentation

◆ float_scalar_type

template<typename T>
typedef TensorTypeData<T>::float_scalar_type madness::GenTensor< T >::float_scalar_type

C++ typename of the floating point type associated with scalar real type.

◆ scalar_type

template<typename T>
typedef TensorTypeData<T>::scalar_type madness::GenTensor< T >::scalar_type

C++ typename of the real type associated with a complex type.

Constructor & Destructor Documentation

◆ GenTensor() [1/21]

◆ GenTensor() [2/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const Tensor< T > & t1)
inline

◆ GenTensor() [3/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const Tensor< T > & t1,
const TensorArgs &  )
inline

◆ GenTensor() [4/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const Tensor< T > & t1,
double ,
const TensorType  )
inline

◆ GenTensor() [5/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const TensorType )
inline

◆ GenTensor() [6/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( std::vector< long > v,
const TensorType &  )
inline

◆ GenTensor() [7/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( std::vector< long > v,
const TensorArgs &  )
inline

◆ GenTensor() [8/21]

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

◆ GenTensor() [9/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( long nd,
const long d[],
const TensorType &  )
inline

◆ GenTensor() [10/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( )
default

empty ctor

◆ GenTensor() [11/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const GenTensor< T > & other)
default

copy ctor, shallow

References GenTensor().

◆ GenTensor() [12/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const long ndim,
const long * dims,
const TensorType & tt )
inline

◆ GenTensor() [13/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const std::vector< long > & dim,
const TensorType & tt )
inline

ctor with dimensions; constructs tensor filled with zeros

References GenTensor(), dim(), madness::FunctionDefaults< NDIM >::tt, and size().

◆ GenTensor() [14/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const std::vector< long > & dim,
const TensorArgs & targs )
inline

ctor with dimensions; constructs tensor filled with zeros

References GenTensor(), dim(), and madness::FunctionDefaults< NDIM >::tt.

◆ GenTensor() [15/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const TensorType & tt,
const long k,
const long ndim )
inline

ctor with dimensions; all dims have the same value k

References GenTensor(), madness::FunctionDefaults< NDIM >::k, madness::FunctionDefaults< NDIM >::tt, and ndim().

◆ GenTensor() [16/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const Tensor< T > & rhs,
const double & thresh,
const TensorType & tt )
inline

◆ GenTensor() [17/21]

◆ GenTensor() [18/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const Tensor< T > & other)
inline

ctor with a regular Tensor, deep

References madness::Tensor< T >::Tensor(), and tensor.

◆ GenTensor() [19/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const TensorTrain< T > & other)
inline

ctor with a TensorTrain as argument, shallow

References tensor.

◆ GenTensor() [20/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const SVDTensor< T > & other)
inline

ctor with a SVDTensor as argument, shallow

References tensor.

◆ GenTensor() [21/21]

template<typename T>
madness::GenTensor< T >::GenTensor ( const SliceLowRankTensor< T > & other)
inline

ctor with a SliceLowRankTensor as argument, deep

Member Function Documentation

◆ add_SVD() [1/2]

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

◆ add_SVD() [2/2]

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

◆ config()

template<typename T>
SRConf< T > madness::GenTensor< T >::config ( ) const
inline

◆ convert() [1/2]

◆ convert() [2/2]

template<typename T>
GenTensor madness::GenTensor< T >::convert ( const TensorArgs & targs) const
inline

convert this to a new LowRankTensor of given tensor type

References GenTensor(), convert_inplace(), copy, get_tensor(), is_full_tensor(), is_of_tensortype(), and madness::TensorArgs::tt.

◆ convert_inplace()

◆ dim()

◆ dims()

template<typename T>
const long * madness::GenTensor< T >::dims ( ) const
inline

◆ emul()

◆ fac_reduce() [1/2]

template<typename T>
double madness::GenTensor< T >::fac_reduce ( )
inlinestatic

◆ fac_reduce() [2/2]

template<typename T>
double madness::GenTensor< T >::fac_reduce ( )
inlinestatic

◆ facReduce()

template<typename T>
double madness::GenTensor< T >::facReduce ( )
inlinestatic

Referenced by GenTensor(), add_SVD(), and reduce_rank().

◆ full_tensor() [1/4]

template<typename T>
Tensor< T > & madness::GenTensor< T >::full_tensor ( )
inline

◆ full_tensor() [2/4]

template<typename T>
Tensor< T > & madness::GenTensor< T >::full_tensor ( )
inline

return a reference of the full tensor, presumably for in-place modification WARNING: works only if this is indeed a full tensor

References madness::Tensor< T >::Tensor(), get_tensor(), is_full_tensor(), and MADNESS_ASSERT.

◆ full_tensor() [3/4]

◆ full_tensor() [4/4]

template<typename T>
Tensor< T > madness::GenTensor< T >::full_tensor ( ) const
inline

return a view (shallow copy) of the full tensor, if possible, otherwise reconstruct to full tensor and return a deep copy

References madness::Tensor< T >::Tensor(), full_tensor_copy(), get_tensor(), and is_full_tensor().

◆ full_tensor_copy() [1/3]

template<typename T>
Tensor< T > madness::GenTensor< T >::full_tensor_copy ( )
inline

◆ full_tensor_copy() [2/3]

◆ full_tensor_copy() [3/3]

◆ gaxpy() [1/2]

◆ gaxpy() [2/2]

template<typename T>
GenTensor & madness::GenTensor< T >::gaxpy ( const T alpha,
std::array< Slice, TENSOR_MAXDIM > s0,
const GenTensor< T > & other,
const T beta,
std::array< Slice, TENSOR_MAXDIM > s1 )
inline

◆ get_configs()

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

References MADNESS_EXCEPTION.

◆ get_svdtensor() [1/4]

◆ get_svdtensor() [2/4]

template<typename T>
SVDTensor< T > & madness::GenTensor< T >::get_svdtensor ( )
inline

◆ get_svdtensor() [3/4]

template<typename T>
const SVDTensor< T > & madness::GenTensor< T >::get_svdtensor ( ) const
inline

References MADNESS_EXCEPTION.

◆ get_svdtensor() [4/4]

template<typename T>
const SVDTensor< T > & madness::GenTensor< T >::get_svdtensor ( ) const
inline

◆ get_tensor() [1/4]

template<typename T>
Tensor< T > & madness::GenTensor< T >::get_tensor ( )
inline

◆ get_tensor() [2/4]

template<typename T>
Tensor< T > & madness::GenTensor< T >::get_tensor ( )
inline

◆ get_tensor() [3/4]

◆ get_tensor() [4/4]

template<typename T>
const Tensor< T > & madness::GenTensor< T >::get_tensor ( ) const
inline

◆ get_tensortrain() [1/4]

◆ get_tensortrain() [2/4]

template<typename T>
TensorTrain< T > & madness::GenTensor< T >::get_tensortrain ( )
inline

◆ get_tensortrain() [3/4]

template<typename T>
const SVDTensor< T > & madness::GenTensor< T >::get_tensortrain ( ) const
inline

References MADNESS_EXCEPTION.

◆ get_tensortrain() [4/4]

template<typename T>
const TensorTrain< T > & madness::GenTensor< T >::get_tensortrain ( ) const
inline

◆ has_data() [1/2]

◆ has_data() [2/2]

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

References size().

◆ has_no_data() [1/2]

◆ has_no_data() [2/2]

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

References has_data().

◆ index()

◆ is_assigned() [1/2]

◆ is_assigned() [2/2]

template<typename T>
bool madness::GenTensor< T >::is_assigned ( ) const
inline

References ptr().

◆ is_full_tensor() [1/2]

◆ is_full_tensor() [2/2]

template<typename T>
bool madness::GenTensor< T >::is_full_tensor ( ) const
inlineconstexpr

References index().

◆ is_of_tensortype() [1/2]

◆ is_of_tensortype() [2/2]

template<typename T>
bool madness::GenTensor< T >::is_of_tensortype ( const TensorType & tt) const
inline

◆ is_svd_tensor() [1/2]

◆ is_svd_tensor() [2/2]

template<typename T>
bool madness::GenTensor< T >::is_svd_tensor ( ) const
inlineconstexpr

References index().

◆ is_tensortrain() [1/2]

◆ is_tensortrain() [2/2]

template<typename T>
bool madness::GenTensor< T >::is_tensortrain ( ) const
inlineconstexpr

References index().

◆ nCoeff() [1/2]

template<typename T>
size_t madness::GenTensor< T >::nCoeff ( ) const
inline

◆ nCoeff() [2/2]

template<typename T>
long madness::GenTensor< T >::nCoeff ( ) const
inline

◆ ndim()

◆ normalize() [1/2]

template<typename T>
void madness::GenTensor< T >::normalize ( )
inline

◆ normalize() [2/2]

template<typename T>
void madness::GenTensor< T >::normalize ( )
inline

References get_svdtensor(), and is_svd_tensor().

◆ normf()

◆ operator GenTensor< Q >() [1/2]

template<typename T>
template<class Q>
madness::GenTensor< T >::operator GenTensor< Q > ( ) const
inline

◆ operator GenTensor< Q >() [2/2]

template<typename T>
template<class Q>
madness::GenTensor< T >::operator GenTensor< Q > ( ) const
inline

◆ operator()() [1/2]

template<typename T>
SliceLowRankTensor< T > madness::GenTensor< T >::operator() ( const std::vector< Slice > & s)
inline

general slicing, shallow; for temporary use only!

References SliceLowRankTensor< T >.

◆ operator()() [2/2]

template<typename T>
const SliceLowRankTensor< T > madness::GenTensor< T >::operator() ( const std::vector< Slice > & s) const
inline

general slicing, shallow; for temporary use only!

References SliceLowRankTensor< T >.

◆ operator*()

template<typename T>
template<typename Q>
GenTensor< TENSOR_RESULT_TYPE(T, Q)> madness::GenTensor< T >::operator* ( const Q & x) const
inline

multiply with a number

References GenTensor(), copy, Q(), scale(), and TENSOR_RESULT_TYPE.

◆ operator+() [1/2]

template<typename T>
GenTensor madness::GenTensor< T >::operator+ ( const GenTensor< T > & other)
inline

References GenTensor(), copy, and gaxpy().

◆ operator+() [2/2]

template<typename T>
GenTensor madness::GenTensor< T >::operator+ ( const SliceLowRankTensor< T > & other)
inline

◆ operator+=() [1/2]

template<typename T>
GenTensor & madness::GenTensor< T >::operator+= ( const GenTensor< T > & other)
inline

References GenTensor(), and gaxpy().

◆ operator+=() [2/2]

template<typename T>
GenTensor & madness::GenTensor< T >::operator+= ( const SliceLowRankTensor< T > & other)
inline

◆ operator-()

template<typename T>
GenTensor madness::GenTensor< T >::operator- ( const GenTensor< T > & other)
inline

References GenTensor(), copy, and gaxpy().

◆ operator-=() [1/2]

template<typename T>
GenTensor & madness::GenTensor< T >::operator-= ( const GenTensor< T > & other)
inline

References GenTensor(), and gaxpy().

◆ operator-=() [2/2]

template<typename T>
GenTensor & madness::GenTensor< T >::operator-= ( const SliceLowRankTensor< T > & other)
inline

◆ operator=() [1/6]

template<typename T>
GenTensor & madness::GenTensor< T >::operator= ( const GenTensor< T > & other)
inline

shallow assignment operator

References GenTensor(), and tensor.

◆ operator=() [2/6]

◆ operator=() [3/6]

template<typename T>
GenTensor & madness::GenTensor< T >::operator= ( const SVDTensor< T > & other)
inline

deep assignment operator

References GenTensor(), copy, and tensor.

◆ operator=() [4/6]

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

assign a number to this tensor

References GenTensor(), and tensor.

◆ operator=() [5/6]

template<typename T>
GenTensor & madness::GenTensor< T >::operator= ( const Tensor< T > & other)
inline

deep assignment operator

References GenTensor(), madness::Tensor< T >::Tensor(), copy, and tensor.

◆ operator=() [6/6]

template<typename T>
GenTensor & madness::GenTensor< T >::operator= ( const TensorTrain< T > & other)
inline

deep assignment operator

References GenTensor(), copy, and tensor.

◆ ptr()

template<typename T>
const BaseTensor * madness::GenTensor< T >::ptr ( ) const
inline

might return a NULL pointer!

References p(), and tensor.

Referenced by madness::SeparatedConvolution< double, 3 >::apply_transformation2(), dim(), dims(), is_assigned(), ndim(), and size().

◆ rank() [1/2]

◆ rank() [2/2]

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

◆ real_size() [1/2]

template<typename T>
size_t madness::GenTensor< T >::real_size ( ) const
inline

◆ real_size() [2/2]

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

◆ reconstruct_tensor() [1/2]

template<typename T>
Tensor< T > madness::GenTensor< T >::reconstruct_tensor ( ) const
inline

◆ reconstruct_tensor() [2/2]

template<typename T>
Tensor< T > madness::GenTensor< T >::reconstruct_tensor ( ) const
inline

◆ reduce_rank() [1/2]

◆ reduce_rank() [2/2]

template<typename T>
void madness::GenTensor< T >::reduce_rank ( const double & thresh)
inline

◆ scale()

template<typename T>
template<typename Q>
IsSupported< TensorTypeData< Q >, GenTensor< T > & >::type madness::GenTensor< T >::scale ( Q fac)
inline

◆ size()

◆ svd_normf() [1/2]

template<typename T>
double madness::GenTensor< T >::svd_normf ( ) const
inline

◆ svd_normf() [2/2]

template<typename T>
float_scalar_type madness::GenTensor< T >::svd_normf ( ) const
inline

◆ TENSOR_RESULT_TYPE()

template<typename T>
template<typename Q>
madness::GenTensor< T >::TENSOR_RESULT_TYPE ( T ,
Q  ) const &
inline

◆ tensor_type() [1/2]

◆ tensor_type() [2/2]

template<typename T>
TensorType madness::GenTensor< T >::tensor_type ( ) const
inline

◆ what_am_i() [1/2]

template<typename T>
std::string madness::GenTensor< T >::what_am_i ( ) const
inline

◆ what_am_i() [2/2]

◆ copy

◆ is_same_tensor_type

template<typename T>
template<typename Q, typename R>
bool is_same_tensor_type ( const GenTensor< R > & rhs,
const GenTensor< Q > & lhs )
friend

◆ SliceLowRankTensor< T >

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

Member Data Documentation

◆ tensor

template<typename T>
std::variant<std::shared_ptr<Tensor<T> >, std::shared_ptr<SVDTensor<T> >, std::shared_ptr<TensorTrain<T> > > madness::GenTensor< T >::tensor
private

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