Fix some ref/map/block non-trivial interactions.
This commit is contained in:
parent
f285251a52
commit
399f17af57
7 changed files with 127 additions and 22 deletions
|
|
@ -139,22 +139,21 @@ namespace rotgen
|
|||
|
||||
template<std::same_as<value_type> S, int R, int C, int O, int MR, int MC>
|
||||
ref(matrix<S, R, C, O, MR, MC> const& m)
|
||||
requires((O & 1) == storage_order)
|
||||
: parent(m.data(), m.rows(), m.cols(), strides(m))
|
||||
{
|
||||
static_assert((O & 1) == storage_order, "ref: Incompatible storage layout");
|
||||
}
|
||||
{}
|
||||
|
||||
template<typename Ref, int R, int C, bool I>
|
||||
ref(block<Ref,R,C,I> const& b) : parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
|
||||
{
|
||||
static_assert((Ref::storage_order & 1) == storage_order, "ref: Incompatible storage layout");
|
||||
}
|
||||
ref ( block<Ref,R,C,I> const& b )
|
||||
requires(std::same_as<value_type, typename Ref::value_type> && (Ref::storage_order & 1) == storage_order)
|
||||
: parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
|
||||
{}
|
||||
|
||||
template<typename Ref, int O, typename S>
|
||||
ref(map<Ref,O,S> const& b) : parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
|
||||
{
|
||||
static_assert((Ref::storage_order & 1) == storage_order, "ref: Incompatible storage layout");
|
||||
}
|
||||
ref ( map<Ref,O,S> const& b )
|
||||
requires(std::same_as<value_type, typename Ref::value_type> && (Ref::storage_order & 1) == storage_order)
|
||||
: parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
|
||||
{}
|
||||
|
||||
ref(parent const& m) : parent(m.data(), m.rows(), m.cols()) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ namespace rotgen
|
|||
#else
|
||||
struct stride
|
||||
{
|
||||
static constexpr bool is_dynamic = true;
|
||||
|
||||
stride() : outer_(-1), inner_(1) {}
|
||||
stride(Index s, Index i) : outer_(s), inner_(i) {}
|
||||
|
||||
|
|
@ -35,6 +37,7 @@ namespace rotgen
|
|||
template<Index Value= Dynamic>
|
||||
struct inner_stride : stride
|
||||
{
|
||||
static constexpr bool is_dynamic = Value == Dynamic;
|
||||
inner_stride() : stride(-1,Value) {}
|
||||
inner_stride(Index v) : stride(0, v) {}
|
||||
};
|
||||
|
|
@ -42,6 +45,7 @@ namespace rotgen
|
|||
template<Index Value = Dynamic>
|
||||
struct outer_stride : stride
|
||||
{
|
||||
static constexpr bool is_dynamic = Value == Dynamic;
|
||||
outer_stride() : stride(Value,0) {}
|
||||
outer_stride(Index v) : stride(v,0) {}
|
||||
};
|
||||
|
|
@ -57,15 +61,16 @@ namespace rotgen
|
|||
}
|
||||
|
||||
template<int Order>
|
||||
stride strides(stride original)
|
||||
stride strides(stride const& original,Index, Index)
|
||||
{
|
||||
return original;
|
||||
}
|
||||
|
||||
template<int, Index N>
|
||||
stride strides(outer_stride<N> const& original)
|
||||
template<int Order, Index N>
|
||||
stride strides(outer_stride<N> const& original,Index r, Index c)
|
||||
{
|
||||
return {original.outer(),1};
|
||||
if constexpr(N==0) return stride{ Order==ColMajor ? r : c, 1};
|
||||
else return {original.outer(),1};
|
||||
}
|
||||
|
||||
template<concepts::entity E>
|
||||
|
|
|
|||
|
|
@ -40,8 +40,16 @@ namespace rotgen
|
|||
static constexpr Index RowsAtCompileTime = Ref::RowsAtCompileTime;
|
||||
static constexpr Index ColsAtCompileTime = Ref::ColsAtCompileTime;
|
||||
|
||||
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, Index r, Index c, stride_type s) : parent(ptr, r, c, strides<storage_order>(s,r,c)) {}
|
||||
map(ptr_type ptr, Index r, Index c)
|
||||
: parent( ptr, r, c
|
||||
, [&]()
|
||||
{
|
||||
if constexpr(!std::same_as<Stride,stride>) return strides<storage_order>(Stride{},r,c);
|
||||
else return strides<storage_order>(r,c);
|
||||
}()
|
||||
)
|
||||
{}
|
||||
|
||||
map(ptr_type ptr, stride_type s) requires(RowsAtCompileTime!=-1 && ColsAtCompileTime!=-1)
|
||||
: parent(ptr,RowsAtCompileTime,ColsAtCompileTime, strides<storage_order>(s))
|
||||
|
|
|
|||
|
|
@ -58,11 +58,19 @@ namespace rotgen
|
|||
map& operator=(const map&) = default;
|
||||
map& operator=(map&&) = default;
|
||||
|
||||
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, Index r, Index c, stride_type s) : parent(ptr, r, c, strides<storage_order>(s,r,c)) {}
|
||||
map(ptr_type ptr, Index r, Index c)
|
||||
: parent( ptr, r, c
|
||||
, [&]()
|
||||
{
|
||||
if constexpr(!std::same_as<Stride,stride>) return strides<storage_order>(Stride{},r,c);
|
||||
else return strides<storage_order>(r,c);
|
||||
}()
|
||||
)
|
||||
{}
|
||||
|
||||
map(ptr_type ptr, stride_type s) requires(RowsAtCompileTime!=-1 && ColsAtCompileTime!=-1)
|
||||
: parent(ptr, strides<storage_order>(s))
|
||||
: parent(ptr, strides<storage_order>(s,RowsAtCompileTime,ColsAtCompileTime))
|
||||
{}
|
||||
|
||||
map(ptr_type ptr, Index sz) requires(RowsAtCompileTime==1 || ColsAtCompileTime==1)
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
const TYPE* data() const;
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
TYPE* data();
|
||||
void setZero();
|
||||
void setOnes();
|
||||
void setRandom();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue