commit 2816588db7ff2c82c7441f7485221ac22abcbbb1
parent 4e095d17d2a35a94b715cf17abe35528cfeb878b
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date: Thu, 21 Dec 2023 13:09:11 +0000
strides_for_shape fortran_order
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/kfr/base/shape.hpp b/include/kfr/base/shape.hpp
@@ -475,7 +475,7 @@ namespace internal_generic
constexpr inline index_t null_index = max_index_t;
-template <index_t dims>
+template <index_t dims, bool fortran_order = false>
constexpr KFR_INTRINSIC shape<dims> strides_for_shape(const shape<dims>& sh, index_t stride = 1)
{
shape<dims> strides;
@@ -484,8 +484,8 @@ constexpr KFR_INTRINSIC shape<dims> strides_for_shape(const shape<dims>& sh, ind
index_t n = stride;
for (index_t i = 0; i < dims; ++i)
{
- strides[dims - 1 - i] = n;
- n *= sh[dims - 1 - i];
+ strides[fortran_order ? i : dims - 1 - i] = n;
+ n *= sh[fortran_order ? i : dims - 1 - i];
}
}
return strides;