|
MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
|
Mathematical tensor with compile-time rank and spatial dimension. More...
#include <tensor.hpp>
Public Types | |
| using | value_type = Value |
| using | reference = Value& |
| using | const_reference = const Value& |
| using | pointer = Value* |
| using | const_pointer = const Value* |
| using | size_type = std::size_t |
Public Member Functions | |
| tensor ()=default | |
| Default: zero-initialized. | |
| tensor (const Value &val) | |
| Fill all components with a value. | |
| tensor (std::initializer_list< Value > il) | |
| Construct from initializer list (row-major order for rank-2). | |
| template<typename... Indices> requires (sizeof...(Indices) == Rank) | |
| reference | operator() (Indices... indices) |
| Multi-index access: T(i, j), T(i, j, k, l), etc. | |
| template<typename... Indices> requires (sizeof...(Indices) == Rank) | |
| const_reference | operator() (Indices... indices) const |
| reference | operator[] (const std::array< size_type, Rank > &idx) |
| Array-index access. | |
| const_reference | operator[] (const std::array< size_type, Rank > &idx) const |
| pointer | data () |
| const_pointer | data () const |
| pointer | begin () |
| const_pointer | begin () const |
| pointer | end () |
| const_pointer | end () const |
| void | fill (const Value &val) |
| void | set_to_zero () |
| tensor & | operator+= (const tensor &other) |
| tensor & | operator-= (const tensor &other) |
| tensor & | operator*= (const Value &s) |
| tensor & | operator/= (const Value &s) |
| bool | operator== (const tensor &other) const |
| bool | operator!= (const tensor &other) const |
Static Public Member Functions | |
| static constexpr size_type | size () |
Static Public Attributes | |
| static constexpr size_type | rank = Rank |
| static constexpr size_type | dimension = Dim |
| static constexpr size_type | num_components = detail::ipow(Dim, Rank) |
Friends | |
| tensor | operator+ (tensor a, const tensor &b) |
| tensor | operator- (tensor a, const tensor &b) |
| tensor | operator* (tensor a, const Value &s) |
| tensor | operator* (const Value &s, tensor a) |
| tensor | operator/ (tensor a, const Value &s) |
| tensor | operator- (tensor a) |
Mathematical tensor with compile-time rank and spatial dimension.
| Value | scalar type (double, float, posit, etc.) |
| Rank | tensor rank (0=scalar, 1=vector, 2=matrix, 4=elasticity, ...) |
| Dim | spatial dimension (2D, 3D, 4D, ...) |
| using mtl::tensor::tensor< Value, Rank, Dim >::const_pointer = const Value* |
| using mtl::tensor::tensor< Value, Rank, Dim >::const_reference = const Value& |
| using mtl::tensor::tensor< Value, Rank, Dim >::pointer = Value* |
| using mtl::tensor::tensor< Value, Rank, Dim >::reference = Value& |
| using mtl::tensor::tensor< Value, Rank, Dim >::size_type = std::size_t |
| using mtl::tensor::tensor< Value, Rank, Dim >::value_type = Value |
|
default |
Default: zero-initialized.
|
inlineexplicit |
Fill all components with a value.
|
inline |
Construct from initializer list (row-major order for rank-2).
Fewer values than components leave the rest zero; more throw std::invalid_argument, in every build (#857: it was an assert, and under NDEBUG the copy ran past the storage).
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Multi-index access: T(i, j), T(i, j, k, l), etc.
Under bounds_checking every index is checked against Dim (#857: the check was on the flat offset, so t(0, 3) of a tensor<V, 2, 3> passed and aliased t(1, 0)).
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Array-index access.
|
inline |
|
inline |
|
inlinestaticconstexpr |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |