Clarify single index API for data access.
This commit is contained in:
parent
a50098f761
commit
d89da18709
13 changed files with 249 additions and 128 deletions
|
|
@ -39,13 +39,14 @@ namespace rotgen
|
|||
using value_type = typename std::remove_const_t<Ref>::value_type;
|
||||
using concrete_type = typename std::remove_const_t<Ref>::concrete_type;
|
||||
|
||||
static constexpr auto Flags = Ref::Flags;
|
||||
static constexpr Index RowsAtCompileTime = Ref::RowsAtCompileTime;
|
||||
static constexpr Index ColsAtCompileTime = Ref::ColsAtCompileTime;
|
||||
static constexpr bool has_static_storage = Ref::has_static_storage;
|
||||
static constexpr int storage_order = Ref::storage_order;
|
||||
static constexpr bool is_immutable = std::is_const_v<Ref>;
|
||||
static constexpr bool is_defined_static = Ref::is_defined_static;
|
||||
static constexpr auto Flags = Ref::Flags;
|
||||
static constexpr Index RowsAtCompileTime = Ref::RowsAtCompileTime;
|
||||
static constexpr Index ColsAtCompileTime = Ref::ColsAtCompileTime;
|
||||
static constexpr bool IsVectorAtCompileTime = Ref::IsVectorAtCompileTime;
|
||||
static constexpr bool has_static_storage = Ref::has_static_storage;
|
||||
static constexpr int storage_order = Ref::storage_order;
|
||||
static constexpr bool is_immutable = std::is_const_v<Ref>;
|
||||
static constexpr bool is_defined_static = Ref::is_defined_static;
|
||||
|
||||
template<typename ET>
|
||||
using as_concrete_type = as_concrete_t<ET, matrix>;
|
||||
|
|
@ -111,21 +112,25 @@ namespace rotgen
|
|||
else return *this;
|
||||
}
|
||||
|
||||
value_type& operator()(Index i, Index j) { return base()(i, j); }
|
||||
value_type operator()(Index i, Index j) const { return base()(i, j); }
|
||||
|
||||
value_type& operator()(Index i) requires(!is_immutable)
|
||||
value_type& operator()(Index i, Index j) requires(!is_immutable)
|
||||
{
|
||||
return base()(i,j);
|
||||
}
|
||||
|
||||
value_type& operator()(Index i) requires(!is_immutable && IsVectorAtCompileTime)
|
||||
{
|
||||
assert(is_contiguous_linear());
|
||||
return base().data()[i];
|
||||
}
|
||||
|
||||
value_type operator()(Index i) const
|
||||
value_type& operator[](Index i) requires(!is_immutable && IsVectorAtCompileTime)
|
||||
{
|
||||
assert(is_contiguous_linear());
|
||||
return base().data()[i];
|
||||
return (*this)(i);
|
||||
}
|
||||
|
||||
value_type operator()(Index i, Index j) const { return base()(i,j); }
|
||||
value_type operator()(Index i) const requires(IsVectorAtCompileTime) { return base().data()[i]; }
|
||||
value_type operator[](Index i) const requires(IsVectorAtCompileTime) { return (*this)(i); }
|
||||
|
||||
map& operator+=(map const& rhs)
|
||||
{
|
||||
base() += rhs.base();
|
||||
|
|
@ -253,13 +258,6 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool is_contiguous_linear() const
|
||||
{
|
||||
if(base().innerStride() != 1) return false;
|
||||
if constexpr(storage_order == rotgen::RowMajor) return base().outerStride() == base().cols();
|
||||
else return base().outerStride() == base().rows();
|
||||
}
|
||||
|
||||
using parent::innerStride;
|
||||
using parent::outerStride;
|
||||
using parent::rows;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue