Dense tensor class. More...
#include <dense.h>
Public Types | |
using | Coord = DenseImpl::Coord< rank > |
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 | conjugate () |
Conjugates every element. More... | |
DenseTensor () | |
Creates a zero-dimensional tensor. More... | |
DenseTensor (Coord dims_, Init do_init) | |
Ctor with possibility to request calloc() -based memory allocation for the contained array. 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... | |
DenseTensor (std::initializer_list< Index > const dims_) | |
Overload for initializer lists, which could otherwise be confused with the scalar ctor below. 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. 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... | |
Static Public Attributes | |
static constexpr unsigned int | version = 3 |
Bump this if any of the above change. More... | |
Private Attributes | |
DynArray< Scalar > | data |
Data vector holding the entries. More... | |
Dense tensor class.
rank | rank of the tensor, i.e. number of dimensions |
Scalar | Scalar 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
.