Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType > Class Template Reference

A class that represents a tetrahedral matrix or tensor, with optional support for higher-dimensional tensor-like data. More...

#include <tensor.hpp>

Public Member Functions

template<typename T = void, typename = std::enable_if_t< !Tensor && std::is_same_v<StorageType, std::vector<DataType>>, T>>
 TetraTensor (IndexType tri_dim)
 Constructor for a non-tensor tetrahedral or cubic matrix.
 TetraTensor (const StorageType &data, IndexType tri_dim)
 Copy-constructor (almost).
template<typename T = void, typename = std::enable_if_t< Tensor && std::is_same_v<StorageType, std::vector<DataType>>, T>>
 TetraTensor (IndexType tri_dim, IndexType tensor_size)
 Constructor for a tensor-like tetrahedral or cubic matrix.
template<typename T = void, typename = std::enable_if_t<!Tensor, T>>
const DataType & operator() (IndexType i, IndexType j, IndexType k) const
 Accessor for non-tensor tetrahedral or cubic matrix (const version).
template<typename T = void, typename = std::enable_if_t<Tensor, T>>
const DataType & operator() (IndexType i, IndexType j, IndexType k, IndexType l) const
 Accessor for tensor-like tetrahedral or cubic matrix (const version).
template<typename T = void, typename = std::enable_if_t< !Tensor && std::is_same_v<StorageType, std::vector<DataType>>, T>>
DataType & operator() (IndexType i, IndexType j, IndexType k)
 Mutator for non-tensor tetrahedral or cubic matrix.
template<typename T = void, typename = std::enable_if_t<Tensor, T>>
DataType & operator() (IndexType i, IndexType j, IndexType k, IndexType l)
 Mutator for tensor-like tetrahedral or cubic matrix.
IndexType dim () const
 Dimension n of the \(n \times n\) matrix (or one slice of the tensor).
IndexType tdim () const
 Dimension along the tensor dimension.
IndexType numel () const
 Total number of elements.
auto begin ()
 Begin iterator.
auto end ()
 End iterator.
auto begin () const
 Const begin iterator.
auto end () const
 Const end iterator.

Protected Member Functions

IndexType ijk (IndexType i, IndexType j, IndexType k) const
 Helper function to compute the flattened index for a 3D tetrahedral or cubic matrix.
IndexType ijkl (IndexType i, IndexType j, IndexType k, IndexType l) const
 Helper function to compute the flattened index for a 4D tensor matrix.

Protected Attributes

IndexType m_tri_dim
 Dimension of the matrix.
IndexType m_tensor_size
 Size of the tensor dimension.
IndexType m_tri_size
 Total number of elements in one slice.
IndexType m_numel
 Total number of elements stored.
StorageType m_data
 Data storage.

Detailed Description

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
class vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >

A class that represents a tetrahedral matrix or tensor, with optional support for higher-dimensional tensor-like data.

The TetraTensor class stores data in either a tetrahedral structure (if Triangular is true) or in a cubic structure (if Triangular is false). Namely it offers a coalescent representation for data when you know that the indexes of the tensor i, j, k satisfy i + j + k < tri_dim. It can also store fourth-order tensor data based on the template parameters.

Template Parameters
TriangularSpecifies whether the tensor is tetrahedral (if true).
TensorSpecifies whether the tensor includes additional dimensions.
DataTypeThe data type of elements stored in the tensor.
IndexTypeThe data type for indexing the tensor.
StorageTypeThe container where to save the data. By default an std::vector, other used options are a const pointer, indicating that this is an not-owning view of some data

Constructor & Destructor Documentation

◆ TetraTensor() [1/3]

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
template<typename T = void, typename = std::enable_if_t< !Tensor && std::is_same_v<StorageType, std::vector<DataType>>, T>>
vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::TetraTensor ( IndexType tri_dim)
inlineexplicit

Constructor for a non-tensor tetrahedral or cubic matrix.

Parameters
tri_dimThe dimension of the tetrahedral or cubic matrix.
Note
This constructor can only be used when Tensor is false.

◆ TetraTensor() [2/3]

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::TetraTensor ( const StorageType & data,
IndexType tri_dim )
inlineexplicit

Copy-constructor (almost).

This constructor initializes the tensor from the underlying data buffer. Especially useful for constructing data views (pass the pointer to the data)

