parent
9901765ef9
commit
4ba8b3c6a9
13 changed files with 70 additions and 54 deletions
|
|
@ -30,6 +30,7 @@ namespace rotgen
|
|||
static constexpr int RowsAtCompileTime = T::RowsAtCompileTime;
|
||||
static constexpr int ColsAtCompileTime = T::ColsAtCompileTime;
|
||||
static constexpr bool IsVectorAtCompileTime = T::IsVectorAtCompileTime;
|
||||
static constexpr bool is_immutable = T::is_immutable;
|
||||
|
||||
using parent::evaluate;
|
||||
using parent::noalias;
|
||||
|
|
@ -120,14 +121,16 @@ namespace rotgen
|
|||
class ref<const T, Options,Stride> : private map<const T, Options,Stride>
|
||||
{
|
||||
public:
|
||||
using parent = map<const T, Options,Stride>;
|
||||
using value_type = typename T::value_type;
|
||||
using rotgen_tag = void;
|
||||
using parent = map<const T, Options,Stride>;
|
||||
using value_type = typename T::value_type;
|
||||
using rotgen_tag = void;
|
||||
using rotgen_ref_tag = void;
|
||||
|
||||
static constexpr int storage_order = T::storage_order;
|
||||
static constexpr int RowsAtCompileTime = T::RowsAtCompileTime;
|
||||
static constexpr int ColsAtCompileTime = T::ColsAtCompileTime;
|
||||
static constexpr bool IsVectorAtCompileTime = T::IsVectorAtCompileTime;
|
||||
static constexpr bool is_immutable = T::is_immutable;
|
||||
|
||||
using parent::evaluate;
|
||||
using parent::noalias;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ namespace rotgen::detail
|
|||
return false;
|
||||
}();
|
||||
|
||||
template<typename T>
|
||||
using propagate_const = std::conditional_t<T::is_immutable || std::is_const_v<T>, std::add_const_t<T>, T>;
|
||||
|
||||
template<auto M, auto N>
|
||||
inline constexpr auto select_static = (M==rotgen::Dynamic || N==rotgen::Dynamic) ? rotgen::Dynamic : M;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ namespace rotgen
|
|||
static constexpr bool IsRowMajor = (Opts & RowMajor) == RowMajor;
|
||||
static constexpr bool is_defined_static = false;
|
||||
static constexpr bool has_static_storage = false;
|
||||
static constexpr bool is_immutable = false;
|
||||
|
||||
using transposed_type = matrix<value_type,Cols,Rows, storage_order ^ RowMajor>;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
//==================================================================================================
|
||||
#pragma once
|
||||
#include <rotgen/detail/helpers.hpp>
|
||||
|
||||
namespace rotgen
|
||||
{
|
||||
|
|
@ -28,13 +29,10 @@ namespace rotgen
|
|||
auto extract(Entity& e, Index i0, Index j0, Index ni, Index nj)
|
||||
{
|
||||
detail::validate_extract(e,i0,j0,ni,nj);
|
||||
return block<Entity>(e, i0, j0, ni, nj);
|
||||
}
|
||||
template<concepts::entity Entity>
|
||||
auto extract(Entity const& e, Index i0, Index j0, Index ni, Index nj)
|
||||
{
|
||||
detail::validate_extract(e,i0,j0,ni,nj);
|
||||
return block<Entity const>(e, i0, j0, ni, nj);
|
||||
if constexpr(concepts::reference<Entity>)
|
||||
return extract(e.base(), i0, j0, ni, nj);
|
||||
else
|
||||
return block<detail::propagate_const<Entity>>(e, i0, j0, ni, nj);
|
||||
}
|
||||
|
||||
template<Index NI, Index NJ, concepts::entity Entity>
|
||||
|
|
@ -42,7 +40,10 @@ namespace rotgen
|
|||
auto extract(Entity& e, Index i0, Index j0)
|
||||
{
|
||||
detail::validate_extract(e,i0,j0,NI,NJ);
|
||||
return block<Entity,NI,NJ>(e, i0, j0);
|
||||
if constexpr(concepts::reference<Entity>)
|
||||
return extract<NI,NJ>(e.base(), i0, j0);
|
||||
else
|
||||
return block<detail::propagate_const<Entity> ,NI,NJ>(e, i0, j0);
|
||||
}
|
||||
|
||||
template<Index NI, Index NJ, concepts::entity Entity>
|
||||
|
|
@ -50,7 +51,10 @@ namespace rotgen
|
|||
auto extract(Entity& e, Index i0, Index j0, Index ni, Index nj)
|
||||
{
|
||||
detail::validate_extract(e,i0,j0,ni,nj);
|
||||
return block<Entity,NI,NJ>(e, i0, j0, ni, nj);
|
||||
if constexpr(concepts::reference<Entity>)
|
||||
return extract<NI,NJ>(e.base(), i0, j0, ni, nj);
|
||||
else
|
||||
return block<detail::propagate_const<Entity>,NI,NJ>(e, i0, j0, ni, nj);
|
||||
}
|
||||
|
||||
//======================== TOP LEFT CORNER ========================
|
||||
|
|
|
|||
|
|
@ -74,54 +74,31 @@ namespace rotgen
|
|||
static constexpr bool has_static_storage = storage_status<Rows,Cols,Rows,Cols>;
|
||||
|
||||
public:
|
||||
|
||||
block(const block& other) = default;
|
||||
block(block&& other) = default;
|
||||
block& operator=(const block&) = default;
|
||||
block& operator=(block&&) = default;
|
||||
|
||||
// Constructs from regular Ref
|
||||
block(Ref const& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
|
||||
requires(is_immutable && !concepts::reference<Ref>)
|
||||
requires(is_immutable)
|
||||
: parent(r.base(),i0,j0,ni,nj)
|
||||
{}
|
||||
|
||||
block(Ref const& r, std::size_t i0, std::size_t j0)
|
||||
requires(Rows != -1 && Cols != -1 && is_immutable && !concepts::reference<Ref>)
|
||||
requires(Rows != -1 && Cols != -1 && is_immutable)
|
||||
: parent(r.base(),i0,j0,Rows,Cols)
|
||||
{}
|
||||
|
||||
block(Ref& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
|
||||
requires(!is_immutable && !concepts::reference<Ref>)
|
||||
requires(!is_immutable)
|
||||
: parent(r.base(),i0,j0,ni,nj)
|
||||
{}
|
||||
|
||||
block(Ref& r, std::size_t i0, std::size_t j0)
|
||||
requires(Rows != -1 && Cols != -1 && !is_immutable && !concepts::reference<Ref>)
|
||||
requires(Rows != -1 && Cols != -1 && !is_immutable)
|
||||
: parent(r.base(),i0,j0,Rows,Cols)
|
||||
{}
|
||||
|
||||
// Constructs from rotgen::ref<T>
|
||||
block(Ref const& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
|
||||
requires(is_immutable && concepts::reference<Ref>)
|
||||
: parent(r.base().base(),i0,j0,ni,nj)
|
||||
{}
|
||||
|
||||
block(Ref const& r, std::size_t i0, std::size_t j0)
|
||||
requires(Rows != -1 && Cols != -1 && is_immutable && concepts::reference<Ref>)
|
||||
: parent(r.base().base(),i0,j0,Rows,Cols)
|
||||
{}
|
||||
|
||||
block(Ref& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
|
||||
requires(!is_immutable && concepts::reference<Ref>)
|
||||
: parent(r.base().base(),i0,j0,ni,nj)
|
||||
{}
|
||||
|
||||
block(Ref& r, std::size_t i0, std::size_t j0)
|
||||
requires(Rows != -1 && Cols != -1 && !is_immutable && concepts::reference<Ref>)
|
||||
: parent(r.base().base(),i0,j0,Rows,Cols)
|
||||
{}
|
||||
|
||||
template<typename B, Index R, Index C, bool I, int FS>
|
||||
block(block<B,R,C,I,FS> const& other) : parent(other.base())
|
||||
{}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ namespace rotgen
|
|||
template<typename ET>
|
||||
using as_concrete_type = as_concrete_t<ET, matrix>;
|
||||
|
||||
static constexpr bool is_immutable = false;
|
||||
static constexpr bool is_defined_static = Rows!=-1 && Cols!=-1;
|
||||
static constexpr bool has_static_storage = storage_status<Rows,Cols,MaxRows,MaxCols>;
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ namespace rotgen
|
|||
auto trace(concepts::entity auto const& arg) { return arg.trace(); }
|
||||
auto squaredNorm(concepts::entity auto const& arg) { return arg.squaredNorm(); }
|
||||
auto norm(concepts::entity auto const& arg) { return arg.norm(); }
|
||||
auto sum(concepts::entity auto const& arg) { return arg.sum(); }
|
||||
auto sum(auto const& arg) requires requires{ arg.sum(); } { return arg.sum(); }
|
||||
auto prod(concepts::entity auto const& arg) { return arg.prod(); }
|
||||
auto mean(concepts::entity auto const& arg) { return arg.mean(); }
|
||||
|
||||
|
|
|
|||
|
|
@ -25,15 +25,19 @@ namespace rotgen
|
|||
#define USE_CONST
|
||||
#define CONST const
|
||||
#define BASENAME block_const_impl
|
||||
#define BASEMAP map_const_impl
|
||||
#include <rotgen/impl/block_indirect.hpp>
|
||||
#undef BASENAME
|
||||
#undef BASEMAP
|
||||
#undef CONST
|
||||
#undef USE_CONST
|
||||
|
||||
#define CONST
|
||||
#define BASENAME block_impl
|
||||
#define BASEMAP map_impl
|
||||
#include <rotgen/impl/block_indirect.hpp>
|
||||
#undef BASENAME
|
||||
#undef BASEMAP
|
||||
#undef CONST
|
||||
|
||||
template<typename Scalar,int Options, bool isConst> struct find_block_impl;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(map_impl,SIZE,_col)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(BASEMAP,SIZE,_col)
|
||||
#include <rotgen/impl/block_model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(map_impl,SIZE,_row)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(BASEMAP,SIZE,_row)
|
||||
#include <rotgen/impl/block_model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(map_impl,SIZE,_col)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(BASEMAP,SIZE,_col)
|
||||
#include <rotgen/impl/block_model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(map_impl,SIZE,_row)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(BASEMAP,SIZE,_row)
|
||||
#include <rotgen/impl/block_model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue