Tannic
A C++ Tensor Library
|
Represents the shape (dimensions) of an tensor-like expression. More...
#include <shape.hpp>
Public Types | |
using | rank_type = uint8_t |
Type used for rank (number of dimensions). | |
using | size_type = size_t |
Type used for size and shape dimensions. | |
Public Member Functions | |
constexpr | Shape () noexcept=default |
Default constructor. | |
constexpr | Shape (std::initializer_list< size_type > shape) |
Constructs a shape from an initializer list of dimension sizes. | |
template<Integral... Sizes> | |
constexpr | Shape (Sizes... sizes) |
Constructs a shape from a list of size arguments. | |
template<Iterable Sizes> | |
constexpr | Shape (Sizes &&sizes) |
Constructs a shape from any iterable container of sizes. | |
template<Iterator Iterator> | |
constexpr | Shape (Iterator begin, Iterator end) |
Constructs a shape from a pair of iterators. | |
constexpr size_type * | address () noexcept |
Returns a pointer to the internal size data (non-const). | |
constexpr size_type const * | address () const noexcept |
Returns a pointer to the internal size data (const). | |
constexpr rank_type | rank () const noexcept |
Returns the number of dimensions (rank). | |
constexpr auto | front () const noexcept |
Returns the first dimension size. | |
constexpr auto | back () const |
Returns the last dimension size. | |
template<Integral Index> | |
constexpr auto const & | operator[] (Index index) const |
Accesses a dimension by index (const). | |
template<Integral Index> | |
constexpr auto & | operator[] (Index index) |
Accesses a dimension by index (non-const). | |
constexpr void | expand (size_type size) |
Expands the shape's last dimension with a given size. | |
Iterators | |
constexpr auto | begin () |
constexpr auto | end () |
constexpr auto | begin () const |
constexpr auto | end () const |
constexpr auto | cbegin () const |
constexpr auto | cend () const |
Static Public Attributes | |
static constexpr uint8_t | limit = 8 |
Represents the shape (dimensions) of an tensor-like expression.
The Shape
class provides a constexpr-friendly abstraction over an expression shape and provides constructors and accessors for tensor shapes, including support for initializer lists, iterators, and iterable containers.
Shapes are limited to a maximum rank of 8 dimensions.
using tannic::Shape::rank_type = uint8_t |
Type used for rank (number of dimensions).
using tannic::Shape::size_type = size_t |
Type used for size and shape dimensions.
|
constexprdefaultnoexcept |
Default constructor.
Initializes a shape of rank 0 and size 1 (shape of scalars).
|
inlineconstexpr |
Constructs a shape from an initializer list of dimension sizes.
shape | An initializer list of dimension sizes. |
limit
.
|
inlineconstexpr |
Constructs a shape from a list of size arguments.
Sizes | Variadic list of integral size arguments. |
sizes | Sizes of each dimension. |
limit
.
|
inlineconstexpr |
|
inlineconstexpr |
Constructs a shape from a pair of iterators.
Iterator | Type of the iterator (must satisfy the Iterator concept). |
begin | Iterator to the beginning of dimension sizes. |
end | Iterator to the end of dimension sizes. |
limit
.
|
inlineconstexprnoexcept |
Returns a pointer to the internal size data (const).
|
inlineconstexprnoexcept |
Returns a pointer to the internal size data (non-const).
|
inlineconstexpr |
Returns the last dimension size.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Expands the shape's last dimension with a given size.
Increments the rank by one.
size | The size of the dimension that will be added to the back of the shape. |
|
inlineconstexprnoexcept |
Returns the first dimension size.
|
inlineconstexpr |
Accesses a dimension by index (non-const).
Index | Integral index type. |
index | Index of the dimension to access (supports negative indexing). |
|
inlineconstexpr |
Accesses a dimension by index (const).
Index | Integral index type. |
index | Index of the dimension to access (supports negative indexing). |
|
inlineconstexprnoexcept |
Returns the number of dimensions (rank).
|
staticconstexpr |