Add support for custom strides on map

See merge request oss/rotgen!14
This commit is contained in:
Joel Falcou 2025-08-15 16:49:33 +02:00
parent 87d4bc0585
commit c8fb0f476c
6 changed files with 220 additions and 69 deletions

View file

@ -29,17 +29,9 @@ namespace rotgen
template<typename Ref, int Options, bool isConst>
using map_type = typename compute_map_type<Ref,Options,isConst>::type;
template<typename T> struct map_stride;
template<typename PlainObjectType, int MapOptions, typename Stride>
struct map_stride<Eigen::Map<PlainObjectType, MapOptions, Stride>>
{
using type = Stride;
};
}
template<typename Ref, int Options = ColMajor, typename = void>
template<typename Ref, int Options = ColMajor, typename Stride = stride>
class map : private detail::map_type<std::remove_const_t<Ref>, Options, std::is_const_v<Ref>>
{
public:
@ -60,18 +52,18 @@ namespace rotgen
using as_concrete_type = as_concrete_t<ET, matrix>;
using ptr_type = std::conditional_t<is_immutable, value_type const*, value_type*>;
using stride_type = typename detail::map_stride<parent>::type;
using stride_type = Stride;
map(const map&) = default;
map(map&&) = default;
map& operator=(const map&) = default;
map& operator=(map&&) = default;
map(ptr_type ptr, Index r, Index c, stride_type s) : parent(ptr, r, c, s) {}
map(ptr_type ptr, Index r, Index c) : map(ptr, r, c, strides<storage_order>(r,c)) {}
map(ptr_type ptr, Index r, Index c, stride_type s) : parent(ptr, r, c, strides<storage_order>(s)) {}
map(ptr_type ptr, Index r, Index c) : parent(ptr, r, c, strides<storage_order>(r,c)) {}
map(ptr_type ptr, stride_type s) requires(RowsAtCompileTime!=-1 && ColsAtCompileTime!=-1)
: parent(ptr, s)
: parent(ptr, strides<storage_order>(s))
{}
map(ptr_type ptr, Index sz) requires(RowsAtCompileTime==1 || ColsAtCompileTime==1)