commit
aba4d65feb
4 changed files with 207 additions and 130 deletions
|
|
@ -139,6 +139,32 @@ namespace rotgen
|
|||
{
|
||||
}
|
||||
|
||||
block(Ref&& r, Index i0, Index j0, Index ni, Index nj)
|
||||
requires(!requires { typename Ref::rotgen_block_tag; } && !is_immutable)
|
||||
: parent(r.base(), i0, j0, ni, nj)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref&& r, Index i0, Index j0, Index ni, Index nj)
|
||||
requires(requires { typename Ref::rotgen_block_tag; } && !is_immutable)
|
||||
: parent(r.base(), i0, j0, ni, nj)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref&& r, Index i0, Index j0)
|
||||
requires(!requires { typename Ref::rotgen_block_tag; } && Rows != -1 &&
|
||||
Cols != -1 && !is_immutable)
|
||||
: parent(r.base(), i0, j0, Rows, Cols)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref&& r, Index i0, Index j0)
|
||||
requires(requires { typename Ref::rotgen_block_tag; } && Rows != -1 &&
|
||||
Cols != -1 && !is_immutable)
|
||||
: parent(r.base(), i0, j0, Rows, Cols)
|
||||
{
|
||||
}
|
||||
|
||||
block(parent const& base) : parent(base) {}
|
||||
|
||||
bool is_contiguous_linear() const
|
||||
|
|
|
|||
|
|
@ -133,11 +133,28 @@ namespace rotgen
|
|||
{
|
||||
}
|
||||
|
||||
block(Ref&& r, Index i0, Index j0, Index ni, Index nj)
|
||||
requires(!is_immutable)
|
||||
: parent(r.base(), i0, j0, ni, nj)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref&& r, Index i0, Index j0)
|
||||
requires(Rows != -1 && Cols != -1 && !is_immutable)
|
||||
: parent(r.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())
|
||||
{
|
||||
}
|
||||
|
||||
template<typename B, Index R, Index C, bool I, int FS>
|
||||
block(block<B, R, C, I, FS>&& other) : parent(other.base())
|
||||
{
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
block(Eigen::MatrixBase<OtherDerived> const& other) : parent(other)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include <type_traits>
|
||||
|
||||
#define ROTGEN_FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__)
|
||||
|
||||
namespace rotgen::detail
|
||||
{
|
||||
template<typename T> constexpr int static_size()
|
||||
|
|
@ -50,14 +52,7 @@ namespace rotgen::detail
|
|||
inline constexpr bool has_same_vector_size = []() {
|
||||
// No vector = noo size
|
||||
if (!(M::IsVectorAtCompileTime && N::IsVectorAtCompileTime)) return false;
|
||||
// Row vectors -> same Cols
|
||||
if (M::RowsAtCompileTime == 1 && N::RowsAtCompileTime == 1)
|
||||
return M::ColsAtCompileTime == N::ColsAtCompileTime;
|
||||
// Col vectors -> same Rows
|
||||
if (M::ColsAtCompileTime == 1 && N::ColsAtCompileTime == 1)
|
||||
return M::RowsAtCompileTime == N::RowsAtCompileTime;
|
||||
// Mixing 1xN with Mx1
|
||||
return false;
|
||||
else return static_size<M>() == static_size<N>();
|
||||
}();
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -65,7 +60,7 @@ namespace rotgen::detail
|
|||
std::conditional_t<std::remove_cvref_t<T>::is_immutable ||
|
||||
std::is_const_v<T>,
|
||||
std::add_const_t<std::remove_cvref_t<T>>,
|
||||
std::remove_cvref_t<T>>;
|
||||
std::remove_reference_t<T>>;
|
||||
|
||||
template<auto M, auto N>
|
||||
inline constexpr auto select_static = (M == -1 || N == -1) ? -1 : M;
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@
|
|||
#pragma once
|
||||
#include <rotgen/detail/helpers.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace rotgen
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template<concepts::entity Entity>
|
||||
void validate_extract([[maybe_unused]] Entity& e,
|
||||
void validate_extract([[maybe_unused]] Entity const& e,
|
||||
[[maybe_unused]] Index i0,
|
||||
[[maybe_unused]] Index j0,
|
||||
[[maybe_unused]] Index ni,
|
||||
|
|
@ -28,260 +30,297 @@ namespace rotgen
|
|||
|
||||
//======================== EXTRACT ========================
|
||||
template<concepts::entity Entity>
|
||||
auto extract(Entity& e, Index i0, Index j0, Index ni, Index nj)
|
||||
auto extract(Entity&& e, Index i0, Index j0, Index ni, Index nj)
|
||||
{
|
||||
detail::validate_extract(e, i0, j0, ni, nj);
|
||||
if constexpr (requires { e.as_map(); })
|
||||
return extract(e.as_map(), i0, j0, ni, nj);
|
||||
else return block<detail::propagate_const<Entity>>(e, i0, j0, ni, nj);
|
||||
if constexpr (requires { ROTGEN_FWD(e).as_map(); })
|
||||
return extract(ROTGEN_FWD(e).as_map(), i0, j0, ni, nj);
|
||||
else
|
||||
return block<detail::propagate_const<Entity>>(ROTGEN_FWD(e), i0, j0, ni,
|
||||
nj);
|
||||
}
|
||||
|
||||
template<Index NI, Index NJ, concepts::entity Entity>
|
||||
requires(NI != -1 && NJ != -1)
|
||||
auto extract(Entity& e, Index i0, Index j0)
|
||||
auto extract(Entity&& e, Index i0, Index j0)
|
||||
{
|
||||
detail::validate_extract(e, i0, j0, NI, NJ);
|
||||
if constexpr (requires { e.as_map(); })
|
||||
return extract<NI, NJ>(e.as_map(), i0, j0);
|
||||
else return block<detail::propagate_const<Entity>, NI, NJ>(e, i0, j0);
|
||||
if constexpr (requires { ROTGEN_FWD(e).as_map(); })
|
||||
return extract<NI, NJ>(ROTGEN_FWD(e).as_map(), i0, j0);
|
||||
else
|
||||
return block<detail::propagate_const<Entity>, NI, NJ>(ROTGEN_FWD(e), i0,
|
||||
j0);
|
||||
}
|
||||
|
||||
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)
|
||||
auto extract(Entity&& e, Index i0, Index j0, Index ni, Index nj)
|
||||
{
|
||||
detail::validate_extract(e, i0, j0, ni, nj);
|
||||
if constexpr (requires { e.as_map(); })
|
||||
return extract<NI, NJ>(e.as_map(), i0, j0, ni, nj);
|
||||
if constexpr (requires { ROTGEN_FWD(e).as_map(); })
|
||||
return extract<NI, NJ>(ROTGEN_FWD(e).as_map(), i0, j0, ni, nj);
|
||||
else
|
||||
return block<detail::propagate_const<Entity>, NI, NJ>(e, i0, j0, ni, nj);
|
||||
return block<detail::propagate_const<Entity>, NI, NJ>(ROTGEN_FWD(e), i0,
|
||||
j0, ni, nj);
|
||||
}
|
||||
|
||||
//======================== TOP LEFT CORNER ========================
|
||||
template<concepts::entity Entity>
|
||||
auto topLeftCorner(Entity& e, Index ni, Index nj)
|
||||
auto topLeftCorner(Entity&& e, Index ni, Index nj)
|
||||
{
|
||||
return extract(e, 0, 0, ni, nj);
|
||||
return extract(ROTGEN_FWD(e), 0, 0, ni, nj);
|
||||
}
|
||||
|
||||
template<Index NI, Index NJ, concepts::entity Entity>
|
||||
auto topLeftCorner(Entity& e)
|
||||
auto topLeftCorner(Entity&& e)
|
||||
{
|
||||
return extract<NI, NJ>(e, 0, 0);
|
||||
return extract<NI, NJ>(ROTGEN_FWD(e), 0, 0);
|
||||
}
|
||||
|
||||
//======================== TOP RIGHT CORNER ========================
|
||||
template<concepts::entity Entity>
|
||||
auto topRightCorner(Entity& e, Index ni, Index nj)
|
||||
auto topRightCorner(Entity&& e, Index ni, Index nj)
|
||||
{
|
||||
return extract(e, 0, e.cols() - nj, ni, nj);
|
||||
return extract(ROTGEN_FWD(e), 0, e.cols() - nj, ni, nj);
|
||||
}
|
||||
|
||||
template<Index NI, Index NJ, concepts::entity Entity>
|
||||
auto topRightCorner(Entity& e)
|
||||
auto topRightCorner(Entity&& e)
|
||||
{
|
||||
return extract<NI, NJ>(e, 0, e.cols() - NJ);
|
||||
return extract<NI, NJ>(ROTGEN_FWD(e), 0, e.cols() - NJ);
|
||||
}
|
||||
|
||||
//======================== BOTTOM LEFT CORNER ========================
|
||||
template<concepts::entity Entity>
|
||||
auto bottomLeftCorner(Entity& e, Index ni, Index nj)
|
||||
auto bottomLeftCorner(Entity&& e, Index ni, Index nj)
|
||||
{
|
||||
return extract(e, e.rows() - ni, 0, ni, nj);
|
||||
return extract(ROTGEN_FWD(e), e.rows() - ni, 0, ni, nj);
|
||||
}
|
||||
|
||||
template<Index NI, Index NJ, concepts::entity Entity>
|
||||
auto bottomLeftCorner(Entity& e)
|
||||
auto bottomLeftCorner(Entity&& e)
|
||||
{
|
||||
return extract<NI, NJ>(e, e.rows() - NI, 0);
|
||||
return extract<NI, NJ>(ROTGEN_FWD(e), e.rows() - NI, 0);
|
||||
}
|
||||
|
||||
//======================== BOTTOM RIGHT CORNER ========================
|
||||
template<concepts::entity Entity>
|
||||
auto bottomRightCorner(Entity& e, Index ni, Index nj)
|
||||
auto bottomRightCorner(Entity&& e, Index ni, Index nj)
|
||||
{
|
||||
return extract(e, e.rows() - ni, e.cols() - nj, ni, nj);
|
||||
return extract(ROTGEN_FWD(e), e.rows() - ni, e.cols() - nj, ni, nj);
|
||||
}
|
||||
|
||||
template<Index NI, Index NJ, concepts::entity Entity>
|
||||
auto bottomRightCorner(Entity& e)
|
||||
auto bottomRightCorner(Entity&& e)
|
||||
{
|
||||
return extract<NI, NJ>(e, e.rows() - NI, e.cols() - NJ);
|
||||
return extract<NI, NJ>(ROTGEN_FWD(e), e.rows() - NI, e.cols() - NJ);
|
||||
}
|
||||
|
||||
//======================== TOP ROWS ========================
|
||||
template<concepts::entity Entity> auto topRows(Entity& e, Index ni)
|
||||
template<concepts::entity Entity> auto topRows(Entity&& e, Index ni)
|
||||
{
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract(e, 0, 0, ni, e.cols());
|
||||
else return extract<-1, Entity::ColsAtCompileTime>(e, 0, 0, ni, e.cols());
|
||||
if constexpr (std::remove_cvref_t<Entity>::ColsAtCompileTime == -1)
|
||||
return extract(ROTGEN_FWD(e), 0, 0, ni, e.cols());
|
||||
else
|
||||
return extract<-1, std::remove_cvref_t<Entity>::ColsAtCompileTime>(
|
||||
ROTGEN_FWD(e), 0, 0, ni, e.cols());
|
||||
}
|
||||
|
||||
template<Index NI, concepts::entity Entity> auto topRows(Entity& e)
|
||||
template<Index NI, concepts::entity Entity> auto topRows(Entity&& e)
|
||||
{
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract<NI, -1>(e, 0, 0, NI, e.cols());
|
||||
else return extract<NI, Entity::ColsAtCompileTime>(e, 0, 0);
|
||||
if constexpr (std::remove_cvref_t<Entity>::ColsAtCompileTime == -1)
|
||||
return extract<NI, -1>(ROTGEN_FWD(e), 0, 0, NI, e.cols());
|
||||
else
|
||||
return extract<NI, std::remove_cvref_t<Entity>::ColsAtCompileTime>(
|
||||
ROTGEN_FWD(e), 0, 0);
|
||||
}
|
||||
|
||||
//======================== MIDDLE ROWS ========================
|
||||
template<concepts::entity Entity>
|
||||
auto middleRows(Entity& e, Index i0, Index ni)
|
||||
auto middleRows(Entity&& e, Index i0, Index ni)
|
||||
{
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract(e, i0, 0, ni, e.cols());
|
||||
else return extract<-1, Entity::ColsAtCompileTime>(e, i0, 0, ni, e.cols());
|
||||
if constexpr (std::remove_cvref_t<Entity>::ColsAtCompileTime == -1)
|
||||
return extract(ROTGEN_FWD(e), i0, 0, ni, e.cols());
|
||||
else
|
||||
return extract<-1, std::remove_cvref_t<Entity>::ColsAtCompileTime>(
|
||||
ROTGEN_FWD(e), i0, 0, ni, e.cols());
|
||||
}
|
||||
|
||||
template<Index NI, concepts::entity Entity>
|
||||
auto middleRows(Entity& e, Index i0)
|
||||
auto middleRows(Entity&& e, Index i0)
|
||||
{
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract<NI, -1>(e, i0, 0, NI, e.cols());
|
||||
else return extract<NI, Entity::ColsAtCompileTime>(e, i0, 0);
|
||||
if constexpr (std::remove_cvref_t<Entity>::ColsAtCompileTime == -1)
|
||||
return extract<NI, -1>(ROTGEN_FWD(e), i0, 0, NI, e.cols());
|
||||
else
|
||||
return extract<NI, std::remove_cvref_t<Entity>::ColsAtCompileTime>(
|
||||
ROTGEN_FWD(e), i0, 0);
|
||||
}
|
||||
|
||||
//======================== BOTTOM ROWS ========================
|
||||
template<concepts::entity Entity> auto bottomRows(Entity& e, Index ni)
|
||||
template<concepts::entity Entity> auto bottomRows(Entity&& e, Index ni)
|
||||
{
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract(e, e.rows() - ni, 0, ni, e.cols());
|
||||
if constexpr (std::remove_cvref_t<Entity>::ColsAtCompileTime == -1)
|
||||
return extract(ROTGEN_FWD(e), e.rows() - ni, 0, ni, e.cols());
|
||||
else
|
||||
return extract<-1, Entity::ColsAtCompileTime>(e, e.rows() - ni, 0, ni,
|
||||
e.cols());
|
||||
return extract<-1, std::remove_cvref_t<Entity>::ColsAtCompileTime>(
|
||||
ROTGEN_FWD(e), e.rows() - ni, 0, ni, e.cols());
|
||||
}
|
||||
|
||||
template<Index NI, concepts::entity Entity> auto bottomRows(Entity& e)
|
||||
template<Index NI, concepts::entity Entity> auto bottomRows(Entity&& e)
|
||||
{
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract<NI, -1>(e, e.rows() - NI, 0, NI, e.cols());
|
||||
else return extract<NI, Entity::ColsAtCompileTime>(e, e.rows() - NI, 0);
|
||||
if constexpr (std::remove_cvref_t<Entity>::ColsAtCompileTime == -1)
|
||||
return extract<NI, -1>(ROTGEN_FWD(e), e.rows() - NI, 0, NI, e.cols());
|
||||
else
|
||||
return extract<NI, std::remove_cvref_t<Entity>::ColsAtCompileTime>(
|
||||
ROTGEN_FWD(e), e.rows() - NI, 0);
|
||||
}
|
||||
|
||||
//======================== LEFT COLS ========================
|
||||
template<concepts::entity Entity> auto leftCols(Entity& e, Index nj)
|
||||
template<concepts::entity Entity> auto leftCols(Entity&& e, Index nj)
|
||||
{
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract(e, 0, 0, e.rows(), nj);
|
||||
else return extract<Entity::RowsAtCompileTime, -1>(e, 0, 0, e.rows(), nj);
|
||||
if constexpr (std::remove_cvref_t<Entity>::RowsAtCompileTime == -1)
|
||||
return extract(ROTGEN_FWD(e), 0, 0, e.rows(), nj);
|
||||
else
|
||||
return extract<std::remove_cvref_t<Entity>::RowsAtCompileTime, -1>(
|
||||
ROTGEN_FWD(e), 0, 0, e.rows(), nj);
|
||||
}
|
||||
|
||||
template<Index NJ, concepts::entity Entity> auto leftCols(Entity& e)
|
||||
template<Index NJ, concepts::entity Entity> auto leftCols(Entity&& e)
|
||||
{
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract<-1, NJ>(e, 0, 0, e.rows(), NJ);
|
||||
else return extract<Entity::RowsAtCompileTime, NJ>(e, 0, 0);
|
||||
if constexpr (std::remove_cvref_t<Entity>::RowsAtCompileTime == -1)
|
||||
return extract<-1, NJ>(ROTGEN_FWD(e), 0, 0, e.rows(), NJ);
|
||||
else
|
||||
return extract<std::remove_cvref_t<Entity>::RowsAtCompileTime, NJ>(
|
||||
ROTGEN_FWD(e), 0, 0);
|
||||
}
|
||||
|
||||
//======================== MIDDLE COLS ========================
|
||||
template<concepts::entity Entity>
|
||||
auto middleCols(Entity& e, Index j0, Index nj)
|
||||
auto middleCols(Entity&& e, Index j0, Index nj)
|
||||
{
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract(e, 0, j0, e.rows(), nj);
|
||||
else return extract<Entity::RowsAtCompileTime, -1>(e, 0, j0, e.rows(), nj);
|
||||
if constexpr (std::remove_cvref_t<Entity>::RowsAtCompileTime == -1)
|
||||
return extract(ROTGEN_FWD(e), 0, j0, e.rows(), nj);
|
||||
else
|
||||
return extract<std::remove_cvref_t<Entity>::RowsAtCompileTime, -1>(
|
||||
ROTGEN_FWD(e), 0, j0, e.rows(), nj);
|
||||
}
|
||||
|
||||
template<Index NJ, concepts::entity Entity>
|
||||
auto middleCols(Entity& e, Index j0)
|
||||
auto middleCols(Entity&& e, Index j0)
|
||||
{
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract<-1, NJ>(e, 0, j0, e.rows(), NJ);
|
||||
else return extract<Entity::RowsAtCompileTime, NJ>(e, 0, j0);
|
||||
if constexpr (std::remove_cvref_t<Entity>::RowsAtCompileTime == -1)
|
||||
return extract<-1, NJ>(ROTGEN_FWD(e), 0, j0, e.rows(), NJ);
|
||||
else
|
||||
return extract<std::remove_cvref_t<Entity>::RowsAtCompileTime, NJ>(
|
||||
ROTGEN_FWD(e), 0, j0);
|
||||
}
|
||||
|
||||
//======================== RIGHT COLS ========================
|
||||
template<concepts::entity Entity> auto rightCols(Entity& e, Index nj)
|
||||
template<concepts::entity Entity> auto rightCols(Entity&& e, Index nj)
|
||||
{
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract(e, 0, e.cols() - nj, e.rows(), nj);
|
||||
if constexpr (std::remove_cvref_t<Entity>::RowsAtCompileTime == -1)
|
||||
return extract(ROTGEN_FWD(e), 0, e.cols() - nj, e.rows(), nj);
|
||||
else
|
||||
return extract<Entity::RowsAtCompileTime, -1>(e, 0, e.cols() - nj,
|
||||
e.rows(), nj);
|
||||
return extract<std::remove_cvref_t<Entity>::RowsAtCompileTime, -1>(
|
||||
ROTGEN_FWD(e), 0, e.cols() - nj, e.rows(), nj);
|
||||
;
|
||||
}
|
||||
|
||||
template<Index NJ, concepts::entity Entity> auto rightCols(Entity& e)
|
||||
template<Index NJ, concepts::entity Entity> auto rightCols(Entity&& e)
|
||||
{
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract<-1, NJ>(e, 0, e.cols() - NJ, e.rows(), NJ);
|
||||
else return extract<Entity::RowsAtCompileTime, NJ>(e, 0, e.cols() - NJ);
|
||||
if constexpr (std::remove_cvref_t<Entity>::RowsAtCompileTime == -1)
|
||||
return extract<-1, NJ>(ROTGEN_FWD(e), 0, e.cols() - NJ, e.rows(), NJ);
|
||||
else
|
||||
return extract<std::remove_cvref_t<Entity>::RowsAtCompileTime, NJ>(
|
||||
ROTGEN_FWD(e), 0, e.cols() - NJ);
|
||||
}
|
||||
|
||||
//======================== ROW ========================
|
||||
template<concepts::entity Entity> auto row(Entity& e, Index i0)
|
||||
template<concepts::entity Entity> auto row(Entity&& e, Index i0)
|
||||
{
|
||||
if constexpr (Entity::ColsAtCompileTime == -1)
|
||||
return extract<1, -1>(e, i0, 0, 1, e.cols());
|
||||
else return extract<1, Entity::ColsAtCompileTime>(e, i0, 0);
|
||||
if constexpr (std::remove_cvref_t<Entity>::ColsAtCompileTime == -1)
|
||||
return extract<1, -1>(ROTGEN_FWD(e), i0, 0, 1, e.cols());
|
||||
else
|
||||
return extract<1, std::remove_cvref_t<Entity>::ColsAtCompileTime>(
|
||||
ROTGEN_FWD(e), i0, 0);
|
||||
}
|
||||
|
||||
//======================== COL ========================
|
||||
template<concepts::entity Entity> auto col(Entity& e, Index j0)
|
||||
template<concepts::entity Entity> auto col(Entity&& e, Index j0)
|
||||
{
|
||||
if constexpr (Entity::RowsAtCompileTime == -1)
|
||||
return extract<-1, 1>(e, 0, j0, e.rows(), 1);
|
||||
else return extract<Entity::RowsAtCompileTime, 1>(e, 0, j0);
|
||||
if constexpr (std::remove_cvref_t<Entity>::RowsAtCompileTime == -1)
|
||||
return extract<-1, 1>(ROTGEN_FWD(e), 0, j0, e.rows(), 1);
|
||||
else
|
||||
return extract<std::remove_cvref_t<Entity>::RowsAtCompileTime, 1>(
|
||||
ROTGEN_FWD(e), 0, j0);
|
||||
}
|
||||
|
||||
//======================== VECTOR HEAD ========================
|
||||
template<concepts::entity Entity>
|
||||
auto head(Entity& e, Index n)
|
||||
requires(Entity::RowsAtCompileTime == 1 || Entity::ColsAtCompileTime == 1)
|
||||
auto head(Entity&& e, Index n)
|
||||
requires(std::remove_cvref_t<Entity>::RowsAtCompileTime == 1 ||
|
||||
std::remove_cvref_t<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);
|
||||
if constexpr (std::remove_cvref_t<Entity>::RowsAtCompileTime == 1)
|
||||
return extract<1, Dynamic>(ROTGEN_FWD(e), 0, 0, 1, n);
|
||||
else if constexpr (std::remove_cvref_t<Entity>::ColsAtCompileTime == 1)
|
||||
return extract<Dynamic, 1>(ROTGEN_FWD(e), 0, 0, n, 1);
|
||||
}
|
||||
|
||||
template<Index N, concepts::entity Entity>
|
||||
auto head(Entity& e)
|
||||
requires(Entity::RowsAtCompileTime == 1 || Entity::ColsAtCompileTime == 1)
|
||||
auto head(Entity&& e)
|
||||
requires(std::remove_cvref_t<Entity>::RowsAtCompileTime == 1 ||
|
||||
std::remove_cvref_t<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);
|
||||
if constexpr (std::remove_cvref_t<Entity>::RowsAtCompileTime == 1)
|
||||
return extract<1, N>(ROTGEN_FWD(e), 0, 0);
|
||||
else if constexpr (std::remove_cvref_t<Entity>::ColsAtCompileTime == 1)
|
||||
return extract<N, 1>(ROTGEN_FWD(e), 0, 0);
|
||||
}
|
||||
|
||||
//======================== VECTOR TAIL ========================
|
||||
template<concepts::entity Entity>
|
||||
auto tail(Entity& e, Index n)
|
||||
requires(Entity::RowsAtCompileTime == 1 || Entity::ColsAtCompileTime == 1)
|
||||
auto tail(Entity&& e, Index n)
|
||||
requires(std::remove_cvref_t<Entity>::RowsAtCompileTime == 1 ||
|
||||
std::remove_cvref_t<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);
|
||||
if constexpr (std::remove_cvref_t<Entity>::RowsAtCompileTime == 1)
|
||||
return extract<1, Dynamic>(ROTGEN_FWD(e), 0, e.cols() - n, 1, n);
|
||||
else if constexpr (std::remove_cvref_t<Entity>::ColsAtCompileTime == 1)
|
||||
return extract<Dynamic, 1>(ROTGEN_FWD(e), e.rows() - n, 0, n, 1);
|
||||
}
|
||||
|
||||
template<Index N, concepts::entity Entity>
|
||||
auto tail(Entity& e)
|
||||
requires(Entity::RowsAtCompileTime == 1 || Entity::ColsAtCompileTime == 1)
|
||||
auto tail(Entity&& e)
|
||||
requires(std::remove_cvref_t<Entity>::RowsAtCompileTime == 1 ||
|
||||
std::remove_cvref_t<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);
|
||||
if constexpr (std::remove_cvref_t<Entity>::RowsAtCompileTime == 1)
|
||||
return extract<1, N>(ROTGEN_FWD(e), 0, e.cols() - N);
|
||||
else if constexpr (std::remove_cvref_t<Entity>::ColsAtCompileTime == 1)
|
||||
return extract<N, 1>(ROTGEN_FWD(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)
|
||||
auto segment(Entity&& e, Index s, Index n)
|
||||
requires(std::remove_cvref_t<Entity>::RowsAtCompileTime == 1 ||
|
||||
std::remove_cvref_t<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);
|
||||
if constexpr (std::remove_cvref_t<Entity>::RowsAtCompileTime == 1)
|
||||
return extract<1, Dynamic>(ROTGEN_FWD(e), 0, s, 1, n);
|
||||
else if constexpr (std::remove_cvref_t<Entity>::ColsAtCompileTime == 1)
|
||||
return extract<Dynamic, 1>(ROTGEN_FWD(e), s, 0, n, 1);
|
||||
}
|
||||
|
||||
template<Index N, concepts::entity Entity>
|
||||
auto segment(Entity& e, Index s)
|
||||
requires(Entity::RowsAtCompileTime == 1 || Entity::ColsAtCompileTime == 1)
|
||||
auto segment(Entity&& e, Index s)
|
||||
requires(std::remove_cvref_t<Entity>::RowsAtCompileTime == 1 ||
|
||||
std::remove_cvref_t<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);
|
||||
if constexpr (std::remove_cvref_t<Entity>::RowsAtCompileTime == 1)
|
||||
return extract<1, N>(ROTGEN_FWD(e), 0, s);
|
||||
else if constexpr (std::remove_cvref_t<Entity>::ColsAtCompileTime == 1)
|
||||
return extract<N, 1>(ROTGEN_FWD(e), s, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue