SyTen
syten::DenseTensor< rank, Scalar > Struct Template Reference

Dense tensor class. More...

#include <dense.h>

+ Inheritance diagram for syten::DenseTensor< rank, Scalar >:
+ Collaboration diagram for syten::DenseTensor< rank, Scalar >:

Public Types

typedef std::array< Index, rankCoord
 A set of indices uniquely describing one element. More...
 

Public Member Functions

MemoryUsage::MemorySize allocSize () const
 allocSize()/memory_size.h support. More...
 
Scalar * begin ()
 Pointer to start of data array. More...
 
const Scalar * begin () const
 Pointer to start of const array. More...
 
const Scalar * cbegin () const
 Pointer to start of const array. More...
 
const Scalar * cend () const
 Pointer one past the end of const array. More...
 
void checkDimensions (Coord const &dims) const
 Checks the supplied dimensions for validity, in particular to make sure that they are not too large. More...
 
void conjugate ()
 Conjugates every element. More...
 
 DenseTensor (std::initializer_list< Index > const dims_)
 Overload for initializer lists, which could otherwise be confused with the scalar ctor below. More...
 
 DenseTensor (Coord dims_, DenseTensorType type, Index extra=0)
 Creates a tensor of the specified size with special type and data set as provided. More...
 
 DenseTensor (Coord dims_, Init do_init)
 Ctor with possibility to request calloc()-based memory allocation for the contained array. More...
 
 DenseTensor ()
 Creates a zero-dimensional tensor. More...
 
 DenseTensor (Coord dims_, Scalar initialValue_=Scalar(0.))
 Ctor creates a dense tensor of specified dimension and initial value. More...
 
 DenseTensor (Scalar value)
 Creates a scalar one-dimensional tensor. More...
 
Index dim (Index which) const
 Return the size of the which-th dimension, 1-indexed. More...
 
Scalar * end ()
 Pointer one past the end of array. More...
 
const Scalar * end () const
 Pointer one past the end of const array. More...
 
DenseTensor< rank, Scalar > eternalised () const
 Returns a copy of *this with data allocated on the eternal pool. More...
 
DynArray< Scalar > & get_data ()
 Returns a writeable reference to the private data member, invalidates special.type. More...
 
DynArray< Scalar > const & get_data () const
 Returns a const reference to the private data member. More...
 
Index getCoordinate (Coord coordinates) const
 Given a set of indices coordinates, return the offset into data corresponding to these indices. More...
 
Coord getDims () const
 Return an array of dimensions. More...
 
Size getNumEntries () const
 Return the number of entries in this tensor. More...
 
void normalise ()
 Normalise the tensor such that its norm() is 1. More...
 
 operator DenseTensor< rank, std::complex< Scalar > > () const
 Conversion operator complexifying a dense tensor. More...
 
Scalar & operator[] (Coord coordinates)
 Return the element at specified index position. More...
 
Scalar const & operator[] (Coord coordinates) const
 Return the element at specified index position. More...
 
Scalar & operator[] (Size const c)
 Return the element at specified offset position. More...
 
Scalar const & operator[] (Size const c) const
 Return the element at specified offset position. More...
 
template<class Archive >
void serialize (Archive &ar, const unsigned int in_version)
 Boost serialisation support. More...
 
Size size () const
 Return the number of entries in this tensor. More...
 

Public Attributes

Coord dims
 The dimensions of the tensor, i.e. More...
 
DenseTensorTypeData special {0, DenseTensorType::None}
 Stores the special dense tensor type. More...
 

Static Public Attributes

static constexpr unsigned int version = 2
 Bump this if any of the above change. More...
 

Private Attributes

DynArray< Scalar > data
 Data vector holding the entries. More...
 

Detailed Description

template<Rank rank, typename Scalar = SDef>
struct syten::DenseTensor< rank, Scalar >

Dense tensor class.

Template Parameters
rankrank of the tensor, i.e. number of dimensions
ScalarScalar type of the tensor, i.e. the type of individual entries

As a rule, legs are 1-indexed, i.e. if one wants the dimension of the first leg, one calls dim(1). Elements are 0-indexed, i.e. the first scalar in the top leftmost corner sits at coordinate [0, 0, …, 0] and offset 0.

Member Typedef Documentation

◆ Coord

template<Rank rank, typename Scalar = SDef>
typedef std::array<Index, rank> syten::DenseTensor< rank, Scalar >::Coord

A set of indices uniquely describing one element.

Constructor & Destructor Documentation

◆ DenseTensor() [1/6]

template<Rank rank, typename Scalar = SDef>
syten::DenseTensor< rank, Scalar >::DenseTensor ( Coord  dims_,
Scalar  initialValue_ = Scalar(0.) 
)
inline

Ctor creates a dense tensor of specified dimension and initial value.

Parameters
dims_dimensions of each index
initialValue_initial value of each entry

◆ DenseTensor() [2/6]

template<Rank rank, typename Scalar = SDef>
syten::DenseTensor< rank, Scalar >::DenseTensor ( std::initializer_list< Index > const  dims_)
inline

Overload for initializer lists, which could otherwise be confused with the scalar ctor below.

◆ DenseTensor() [3/6]

template<Rank rank, typename Scalar = SDef>
syten::DenseTensor< rank, Scalar >::DenseTensor ( Coord  dims_,
Init  do_init 
)
inline

Ctor with possibility to request calloc()-based memory allocation for the contained array.

Pass Init::No to do so, this will be disabled if Scalar is not trivial.

Parameters
dims_dimensions of each index
do_initinitialisation request: Init::Yes uses default ctors in new[], Init::No uses calloc() if Scalar or ScalarBase<Scalar> is trivial and otherwise also new[].

◆ DenseTensor() [4/6]

template<Rank rank, typename Scalar = SDef>
syten::DenseTensor< rank, Scalar >::DenseTensor ( )
inline

Creates a zero-dimensional tensor.

◆ DenseTensor() [5/6]

template<Rank rank, typename Scalar = SDef>
syten::DenseTensor< rank, Scalar >::DenseTensor ( Scalar  value)
inline

Creates a scalar one-dimensional tensor.

◆ DenseTensor() [6/6]

template<Rank rank, typename Scalar = SDef>
syten::DenseTensor< rank, Scalar >::DenseTensor ( Coord  dims_,
DenseTensorType  type,
Index  extra = 0 
)
inline

Creates a tensor of the specified size with special type and data set as provided.

If the type is DenseTensorType::EtherealIdentity, the actual tensor array will not be initialised. Otherwise, the array will be zero-initialised.

Member Function Documentation

◆ allocSize()

template<Rank rank, typename Scalar = SDef>
MemoryUsage::MemorySize syten::DenseTensor< rank, Scalar >::allocSize ( ) const
inline

allocSize()/memory_size.h support.

◆ begin() [1/2]

◆ begin() [2/2]

template<Rank rank, typename Scalar = SDef>
const Scalar* syten::DenseTensor< rank, Scalar >::begin ( ) const
inline

Pointer to start of const array.

◆ cbegin()

template<Rank rank, typename Scalar = SDef>
const Scalar* syten::DenseTensor< rank, Scalar >::cbegin ( ) const
inline

Pointer to start of const array.

◆ cend()

template<Rank rank, typename Scalar = SDef>
const Scalar* syten::DenseTensor< rank, Scalar >::cend ( ) const
inline

Pointer one past the end of const array.

◆ checkDimensions()

template<Rank rank, typename Scalar = SDef>
void syten::DenseTensor< rank, Scalar >::checkDimensions ( Coord const &  dims) const
inline

Checks the supplied dimensions for validity, in particular to make sure that they are not too large.

Throws an exception if this happens.

◆ conjugate()

template<Rank rank, typename Scalar = SDef>
void syten::DenseTensor< rank, Scalar >::conjugate ( )
inline

Conjugates every element.

Referenced by syten::DenseProduct::one_times_many().

+ Here is the caller graph for this function:

◆ dim()

template<Rank rank, typename Scalar = SDef>
Index syten::DenseTensor< rank, Scalar >::dim ( Index  which) const
inline

Return the size of the which-th dimension, 1-indexed.

Referenced by syten::absSqd(), syten::Deparallelise::cols(), syten::Delinearise::cols(), syten::Delinearise::cols_only(), syten::Delinearise::compare_residual(), syten::QR::DenseQR< double >::DenseQR(), syten::QR::DenseQR< std::complex< float > >::DenseQR(), syten::QR::DenseQR< float >::DenseQR(), syten::eigenDavidson(), syten::expansion(), syten::DenseProduct::gemm_transpose(), syten::Krylov::TensorNetworksImpl::HEffDenseExpectation::H_eff(), syten::hsplit(), syten::DenseProduct::impl(), syten::invertDiagonal(), syten::isParallel_highPrec(), syten::kronaa(), syten::kronbb(), syten::MPS::left_complement(), syten::makeDiagonal(), syten::makeIdentity(), syten::DenseProduct::merge(), syten::DenseProduct::mm(), syten::multi_transpose(), syten::DenseProduct::mv(), syten::DenseProduct::one_times_many(), syten::operator>>(), syten::prune_small_rows(), syten::QR::qr(), syten::MPS::right_complement(), syten::Deparallelise::rows(), syten::scale_columns_2norm(), syten::DenseSolve::solve_cm(), syten::sort_cols_sparsity(), syten::sort_rows_infnorm(), syten::Krylov::SolverPolicies::Exponential::sp_convergence(), syten::Krylov::SolverPolicies::Eigen::sp_convergence(), syten::DenseProduct::split(), syten::DenseProduct::tcl(), syten::DenseProduct::transpose_a(), syten::DenseProduct::transpose_b(), and syten::vsplit().

+ Here is the caller graph for this function:

◆ end() [1/2]

