19 template <
typename M,
size_t I>
20 inline constexpr
size_t matrix_subsize() {
22 return decay_traits<M>::template dim<I + 1>() * matrix_subsize<M, I + 1>();
28 template <
typename M,
size_t I>
29 inline constexpr
size_t matrix_leadingsize() {
30 if constexpr (I > 0) {
31 return decay_traits<M>::template
dim<I - 1>() * matrix_leadingsize<M, I - 1>();
40 template <
typename M,
size_t I>
49 template <
typename M,
size_t I,
typename... S>
50 constexpr
size_t rm_compute_index(
size_t first,
size_t second, S... args) noexcept(assert_nothrow) {
52 return matrix_subsize<M, I>() * first + rm_compute_index<M, I + 1>(second, args...);
58 template <
typename M,
size_t I>
60 cpp_assert(first < M::template dim<I>(),
"Out of bounds");
61 return matrix_leadingsize<M, I>() * first;
67 template <
typename M,
size_t I,
typename... S>
68 constexpr
size_t cm_compute_index(
size_t first,
size_t second, S... args) noexcept(assert_nothrow) {
69 cpp_assert(first < M::template dim<I>(),
"Out of bounds");
70 return matrix_leadingsize<M, I>() * first + cm_compute_index<M, I + 1>(second, args...);
84 constexpr
size_t fast_index(
size_t i) noexcept(assert_nothrow) {
97 constexpr
size_t fast_index(
size_t i,
size_t j) noexcept(assert_nothrow) {
119 constexpr
size_t fast_index(
size_t i,
size_t j,
size_t k) noexcept(assert_nothrow) {
144 constexpr
size_t fast_index(
size_t i,
size_t j,
size_t k,
size_t l) noexcept(assert_nothrow) {
169 template <
typename T,
typename... S>
172 return detail::rm_compute_index<T, 0>(sizes...);
174 return detail::cm_compute_index<T, 0>(sizes...);
187 size_t dyn_index([[maybe_unused]]
const T& expression,
size_t i) noexcept(assert_nothrow) {
201 size_t dyn_index(
const T& expression,
size_t i,
size_t j) noexcept(assert_nothrow) {
224 size_t dyn_index(
const T& expression,
size_t i,
size_t j,
size_t k) noexcept(assert_nothrow) {
250 size_t dyn_index(
const T& expression,
size_t i,
size_t j,
size_t k,
size_t l) noexcept(assert_nothrow) {
276 template <
typename T,
typename... S>
284 [&subsize, &index, &i, &expression](
size_t s) {
287 index += subsize *
s;
298 [&subsize, &index, &i, &expression](
size_t s) {
300 index += subsize *
s;
auto s(T &&value)
Force the evaluation of the given expression.
Definition: stop.hpp:18
constexpr size_t fast_index(size_t i) noexcept(assert_nothrow)
Compute the index for a 1D fast matrix.
Definition: index.hpp:84
Traits to get information about ETL types.
Definition: tmp.hpp:68
Root namespace for the ETL library.
Definition: adapter.hpp:15
static constexpr size_t dimensions()
Return the number of dimensions of the expression.
Definition: traits_base.hpp:31
auto dim(E &&value, size_t i) -> detail::identity_helper< E, dim_view< detail::build_identity_type< E >, D >>
Return a view representing the ith Dth dimension.
Definition: view_expression_builder.hpp:25
requires(D > 0) struct dyn_base
Matrix with run-time fixed dimensions.
Definition: dyn_base.hpp:113
constexpr size_t rm_compute_index(size_t first) noexcept(assert_nothrow)
Compute the index inside the row major matrix.
Definition: index.hpp:41
constexpr size_t cm_compute_index(size_t first) noexcept(assert_nothrow)
Compute the index inside the column major matrix.
Definition: index.hpp:59
size_t subsize(const E &expr)
Returns the sub-size of the given ETL expression, i.e. the size not considering the first dimension...
Definition: helpers.hpp:118
size_t dyn_index([[maybe_unused]] const T &expression, size_t i) noexcept(assert_nothrow)
Compute the index for a 1D dynamic matrix.
Definition: index.hpp:187