- Refurbish block implementation to support nested block

- Add missing extractors
This commit is contained in:
Joel Falcou 2025-09-02 19:52:22 +02:00
parent 3fff326db9
commit 93a1404d9a
24 changed files with 1205 additions and 630 deletions

View file

@ -25,6 +25,8 @@ namespace rotgen
using value_type = typename T::value_type;
using rotgen_tag = void;
static constexpr int storage_order = T::storage_order;
using parent::operator();
using parent::rows;
using parent::cols;
@ -59,19 +61,19 @@ namespace rotgen
ref(matrix<S, R, C, O, MR, MC>& m)
: parent(m.data(), m.rows(), m.cols(), strides(m))
{
static_assert((O & 1) == Options, "ref: Incompatible storage layout");
static_assert((O & 1) == storage_order, "ref: Incompatible storage layout");
}
template<typename Ref, int R, int C, bool I, int FS>
ref(block<Ref,R,C,I,FS>& b) : parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
template<typename Ref, int R, int C, bool I>
ref(block<Ref,R,C,I>& b) : parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
{
static_assert((Ref::Options & 1) == Options, "ref: Incompatible storage layout");
static_assert((Ref::storage_order & 1) == storage_order, "ref: Incompatible storage layout");
}
template<typename Ref, int O, typename S>
ref(map<Ref,O,S>& b) : parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
{
static_assert((Ref::Options & 1) == Options, "ref: Incompatible storage layout");
static_assert((Ref::storage_order & 1) == storage_order, "ref: Incompatible storage layout");
}
ref(parent& m) : parent(m.data(), m.rows(), m.cols()) {}
@ -89,7 +91,9 @@ namespace rotgen
public:
using parent = map<const T, Options,Stride>;
using value_type = typename T::value_type;
using rotgen_tag = void;
using rotgen_tag = void;
static constexpr int storage_order = T::storage_order;
using parent::operator();
using parent::rows;
@ -125,19 +129,19 @@ namespace rotgen
ref(matrix<S, R, C, O, MR, MC> const& m)
: parent(m.data(), m.rows(), m.cols(), strides(m))
{
static_assert((O & 1) == Options, "ref: Incompatible storage layout");
static_assert((O & 1) == storage_order, "ref: Incompatible storage layout");
}
template<typename Ref, int R, int C, bool I, int FS>
ref(block<Ref,R,C,I,FS> const& b) : parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
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::Options & 1) == Options, "ref: Incompatible storage layout");
static_assert((Ref::storage_order & 1) == storage_order, "ref: Incompatible storage layout");
}
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::Options & 1) == Options, "ref: Incompatible storage layout");
static_assert((Ref::storage_order & 1) == storage_order, "ref: Incompatible storage layout");
}
ref(parent const& m) : parent(m.data(), m.rows(), m.cols()) {}
@ -151,14 +155,14 @@ namespace rotgen
template<typename S, int R, int C, int O, int MR, int MC>
ref(matrix<S, R, C, O, MR, MC>&) -> ref<matrix<S>>;
template<typename Ref, int R, int C, bool I, int FS>
ref(block<Ref,R,C,I,FS>& b) -> ref<Ref>;
template<typename Ref, int R, int C, bool I>
ref(block<Ref,R,C,I>& b) -> ref<Ref>;
template<typename S, int R, int C, int O, int MR, int MC>
ref(matrix<S, R, C, O, MR, MC> const&) -> ref<matrix<S> const>;
template<typename Ref, int R, int C, bool I, int FS>
ref(block<Ref,R,C,I,FS> const& b) -> ref<Ref const>;
template<typename Ref, int R, int C, bool I>
ref(block<Ref,R,C,I> const& b) -> ref<Ref const>;
template<typename A, int O, typename S, typename B, int P, typename T>
bool operator==(ref<A,O,S> lhs, ref<B,P,T> rhs)

View file

@ -15,8 +15,8 @@ namespace rotgen::concepts
template<typename T>
concept entity = requires(T const&)
{
typename T::rotgen_tag;
typename T::parent;
typename std::remove_cvref_t<T>::rotgen_tag;
typename std::remove_cvref_t<T>::parent;
};
//================================================================================================

View file