template<Rank rank, typename Scalar = SDef>
Scalar* syten::DenseTensor< rank, Scalar >::end ( )
inline

Pointer one past the end of array.

Referenced by syten::DenseTensor< 1, typename syten::ScalarBase< Scalar >::type >::DenseTensor(), and syten::DenseProduct::one_times_many().

+ Here is the caller graph for this function:

◆ end() [2/2]

template<Rank rank, typename Scalar = SDef>
const Scalar* syten::DenseTensor< rank, Scalar >::end ( ) const
inline

Pointer one past the end of const array.

◆ eternalised()

template<Rank rank, typename Scalar = SDef>
DenseTensor<rank, Scalar> syten::DenseTensor< rank, Scalar >::eternalised ( ) const
inline

Returns a copy of *this with data allocated on the eternal pool.

◆ get_data() [1/2]

template<Rank rank, typename Scalar = SDef>
DynArray<Scalar>& syten::DenseTensor< rank, Scalar >::get_data ( )
inline

Returns a writeable reference to the private data member, invalidates special.type.

Referenced by syten::addScaled(), syten::DenseProduct::gemm_transpose(), syten::insertDummy(), syten::DenseProduct::merge(), syten::DenseProduct::one_times_many(), syten::operator*=(), syten::prodD(), syten::DenseProduct::split(), syten::DenseProduct::tcl(), syten::DenseProduct::transpose_a(), and syten::DenseProduct::transpose_b().

+ Here is the caller graph for this function:

◆ get_data() [2/2]

template<Rank rank, typename Scalar = SDef>
DynArray<Scalar> const& syten::DenseTensor< rank, Scalar >::get_data ( ) const
inline

Returns a const reference to the private data member.

◆ getCoordinate()

template<Rank rank, typename Scalar = SDef>
Index syten::DenseTensor< rank, Scalar >::getCoordinate ( Coord  coordinates) const
inline

Given a set of indices coordinates, return the offset into data corresponding to these indices.

Referenced by syten::DenseProduct::mm().

+ Here is the caller graph for this function:

◆ getDims()

template<Rank rank, typename Scalar = SDef>
Coord syten::DenseTensor< rank, Scalar >::getDims ( ) const
inline

Return an array of dimensions.

Referenced by syten::change_type(), syten::Delinearise::cols(), syten::conj(), syten::elem_abs(), syten::expansion(), syten::DenseProduct::gemm_transpose(), syten::DenseProduct::impl(), syten::make_complex(), syten::DenseProduct::merge(), syten::partial_abs(), syten::prodD(), syten::DenseProduct::split(), syten::DenseProduct::tcl(), syten::transpose(), and syten::write().

+ Here is the caller graph for this function:

◆ getNumEntries()

template<Rank rank, typename Scalar = SDef>
Size syten::DenseTensor< rank, Scalar >::getNumEntries ( ) const
inline

Return the number of entries in this tensor.

◆ normalise()

template<Rank rank, typename Scalar = SDef>
void syten::DenseTensor< rank, Scalar >::normalise ( )
inline

Normalise the tensor such that its norm() is 1.

Depends on a defined norm() function

◆ operator DenseTensor< rank, std::complex< Scalar > >()

template<Rank rank, typename Scalar = SDef>
syten::DenseTensor< rank, Scalar >::operator DenseTensor< rank, std::complex< Scalar > > ( ) const
inline

Conversion operator complexifying a dense tensor.

◆ operator[]() [1/4]

template<Rank rank, typename Scalar = SDef>
Scalar& syten::DenseTensor< rank, Scalar >::operator[] ( Coord  coordinates)
inline

Return the element at specified index position.

◆ operator[]() [2/4]

template<Rank rank, typename Scalar = SDef>
Scalar const& syten::DenseTensor< rank, Scalar >::operator[] ( Coord  coordinates) const
inline

Return the element at specified index position.

◆ operator[]() [3/4]

template<Rank rank, typename Scalar = SDef>
Scalar& syten::DenseTensor< rank, Scalar >::operator[] ( Size const  c)
inline

Return the element at specified offset position.

◆ operator[]() [4/4]

template<Rank rank, typename Scalar = SDef>
Scalar const& syten::DenseTensor< rank, Scalar >::operator[] ( Size const  c) const
inline

Return the element at specified offset position.

◆ serialize()

template<Rank rank, typename Scalar = SDef>
template<class Archive >
void syten::DenseTensor< rank, Scalar >::serialize ( Archive &  ar,
const unsigned int  in_version 
)
inline

Boost serialisation support.

◆ size()

Member Data Documentation

◆ data

template<Rank rank, typename Scalar = SDef>
DynArray<Scalar> syten::DenseTensor< rank, Scalar >::data
private

◆ dims

◆ special

◆ version

template<Rank rank, typename Scalar = SDef>
constexpr unsigned int syten::DenseTensor< rank, Scalar >::version = 2
static

Bump this if any of the above change.


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