◆ TetraTensor() [3/3]

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
template<typename T = void, typename = std::enable_if_t< Tensor && std::is_same_v<StorageType, std::vector<DataType>>, T>>
vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::TetraTensor ( IndexType tri_dim,
IndexType tensor_size )
inlineexplicit

Constructor for a tensor-like tetrahedral or cubic matrix.

Parameters
tri_dimThe dimension of the tetrahedral or cubic matrix.
tensor_sizeThe size of the extra tensor dimension.
Note
This constructor can only be used when Tensor is true.

Member Function Documentation

◆ begin() [1/2]

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
auto vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::begin ( )
inline

Begin iterator.

◆ begin() [2/2]

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
auto vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::begin ( ) const
inline

Const begin iterator.

◆ dim()

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
IndexType vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::dim ( ) const
inline

Dimension n of the \(n \times n\) matrix (or one slice of the tensor).

◆ end() [1/2]

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
auto vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::end ( )
inline

End iterator.

◆ end() [2/2]

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
auto vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::end ( ) const
inline

Const end iterator.

◆ ijk()

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
IndexType vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::ijk ( IndexType i,
IndexType j,
IndexType k ) const
inlineprotected

Helper function to compute the flattened index for a 3D tetrahedral or cubic matrix.

Parameters
iFirst index.
jSecond index.
kThird index.
Returns
The flattened 1D index.

◆ ijkl()

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
IndexType vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::ijkl ( IndexType i,
IndexType j,
IndexType k,
IndexType l ) const
inlineprotected

Helper function to compute the flattened index for a 4D tensor matrix.

Parameters
iFirst index.
jSecond index.
kThird index.
lTensor dimension index.
Returns
The flattened 1D index.

◆ numel()

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
IndexType vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::numel ( ) const
inline

Total number of elements.

◆ operator()() [1/4]

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
template<typename T = void, typename = std::enable_if_t< !Tensor && std::is_same_v<StorageType, std::vector<DataType>>, T>>
DataType & vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::operator() ( IndexType i,
IndexType j,
IndexType k )
inline

Mutator for non-tensor tetrahedral or cubic matrix.

Parameters
iFirst index.
jSecond index.
kThird index.
Returns
A reference to the element at position (i, j, k).

◆ operator()() [2/4]

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
template<typename T = void, typename = std::enable_if_t<!Tensor, T>>
const DataType & vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::operator() ( IndexType i,
IndexType j,
IndexType k ) const
inline

Accessor for non-tensor tetrahedral or cubic matrix (const version).

Parameters
iFirst index.
jSecond index.
kThird index.
Returns
The element at position (i, j, k).

◆ operator()() [3/4]

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
template<typename T = void, typename = std::enable_if_t<Tensor, T>>
DataType & vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::operator() ( IndexType i,
IndexType j,
IndexType k,
IndexType l )
inline

Mutator for tensor-like tetrahedral or cubic matrix.

Parameters
iFirst index.
jSecond index.
kThird index.
lTensor dimension index.
Returns
A reference to the element at position (i, j, k, l).

◆ operator()() [4/4]

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
template<typename T = void, typename = std::enable_if_t<Tensor, T>>
const DataType & vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::operator() ( IndexType i,
IndexType j,
IndexType k,
IndexType l ) const
inline

Accessor for tensor-like tetrahedral or cubic matrix (const version).

Parameters
iFirst index.
jSecond index.
kThird index.
lTensor dimension index.
Returns
The element at position (i, j, k, l).

◆ tdim()

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
IndexType vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::tdim ( ) const
inline

Dimension along the tensor dimension.

Member Data Documentation

◆ m_data

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
StorageType vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::m_data
protected

Data storage.

◆ m_numel

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
IndexType vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::m_numel
protected

Total number of elements stored.

◆ m_tensor_size

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
IndexType vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::m_tensor_size
protected

Size of the tensor dimension.

◆ m_tri_dim

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
IndexType vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::m_tri_dim
protected

Dimension of the matrix.

◆ m_tri_size

template<bool Triangular, bool Tensor, typename DataType, typename IndexType, typename StorageType = std::vector<DataType>>
IndexType vulpes::datastructure::TetraTensor< Triangular, Tensor, DataType, IndexType, StorageType >::m_tri_size
protected

Total number of elements in one slice.


The documentation for this class was generated from the following file:
  • /__w/vulpes/vulpes/vulpes/datastructure/tensor.hpp