@ -15,7 +15,7 @@
namespace rotgen
{
template<typename Ref, int Rows = Dynamic, int Cols = Dynamic, bool Inner = false, int ForceStorageOrder = -1>
template<typename Ref, int Rows = Dynamic, int Cols = Dynamic, bool Inner = false>
class block : public find_block<Ref>
{
public:
@ -25,20 +25,24 @@ namespace rotgen
using parent = find_block<Ref>;
using rotgen_tag = void;
using value_type = typename Ref::value_type;
static constexpr int storage_order = (ForceStorageOrder == -1) ? Ref::storage_order : ForceStorageOrder;
using rotgen_block_tag = void;
using value_type = typename std::remove_const_t<Ref>::value_type;
static constexpr int storage_order = Ref::storage_order;
static constexpr bool is_immutable = std::is_const_v<Ref>;
using concrete_type = matrix<value_type,Rows,Cols,storage_order>;
using concrete_dynamic_type = matrix<value_type,Dynamic,Dynamic,storage_order>;
static constexpr int RowsAtCompileTime = Rows;
static constexpr int ColsAtCompileTime = Cols;
static constexpr int Options = Ref::Options;
static constexpr int RowsAtCompileTime = Rows;
static constexpr int ColsAtCompileTime = Cols;
static constexpr int Options = Ref::Options;
static constexpr bool IsRowMajor = (storage_order & RowMajor) == RowMajor;
static constexpr bool is_defined_static = false;
static constexpr bool has_static_storage = false;
static constexpr bool is_defined_static = false;
static constexpr bool has_static_storage = false;
using parent::operator=;
block& operator=(concepts::entity auto const& other)
block& operator=(concepts::entity auto const& other) requires(!is_immutable)
{
assert(parent::rows() == other.rows() && parent::cols() == other.cols());
for (rotgen::Index r = 0; r < parent::rows(); ++r)
@ -48,26 +52,58 @@ namespace rotgen
return *this;
}
block(Ref& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj) : parent(r,i0,j0,ni,nj)
block(Ref const& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
requires( !requires{typename Ref::rotgen_block_tag; } && is_immutable)
: parent(r,i0,j0,ni,nj)
{}
block(Ref& r, std::size_t i0, std::size_t j0) requires(Rows != -1 && Cols != -1)
block(Ref const& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
requires( requires{typename Ref::rotgen_block_tag; } && is_immutable)
: parent(*r.storage(),i0,j0,ni,nj)
{}
block(Ref const& r, std::size_t i0, std::size_t j0)
requires(!requires{typename Ref::rotgen_block_tag; } && Rows != -1 && Cols != -1 && is_immutable)
: parent(r,i0,j0,Rows,Cols)
{}
block(Ref const& r, std::size_t i0, std::size_t j0)
requires(requires{typename Ref::rotgen_block_tag; } && Rows != -1 && Cols != -1 && is_immutable)
: parent(*r.storage(),i0,j0,Rows,Cols)
{}
block(Ref& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
requires( !requires{typename Ref::rotgen_block_tag; } && !is_immutable)
: parent(r,i0,j0,ni,nj)
{}
block(Ref& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
requires( requires{typename Ref::rotgen_block_tag; } && !is_immutable)
: parent(*r.storage(),i0,j0,ni,nj)
{}
block(Ref& r, std::size_t i0, std::size_t j0)
requires(!requires{typename Ref::rotgen_block_tag; } && Rows != -1 && Cols != -1 && !is_immutable)
: parent(r,i0,j0,Rows,Cols)
{}
block(Ref& r, std::size_t i0, std::size_t j0)
requires(requires{typename Ref::rotgen_block_tag; } && Rows != -1 && Cols != -1 && !is_immutable)
: parent(*r.storage(),i0,j0,Rows,Cols)
{}
block(parent const& base) : parent(base) {}
bool is_contiguous_linear() const
{
if(parent::innerStride() != 1) return false;
// outerstride must equal the “innerdimension length”
if constexpr(storage_order) return parent::outerStride() == parent::cols();
else return parent::outerStride() == parent::rows();
}
value_type& operator()(Index i, Index j) { return parent::operator()(i,j); }
value_type& operator()(Index i, Index j) requires(!is_immutable) { return parent::operator()(i,j); }
value_type& operator()(Index i)
value_type& operator()(Index i) requires(!is_immutable)
{
assert(is_contiguous_linear());
return parent::operator()(i);
@ -96,22 +132,22 @@ namespace rotgen
return concrete_type(static_cast<parent const &>(*this).adjoint());
}
void transposeInPlace() { parent::transposeInPlace(); }
void transposeInPlace() requires(!is_immutable) { parent::transposeInPlace(); }
void adjointInPlace() { parent::adjointInPlace(); }
void adjointInPlace() requires(!is_immutable) { parent::adjointInPlace(); }
friend bool operator==(block const& lhs, block const& rhs)
{
return static_cast<parent const&>(lhs) == static_cast<parent const&>(rhs);
}
block& operator+=(block const& rhs)
block& operator+=(block const& rhs) requires(!is_immutable)
{
base() += static_cast<parent const&>(rhs);
return *this;
}
block& operator-=(block const& rhs)
block& operator-=(block const& rhs) requires(!is_immutable)
{
base() -= static_cast<parent const&>(rhs);
return *this;
@ -122,19 +158,19 @@ namespace rotgen
return concrete_type(static_cast<parent const&>(*this).operator-());
}
block& operator*=(block const& rhs)
block& operator*=(block const& rhs) requires(!is_immutable)
{
base() *= static_cast<parent const&>(rhs);
return *this;
}
block& operator*=(value_type rhs)
block& operator*=(value_type rhs) requires(!is_immutable)
{
base() *= rhs;
return *this;
}
block& operator/=(value_type rhs)
block& operator/=(value_type rhs) requires(!is_immutable)
{
base() /= rhs;
return *this;
@ -205,31 +241,31 @@ namespace rotgen
return parent::Identity(rows, cols);
}
block& setOnes()
block& setOnes() requires(!is_immutable)
{
parent::assign(parent::Ones(parent::rows(), parent::cols()));
return *this;
}
block& setZero()
block& setZero() requires(!is_immutable)
{
parent::assign(parent::Zero(parent::rows(), parent::cols()));
return *this;
}
block& setConstant(value_type value)
block& setConstant(value_type value) requires(!is_immutable)
{
parent::assign(parent::Constant(parent::rows(), parent::cols(), value));
return *this;
}
block& setRandom()
block& setRandom() requires(!is_immutable)
{
parent::assign(parent::Random(parent::rows(), parent::cols()));
return *this;
}
block& setIdentity()
block& setIdentity() requires(!is_immutable)
{
parent::assign(parent::Identity(parent::rows(), parent::cols()));
return *this;
@ -246,45 +282,45 @@ namespace rotgen
parent const& base() const { return static_cast<parent const&>(*this); }
};
template<typename Ref, int R, int C, bool I, int F>
auto operator+(block<Ref, R, C, I, F> const& lhs, block<Ref, R, C, I, F> const& rhs)
template<typename Ref, int R, int C, bool I>
auto operator+(block<Ref, R, C, I> const& lhs, block<Ref, R, C, I> const& rhs)
{
using concrete_type = typename block<Ref, R, C, I, F>::concrete_type;
using concrete_type = typename block<Ref, R, C, I>::concrete_type;
return concrete_type(lhs.base().add(rhs));
}
template<typename Ref, int R, int C, bool I, int F>
auto operator-(block<Ref, R, C, I, F> const& lhs, block<Ref, R, C, I, F> const& rhs)
template<typename Ref, int R, int C, bool I>
auto operator-(block<Ref, R, C, I> const& lhs, block<Ref, R, C, I> const& rhs)
{
using concrete_type = typename block<Ref, R, C, I, F>::concrete_type;
using concrete_type = typename block<Ref, R, C, I>::concrete_type;
return concrete_type(lhs.base().sub(rhs));
}
template<typename Ref, int R, int C, bool I, int F>
auto operator*(block<Ref, R, C, I, F> const& lhs, block<Ref, R, C, I, F> const& rhs)
template<typename Ref, int R, int C, bool I>
auto operator*(block<Ref, R, C, I> const& lhs, block<Ref, R, C, I> const& rhs)
{
using concrete_type = typename block<Ref, R, C, I, F>::concrete_type;
using concrete_type = typename block<Ref, R, C, I>::concrete_type;
return concrete_type(lhs.base().mul(rhs));
}
template<typename Ref, int R, int C, bool I, int F>
auto operator*(block<Ref, R, C, I, F> const& lhs, double rhs)
template<typename Ref, int R, int C, bool I>
auto operator*(block<Ref, R, C, I> const& lhs, double rhs)
{
using concrete_type = typename block<Ref, R, C, I, F>::concrete_type;
using concrete_type = typename block<Ref, R, C, I>::concrete_type;
return concrete_type(lhs.base().mul(rhs));
}
template<typename Ref, int R, int C, bool I, int F>
auto operator*(double lhs, block<Ref, R, C, I, F> const& rhs)
template<typename Ref, int R, int C, bool I>
auto operator*(double lhs, block<Ref, R, C, I> const& rhs)
{
using concrete_type = typename block<Ref, R, C, I, F>::concrete_type;
using concrete_type = typename block<Ref, R, C, I>::concrete_type;
return concrete_type(rhs.base().mul(lhs));
}
template<typename Ref, int R, int C, bool I, int F>
auto operator/(block<Ref, R, C, I, F> const& lhs, double rhs)
template<typename Ref, int R, int C, bool I>
auto operator/(block<Ref, R, C, I> const& lhs, double rhs)
{
using concrete_type = typename block<Ref, R, C, I, F>::concrete_type;
using concrete_type = typename block<Ref, R, C, I>::concrete_type;
return concrete_type(lhs.base().div(rhs));
}
}

View file

@ -22,12 +22,14 @@ namespace rotgen
, "[ROTGEN][CRITICAL] - Map of non-rotgen type instanciated"
);
using parent = find_map<Ref>;
using rotgen_tag = void;
using value_type = typename std::remove_const_t<Ref>::value_type;
using concrete_type = typename std::remove_const_t<Ref>::concrete_type;
static constexpr int storage_order = Ref::storage_order;
static constexpr bool has_static_storage = false;
using parent = find_map<Ref>;
using rotgen_tag = void;
using value_type = typename std::remove_const_t<Ref>::value_type;
using concrete_type = typename std::remove_const_t<Ref>::concrete_type;
static constexpr bool IsRowMajor = Ref::IsRowMajor;
static constexpr int storage_order = Ref::storage_order;
static constexpr bool has_static_storage = false;
static constexpr bool is_immutable = std::is_const_v<Ref>;
static constexpr bool is_defined_static = false;

View file

@ -21,17 +21,18 @@ namespace rotgen
class matrix : public find_matrix<Scalar,Opts>
{
public:
using parent = find_matrix<Scalar,Opts>;
using rotgen_tag = void;
using concrete_type = matrix;
using value_type = Scalar;
static constexpr auto storage_order = Opts & 1;
using parent = find_matrix<Scalar,Opts>;
using rotgen_tag = void;
using concrete_type = matrix;
using value_type = Scalar;
static constexpr int RowsAtCompileTime = Rows;
static constexpr int ColsAtCompileTime = Cols;
static constexpr int Options = Opts;
static constexpr bool is_defined_static = false;
static constexpr bool has_static_storage = false;
static constexpr auto storage_order = Opts & 1;
static constexpr int RowsAtCompileTime = Rows;
static constexpr int ColsAtCompileTime = Cols;
static constexpr int Options = Opts;
static constexpr bool IsRowMajor = (Opts & RowMajor) == RowMajor;
static constexpr bool is_defined_static = false;
static constexpr bool has_static_storage = false;
matrix() : parent(Rows==-1?0:Rows,Cols==-1?0:Cols) {}

View file

@ -9,224 +9,233 @@
namespace rotgen
{
template< typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto extract(matrix<S,R,C,Opts,MaxR,MaxC>& m, int i0, int j0,int ni, int nj)
namespace detail
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base>(m, i0,j0,ni,nj);
template<concepts::entity Entity>
void validate_extract ( [[maybe_unused]] Entity& e
, [[maybe_unused]] Index i0, [[maybe_unused]] Index j0
, [[maybe_unused]] Index ni, [[maybe_unused]] Index nj
)
{
assert(i0 >= 0 && "block extraction uses negative row index.");
assert(j0 >= 0 && "block extraction uses negative col index.");
assert(i0 + ni <= e.rows() && "block extraction rows is out of range.");
assert(j0 + nj <= e.cols() && "block extraction cols is out of range.");
}
}
//======================== EXTRACT ========================
template<concepts::entity Entity>
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< int NI, int NJ
, typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto extract(matrix<S,R,C,Opts,MaxR,MaxC>& m, int i0, int j0)
template<Index NI, Index NJ, concepts::entity Entity>
requires(NI!=-1 && NJ!=-1)
auto extract(Entity& e, Index i0, Index j0)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base,NI,NJ>(m,i0,j0);
detail::validate_extract(e,i0,j0,NI,NJ);
return block<Entity,NI,NJ>(e, i0, j0);
}
template< typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto topLeftCorner(matrix<S,R,C,Opts,MaxR,MaxC>& m, int ni, int nj)
template<Index NI, Index NJ, concepts::entity Entity>
requires((NI!=-1) != (NJ!=-1))
auto extract(Entity& e, Index i0, Index j0, Index ni, Index nj)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base>(m,0,0,ni,nj);
detail::validate_extract(e,i0,j0,ni,nj);
return block<Entity,NI,NJ>(e, i0, j0, ni, nj);
}
template< typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto topRightCorner(matrix<S,R,C,Opts,MaxR,MaxC>& m, int ni, int nj)
//======================== TOP LEFT CORNER ========================
template<concepts::entity Entity>
auto topLeftCorner(Entity& e, Index ni, Index nj)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base>(m,0,m.cols()-nj,ni,nj);
return extract(e, 0, 0, ni, nj);
}
template< typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto bottomLeftCorner(matrix<S,R,C,Opts,MaxR,MaxC>& m, int ni, int nj)
template<Index NI, Index NJ, concepts::entity Entity>
auto topLeftCorner(Entity& e)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base>(m,m.rows()-ni,0,ni,nj);
return extract<NI,NJ>(e, 0, 0);
}
template< typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto bottomRightCorner(matrix<S,R,C,Opts,MaxR,MaxC>& m, int ni, int nj)
//======================== TOP RIGHT CORNER ========================
template<concepts::entity Entity>
auto topRightCorner(Entity& e, Index ni, Index nj)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base>(m,m.rows()-ni,m.cols()-nj,ni,nj);
return extract(e, 0, e.cols() - nj, ni, nj);
}
template< typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto topRows(matrix<S,R,C,Opts,MaxR,MaxC>& m, int ni)
template<Index NI, Index NJ, concepts::entity Entity>
auto topRightCorner(Entity& e)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base>(m,0,0,ni,m.cols());
return extract<NI,NJ>(e, 0, e.cols()-NJ);
}
template< typename S, int R , int C,
int Opts , int MaxR, int MaxC
>
auto middleRows(matrix<S,R,C,Opts,MaxR,MaxC>& m, int i0, int ni)
//======================== BOTTOM LEFT CORNER ========================
template<concepts::entity Entity>
auto bottomLeftCorner(Entity& e, Index ni, Index nj)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base>(m,i0,0,ni,m.cols());
return extract(e, e.rows() - ni, 0, ni, nj);
}
template< typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto bottomRows(matrix<S,R,C,Opts,MaxR,MaxC>& m, int ni)
template<Index NI, Index NJ, concepts::entity Entity>
auto bottomLeftCorner(Entity& e)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base>(m,m.rows()-ni,0,ni,m.cols());
return extract<NI,NJ>(e, e.rows()-NI, 0);
}
template< typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto leftCols(matrix<S,R,C,Opts,MaxR,MaxC>& m, int nj)
//======================== BOTTOM RIGHT CORNER ========================
template<concepts::entity Entity>
auto bottomRightCorner(Entity& e, Index ni, Index nj)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base>(m,0,0,m.rows(),nj);
return extract(e, e.rows() - ni, e.cols() - nj, ni, nj);
}
template< typename S, int R , int C,
int Opts , int MaxR, int MaxC
>
auto middleCols(matrix<S,R,C,Opts,MaxR,MaxC>& m, int j0, int nj)
template<Index NI, Index NJ, concepts::entity Entity>
auto bottomRightCorner(Entity& e)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base>(m,0,j0,m.rows(),nj);
return extract<NI,NJ>(e, e.rows()-NI, e.cols()-NJ);
}
template< typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto rightCols(matrix<S,R,C,Opts,MaxR,MaxC>& m, int nj)
//======================== TOP ROWS ========================
template<concepts::entity Entity>
auto topRows(Entity& e, Index ni)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base>(m,0,m.cols()-nj,m.rows(),nj);
return extract(e, 0, 0, ni, e.cols());
}
template< typename S, int R, int C
, int Opts , int MaxR, int MaxC
>
auto row(matrix<S,R,C,Opts,MaxR,MaxC>& m, int i0)
template<Index NI, concepts::entity Entity>
auto topRows(Entity& e)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base,1, -1, false, 1>(m,i0,0, 1, m.cols());
return extract<NI,-1>(e, 0, 0, NI,e.cols());
}
template< typename S, int R, int C
, int Opts , int MaxR, int MaxC
>
auto col(matrix<S,R,C,Opts,MaxR,MaxC>& m, int j0)
//======================== MIDDLE ROWS ========================
template<concepts::entity Entity>
auto middleRows(Entity& e, Index i0, Index ni)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base,-1,1, false, 0>(m,0,j0, m.rows(), 1);
return extract(e, i0, 0, ni, e.cols());
}
template< int NI, typename S, int R, int C,
int Opts, int MaxR, int MaxC
>
auto topRows(matrix<S,R,C,Opts,MaxR,MaxC>& m)
template<Index NI, concepts::entity Entity>
auto middleRows(Entity& e, Index i0)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base,NI,-1>(m,0,0, NI, m.cols());
return extract<NI,-1>(e, i0, 0,NI,e.cols());
}
template< int NI, typename S, int R, int C,
int Opts, int MaxR, int MaxC
>
auto bottomRows(matrix<S,R,C,Opts,MaxR,MaxC>& m)
//======================== BOTTOM ROWS ========================
template<concepts::entity Entity>
auto bottomRows(Entity& e, Index ni)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base,NI,-1>(m,m.rows()-NI,0, NI, m.cols());
return extract(e, e.rows() - ni, 0, ni, e.cols());
}
template< int NI, typename S, int R, int C,
int Opts , int MaxR, int MaxC
>
auto middleRows(matrix<S,R,C,Opts,MaxR,MaxC>& m, int i0)
template<Index NI, concepts::entity Entity>
auto bottomRows(Entity& e)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base,NI,-1>(m,i0,0, NI, m.cols());
return extract<NI,-1>(e, e.rows()-NI, 0,NI,e.cols());
}
template< int NJ, typename S, int R, int C,
int Opts, int MaxR, int MaxC
>
auto leftCols(matrix<S,R,C,Opts,MaxR,MaxC>& m)
//======================== LEFT COLS ========================
template<concepts::entity Entity>
auto leftCols(Entity& e, Index nj)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base,-1,NJ>(m,0,0, m.rows(), NJ);
return extract(e, 0, 0, e.rows(), nj);
}
template< int NJ, typename S, int R, int C,
int Opts, int MaxR, int MaxC
>
auto rightCols(matrix<S,R,C,Opts,MaxR,MaxC>& m)
template<Index NJ, concepts::entity Entity>
auto leftCols(Entity& e)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base,-1,NJ>(m,0,m.cols()-NJ, m.rows(), NJ);
return extract<-1,NJ>(e, 0, 0,e.rows(),NJ);
}
template< int NJ, typename S, int R, int C,
int Opts , int MaxR, int MaxC
>
auto middleCols(matrix<S,R,C,Opts,MaxR,MaxC>& m, int j0)
//======================== MIDDLE COLS ========================
template<concepts::entity Entity>
auto middleCols(Entity& e, Index j0, Index nj)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base,-1,NJ>(m,0,j0, m.rows(), NJ);
return extract(e, 0, j0, e.rows(), nj);
}
template< int NI, int NJ
, typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto topLeftCorner(matrix<S,R,C,Opts,MaxR,MaxC>& m)
template<Index NJ, concepts::entity Entity>
auto middleCols(Entity& e, Index j0)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base,NI,NJ>(m,0,0);
return extract<-1,NJ>(e, 0, j0,e.rows(),NJ);
}
template< int NI, int NJ
, typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto topRightCorner(matrix<S,R,C,Opts,MaxR,MaxC>& m)
//======================== RIGHT COLS ========================
template<concepts::entity Entity>
auto rightCols(Entity& e, Index nj)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base,NI,NJ>(m,0,m.cols()-NJ);
return extract(e, 0, e.cols() - nj, e.rows(), nj);
}
template< int NI, int NJ
, typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto bottomLeftCorner(matrix<S,R,C,Opts,MaxR,MaxC>& m)
template<Index NJ, concepts::entity Entity>
auto rightCols(Entity& e)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base,NI,NJ>(m,m.rows()-NI,0);
return extract<-1,NJ>(e, 0, e.cols()-NJ,e.rows(),NJ);
}
template< int NI, int NJ
, typename S, int R , int C
, int Opts , int MaxR, int MaxC
>
auto bottomRightCorner(matrix<S,R,C,Opts,MaxR,MaxC>& m)
//======================== ROW ========================
template<concepts::entity Entity>
auto row(Entity& e, Index i0)
{
using base = matrix<S,R,C,Opts,MaxR,MaxC>;
return block<base,NI,NJ>(m,m.rows()-NI,m.cols()-NJ);
return extract<1,-1>(e, i0, 0, 1, e.cols());
}
}
//======================== COL ========================
template<concepts::entity Entity>
auto col(Entity& e, Index j0)
{
return extract<-1,1>(e, 0, j0, e.rows(), 1);
}
//======================== VECTOR HEAD ========================
template<concepts::entity Entity>
auto head(Entity& e, Index n)
requires(Entity::RowsAtCompileTime==1 || Entity::ColsAtCompileTime==1)
{
if constexpr(Entity::RowsAtCompileTime==1) return extract<1,Dynamic>(e,0,0,1,n);
else if constexpr(Entity::ColsAtCompileTime==1) return extract<Dynamic,1>(e,0,0,n,1);
}
template<Index N, concepts::entity Entity>
auto head(Entity& e) requires(Entity::RowsAtCompileTime==1 || Entity::ColsAtCompileTime==1)
{
if constexpr(Entity::RowsAtCompileTime==1) return extract<1,N>(e,0,0);
else if constexpr(Entity::ColsAtCompileTime==1) return extract<N,1>(e,0,0);
}
//======================== VECTOR TAIL ========================
template<concepts::entity Entity>
auto tail(Entity& e, Index n)
requires(Entity::RowsAtCompileTime==1 || Entity::ColsAtCompileTime==1)
{
if constexpr(Entity::RowsAtCompileTime==1) return extract<1,Dynamic>(e,0,e.cols()-n,1,n);
else if constexpr(Entity::ColsAtCompileTime==1) return extract<Dynamic,1>(e,e.rows()-n,0,n,1);
}
template<Index N, concepts::entity Entity>
auto tail(Entity& e) requires(Entity::RowsAtCompileTime==1 || Entity::ColsAtCompileTime==1)
{
if constexpr(Entity::RowsAtCompileTime==1) return extract<1,N>(e,0,e.cols()-N);
else if constexpr(Entity::ColsAtCompileTime==1) return extract<N,1>(e,e.rows()-N,0);
}
//======================== VECTOR SEGMENT ========================
template<concepts::entity Entity>
auto segment(Entity& e, Index s, Index n)
requires(Entity::RowsAtCompileTime==1 || Entity::ColsAtCompileTime==1)
{
if constexpr(Entity::RowsAtCompileTime==1) return extract<1,Dynamic>(e,0,s,1,n);
else if constexpr(Entity::ColsAtCompileTime==1) return extract<Dynamic,1>(e,s,0,n,1);
}
template<Index N, concepts::entity Entity>
auto segment(Entity& e, Index s) requires(Entity::RowsAtCompileTime==1 || Entity::ColsAtCompileTime==1)
{
if constexpr(Entity::RowsAtCompileTime==1) return extract<1,N>(e,0,s);
else if constexpr(Entity::ColsAtCompileTime==1) return extract<N,1>(e,s,0);
}
}

View file

@ -14,30 +14,43 @@ namespace rotgen
{
namespace detail
{
template<typename Ref, int Rows, int Cols, bool Inner>
using block_type = std::conditional_t < storage_status<Rows,Cols,Rows,Cols>
, Eigen::Block<typename Ref::parent, Rows, Cols, Inner>
, Eigen::Block<typename Ref::parent, Eigen::Dynamic, Eigen::Dynamic, Inner>
>;
template<typename Ref, int Rows, int Cols, bool Inner, bool IsConst>
struct compute_block_type
{
using ref_t = std::conditional_t<IsConst, typename Ref::parent const, typename Ref::parent>;
using type = std::conditional_t < storage_status<Rows,Cols,Rows,Cols>
, Eigen::Block<ref_t, Rows, Cols, Inner>
, Eigen::Block<ref_t, Eigen::Dynamic, Eigen::Dynamic, Inner>
>;
};
template<typename Ref, int Rows, int Cols, bool Inner, bool IsConst>
using block_type = typename compute_block_type<Ref,Rows,Cols,Inner,IsConst>::type;
}
template< typename Ref
, int Rows = Dynamic, int Cols = Dynamic
, bool Inner = false , int ForceStorageOrder = -1
>
class block : private detail::block_type<Ref, Rows, Cols, Inner>
class block : private detail::block_type<std::remove_const_t<Ref>, Rows, Cols, Inner,std::is_const_v<Ref> >
{
static_assert ( concepts::entity<Ref>
, "[ROTGEN][CRITICAL] - Block of non-rotgen type instanciated"
);
public:
using rotgen_tag = void;
using parent = detail::block_type<Ref, Rows, Cols, Inner>;
using value_type = typename parent::value_type;
using Index = typename parent::Index;
using rotgen_tag = void;
using rotgen_block_tag = void;
using parent = detail::block_type<std::remove_const_t<Ref>, Rows, Cols, Inner,std::is_const_v<Ref>>;
using value_type = typename parent::value_type;
using Index = typename parent::Index;
static constexpr int storage_order = (ForceStorageOrder == -1) ? Ref::storage_order : ForceStorageOrder;
static constexpr bool is_immutable = std::is_const_v<Ref>;
static constexpr bool IsRowMajor = parent::IsRowMajor;
static constexpr int storage_order = (ForceStorageOrder == -1) ? Ref::storage_order : ForceStorageOrder;
using concrete_type = matrix<value_type,Rows,Cols,storage_order>;
using concrete_dynamic_type = matrix<value_type,Dynamic,Dynamic,storage_order>;
@ -58,10 +71,23 @@ namespace rotgen
block& operator=(const block&) = default;
block& operator=(block&&) = default;
block(Ref& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj) : parent(r.base(),i0,j0,ni,nj)
block(Ref const& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
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)
block(Ref const& r, std::size_t i0, std::size_t j0)
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)
: 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)
: parent(r.base(),i0,j0,Rows,Cols)
{}
@ -111,8 +137,8 @@ namespace rotgen
return as_concrete_type<decltype(res)>(res);
}
void transposeInPlace() { parent::transposeInPlace(); }
void adjointInPlace() { parent::adjointInPlace(); }
void transposeInPlace() requires(!is_immutable) { parent::transposeInPlace(); }
void adjointInPlace() requires(!is_immutable) { parent::adjointInPlace(); }
static concrete_type Constant(value_type value) requires (Rows != -1 && Cols != -1)
{
@ -174,61 +200,61 @@ namespace rotgen
return parent::Random(rows, cols);
}
block& setOnes()
block& setOnes() requires(!is_immutable)
{
*this = parent::Ones(rows(), cols());
return *this;
}
block& setOnes(int r, int c)
block& setOnes(int r, int c) requires(!is_immutable)
{
*this = parent::Ones(r, c);
return *this;
}
block& setZero()
block& setZero() requires(!is_immutable)
{
*this = parent::Zero(rows(), cols());
return *this;
}
block& setZero(int r, int c)
block& setZero(int r, int c) requires(!is_immutable)
{
*this = parent::Zero(r,c);
return *this;
}
block& setConstant(value_type value)
block& setConstant(value_type value) requires(!is_immutable)
{
*this = parent::Constant(rows(), cols(), value);
return *this;
}
block& setConstant(int r, int c, value_type value)
block& setConstant(int r, int c, value_type value) requires(!is_immutable)
{
*this = parent::Constant(r,c, value);
return *this;
}
block& setRandom()
block& setRandom() requires(!is_immutable)
{
*this = parent::Random(rows(),cols());
return *this;
}
block& setRandom(int r, int c)
block& setRandom(int r, int c) requires(!is_immutable)
{
*this = parent::Random(r,c);
return *this;
}
block& setIdentity()
block& setIdentity() requires(!is_immutable)
{
*this = parent::Identity(rows(),cols());
return *this;
}
block& setIdentity(int r, int c)
block& setIdentity(int r, int c) requires(!is_immutable)
{
*this = parent::Identity(r,c);
return *this;
@ -249,10 +275,10 @@ namespace rotgen
else return parent::outerStride() == parent::rows();
}
value_type& operator()(Index i, Index j) { return base()(i,j); }
value_type& operator()(Index i, Index j) requires(!is_immutable) { return base()(i,j); }
value_type operator()(Index i, Index j) const { return base()(i,j); }
value_type& operator()(Index i)
value_type& operator()(Index i) requires(!is_immutable)
{
assert(is_contiguous_linear());
return base().data()[i];
@ -279,13 +305,16 @@ namespace rotgen
using parent::sum;
using parent::data;
block& operator+=(block const& rhs)
Index startRow() const { return base().startRow(); }
Index startCol() const { return base().startCol(); }
block& operator+=(block const& rhs) requires(!is_immutable)
{
static_cast<parent&>(*this) += static_cast<parent const&>(rhs);
return *this;
}
block& operator-=(block const& rhs)
block& operator-=(block const& rhs) requires(!is_immutable)
{
static_cast<parent&>(*this) -= static_cast<parent const&>(rhs);
return *this;
@ -296,19 +325,19 @@ namespace rotgen
return concrete_type(static_cast<parent const&>(*this).operator-());
}
block& operator*=(block const& rhs)
block& operator*=(block const& rhs) requires(!is_immutable)
{
static_cast<parent&>(*this) *= static_cast<parent const&>(rhs);
return *this;
}
block& operator*=(value_type rhs)
block& operator*=(value_type rhs) requires(!is_immutable)
{
static_cast<parent&>(*this) *= rhs;
return *this;
}
block& operator/=(value_type rhs)
block& operator/=(value_type rhs) requires(!is_immutable)
{
static_cast<parent&>(*this) /= rhs;
return *this;

View file

@ -42,6 +42,7 @@ namespace rotgen
static constexpr int RowsAtCompileTime = Rows;
static constexpr int ColsAtCompileTime = Cols;
static constexpr int Options = parent::Options;
static constexpr bool IsRowMajor = parent::IsRowMajor;
template<typename ET>
using as_concrete_type = as_concrete_t<ET, matrix>;

View file

@ -9,55 +9,47 @@
#include <rotgen/detail/generators.hpp>
#include <rotgen/impl/matrix.hpp>
#include <rotgen/impl/map.hpp>
#include <initializer_list>
#include <cstddef>
#include <memory>
namespace rotgen
{
#define SIZE 64
#define TYPE double
class matrix_impl64_row;
class matrix_impl64_col;
class matrix_impl32_row;
class matrix_impl32_col;
#define CLASSNAME ROTGEN_MATRIX_NAME(block_impl,SIZE,_col)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
#include <rotgen/impl/block_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#define CLASSNAME ROTGEN_MATRIX_NAME(block_impl,SIZE,_row)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
#include <rotgen/impl/block_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#define USE_CONST
#define CONST const
#define BASENAME block_const_impl
#include <rotgen/impl/block_indirect.hpp>
#undef BASENAME
#undef CONST
#undef USE_CONST
#undef SIZE
#undef TYPE
#define CONST
#define BASENAME block_impl
#include <rotgen/impl/block_indirect.hpp>
#undef BASENAME
#undef CONST
#define SIZE 32
#define TYPE float
template<typename Scalar,int Options, bool isConst> struct find_block_impl;
#define CLASSNAME ROTGEN_MATRIX_NAME(block_impl,SIZE,_col)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
#include <rotgen/impl/block_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#define CLASSNAME ROTGEN_MATRIX_NAME(block_impl,SIZE,_row)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
#include <rotgen/impl/block_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#undef SIZE
#undef TYPE
template<typename Scalar,int Options> struct find_block_impl;
template<> struct find_block_impl<float , ColMajor> { using type = block_impl32_col; };
template<> struct find_block_impl<float , RowMajor> { using type = block_impl32_row; };
template<> struct find_block_impl<double, ColMajor> { using type = block_impl64_col; };
template<> struct find_block_impl<double, RowMajor> { using type = block_impl64_row; };
template<> struct find_block_impl<float , ColMajor, true> { using type = block_const_impl32_col; };
template<> struct find_block_impl<float , RowMajor, true> { using type = block_const_impl32_row; };
template<> struct find_block_impl<double, ColMajor, true> { using type = block_const_impl64_col; };
template<> struct find_block_impl<double, RowMajor, true> { using type = block_const_impl64_row; };
template<> struct find_block_impl<float , ColMajor, false> { using type = block_impl32_col; };
template<> struct find_block_impl<float , RowMajor, false> { using type = block_impl32_row; };
template<> struct find_block_impl<double, ColMajor, false> { using type = block_impl64_col; };
template<> struct find_block_impl<double, RowMajor, false> { using type = block_impl64_row; };
template<typename Ref>
using find_block = typename find_block_impl<typename Ref::value_type, Ref::storage_order>::type;
using find_block = typename find_block_impl < typename std::remove_const_t<Ref>::value_type
, Ref::storage_order
, std::is_const_v<Ref>
>::type;
}

View file

@ -0,0 +1,43 @@
#define SIZE 64
#define TYPE double
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
#define MAPNAME ROTGEN_MATRIX_NAME(map_impl,SIZE,_col)
#include <rotgen/impl/block_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#undef MAPNAME
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
#define MAPNAME ROTGEN_MATRIX_NAME(map_impl,SIZE,_row)
#include <rotgen/impl/block_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#undef MAPNAME
#undef SIZE
#undef TYPE
#define SIZE 32
#define TYPE float
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
#define MAPNAME ROTGEN_MATRIX_NAME(map_impl,SIZE,_col)
#include <rotgen/impl/block_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#undef MAPNAME
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
#define MAPNAME ROTGEN_MATRIX_NAME(map_impl,SIZE,_row)
#include <rotgen/impl/block_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#undef MAPNAME
#undef SIZE
#undef TYPE

View file

@ -13,18 +13,28 @@
//==================================================================================================
class ROTGEN_EXPORT CLASSNAME
{
private:
struct payload;
std::unique_ptr<payload> storage_;
public:
CLASSNAME(SOURCENAME& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj);
CLASSNAME(SOURCENAME CONST& r , Index i0, Index j0, Index ni, Index nj);
CLASSNAME(MAPNAME CONST& r, Index i0, Index j0, Index ni, Index nj);
CLASSNAME(payload const& r, Index i0, Index j0, Index ni, Index nj);
CLASSNAME(CLASSNAME const& other);
CLASSNAME(CLASSNAME&&) noexcept;
#if !defined(USE_CONST)
CLASSNAME& operator=(CLASSNAME const& other);
CLASSNAME& operator=(CLASSNAME&&) noexcept;
#endif
~CLASSNAME();
#if !defined(USE_CONST)
void assign(SOURCENAME const&);
#endif
Index rows() const;
Index cols() const;
@ -33,12 +43,17 @@ class ROTGEN_EXPORT CLASSNAME
Index innerStride() const;
Index outerStride() const;
Index startRow() const;
Index startCol() const;
SOURCENAME transpose() const;
SOURCENAME conjugate() const;
SOURCENAME adjoint() const;
#if !defined(USE_CONST)
void transposeInPlace();
void adjointInPlace();
#endif
TYPE sum() const;
TYPE prod() const;
@ -53,18 +68,19 @@ class ROTGEN_EXPORT CLASSNAME
TYPE norm() const;
TYPE lpNorm(int p) const;
TYPE& operator()(std::size_t i, std::size_t j);
TYPE const& operator()(std::size_t i, std::size_t j) const;
TYPE& operator()(std::size_t index);
TYPE const& operator()(std::size_t index) const;
#if !defined(USE_CONST)
TYPE& operator()(Index i, Index j);
TYPE& operator()(Index index);
CLASSNAME& operator+=(CLASSNAME const& rhs);
CLASSNAME& operator-=(CLASSNAME const& rhs);
SOURCENAME operator-() const;
CLASSNAME& operator*=(CLASSNAME const& rhs);
CLASSNAME& operator*=(TYPE d);
CLASSNAME& operator/=(TYPE d);
#endif
TYPE operator()(Index i, Index j) const;
TYPE operator()(Index index) const;
SOURCENAME operator-() const;
SOURCENAME add(CLASSNAME const& rhs) const;
SOURCENAME sub(CLASSNAME const& rhs) const;
@ -76,20 +92,21 @@ class ROTGEN_EXPORT CLASSNAME
friend ROTGEN_EXPORT bool operator==(CLASSNAME const& lhs, CLASSNAME const& rhs);
friend ROTGEN_EXPORT bool operator!=(CLASSNAME const& lhs, CLASSNAME const& rhs);
const TYPE* data() const;
#if !defined(USE_CONST)
TYPE* data();
#endif
const TYPE* data() const;
static SOURCENAME Zero(std::size_t r, std::size_t c) { return SOURCENAME::Zero(r,c); }
static SOURCENAME Ones(std::size_t r, std::size_t c) { return SOURCENAME::Ones(r,c); }
static SOURCENAME Constant(std::size_t r, std::size_t c, TYPE v) { return SOURCENAME::Constant(r,c,v); }
static SOURCENAME Random(std::size_t r, std::size_t c) { return SOURCENAME::Random(r,c); }
static SOURCENAME Identity(std::size_t r, std::size_t c) { return SOURCENAME::Identity(r,c); }
private:
struct payload;
std::unique_ptr<payload> storage_;
static SOURCENAME Zero(Index r, Index c) { return SOURCENAME::Zero(r,c); }
static SOURCENAME Ones(Index r, Index c) { return SOURCENAME::Ones(r,c); }
static SOURCENAME Constant(Index r, Index c, TYPE v) { return SOURCENAME::Constant(r,c,v); }
static SOURCENAME Random(Index r, Index c) { return SOURCENAME::Random(r,c); }
static SOURCENAME Identity(Index r, Index c) { return SOURCENAME::Identity(r,c); }
public:
#if !defined(USE_CONST)
std::unique_ptr<payload>& storage() { return storage_; }
#endif
std::unique_ptr<payload> const& storage() const { return storage_; }
};

View file

@ -18,82 +18,19 @@ namespace rotgen
{
#define USE_CONST
#define CONST const
#define SIZE 64
#define TYPE double
#define CLASSNAME ROTGEN_MATRIX_NAME(map_const_impl,SIZE,_col)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
#include <rotgen/impl/map_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#define CLASSNAME ROTGEN_MATRIX_NAME(map_const_impl,SIZE,_row)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
#include <rotgen/impl/map_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#undef SIZE
#undef TYPE
#define SIZE 32
#define TYPE float
#define CLASSNAME ROTGEN_MATRIX_NAME(map_const_impl,SIZE,_col)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
#include <rotgen/impl/map_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#define CLASSNAME ROTGEN_MATRIX_NAME(map_const_impl,SIZE,_row)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
#include <rotgen/impl/map_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#undef SIZE
#undef TYPE
#define BASENAME map_const_impl
#include <rotgen/impl/map_indirect.hpp>
#undef BASENAME
#undef CONST
#undef USE_CONST
#define SIZE 64
#define TYPE double
#define CONST
#define CLASSNAME ROTGEN_MATRIX_NAME(map_impl,SIZE,_col)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
#include <rotgen/impl/map_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#define CLASSNAME ROTGEN_MATRIX_NAME(map_impl,SIZE,_row)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
#include <rotgen/impl/map_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#undef SIZE
#undef TYPE
#define SIZE 32
#define TYPE float
#define CLASSNAME ROTGEN_MATRIX_NAME(map_impl,SIZE,_col)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
#include <rotgen/impl/map_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#define CLASSNAME ROTGEN_MATRIX_NAME(map_impl,SIZE,_row)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
#include <rotgen/impl/map_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#undef SIZE
#undef TYPE
#define BASENAME map_impl
#include <rotgen/impl/map_indirect.hpp>
#undef BASENAME
#undef CONST
template<typename Scalar,int Options, bool isConst> struct find_map_impl;
template<> struct find_map_impl<float , ColMajor, true> { using type = map_const_impl32_col; };

View file

@ -0,0 +1,35 @@
#define SIZE 64
#define TYPE double
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
#include <rotgen/impl/map_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
#include <rotgen/impl/map_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#undef SIZE
#undef TYPE
#define SIZE 32
#define TYPE float
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
#include <rotgen/impl/map_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
#include <rotgen/impl/map_model.hpp>
#undef CLASSNAME
#undef SOURCENAME
#undef SIZE
#undef TYPE