faster handling of row subvectors

This commit is contained in:
conrad
2025-10-20 12:21:33 +10:00
parent 09e213b8ee
commit 475b97464d
3 changed files with 35 additions and 10 deletions
+3
View File
@@ -169,6 +169,9 @@ class Row : public Mat<eT>
inline const_row_iterator end_row (const uword row_num) const;
inline explicit Row(const subview<eT>& X, const bool reuse_mem); // only to be used by the partial_unwrap class
template<uword fixed_n_elem> class fixed;
+18
View File
@@ -1264,6 +1264,20 @@ Row<eT>::end_row(const uword row_num) const
template<typename eT>
inline
Row<eT>::Row(const subview<eT>& X, const bool reuse_mem)
: Mat<eT>(X, reuse_mem)
{
arma_debug_sigprint_this(this);
}
//
template<typename eT>
template<uword fixed_n_elem>
arma_inline
@@ -1859,6 +1873,10 @@ Row<eT>::fixed<fixed_n_elem>::ones()
//
template<typename eT>
inline
Row<eT>::Row(const arma_fixed_indicator&, const uword in_n_elem, const eT* in_mem)
+14 -10
View File
@@ -382,19 +382,21 @@ struct quasi_unwrap< subview_row<eT> >
{
inline
quasi_unwrap(const subview_row<eT>& A)
: M(A)
: sv( A )
, M ( A, (A.m.n_rows == 1) )
{
arma_debug_sigprint();
}
Row<eT> M;
const subview_row<eT>& sv;
const Row<eT> M;
static constexpr bool is_const = false;
static constexpr bool has_subview = false;
static constexpr bool has_orig_mem = false;
static constexpr bool is_const = true;
static constexpr bool has_subview = true;
static constexpr bool has_orig_mem = false; // NOTE: set to false as this is the general case; original memory is only used when the subview is a contiguous chunk
template<typename eT2>
constexpr bool is_alias(const Mat<eT2>&) const { return false; }
arma_inline bool is_alias(const Mat<eT2>& X) const { return (is_same_type<eT,eT2>::yes) && ( (sv.m.n_rows == 1) ? (void_ptr(&X) == void_ptr(&(sv.m))) : false ); }
};
@@ -1430,7 +1432,8 @@ struct partial_unwrap< subview_row<eT> >
inline
partial_unwrap(const subview_row<eT>& A)
: M(A)
: sv( A )
, M ( A, (A.m.n_rows == 1) )
{
arma_debug_sigprint();
}
@@ -1438,13 +1441,14 @@ struct partial_unwrap< subview_row<eT> >
constexpr eT get_val() const { return eT(1); }
template<typename eT2>
constexpr bool is_alias(const Mat<eT2>&) const { return false; }
arma_inline bool is_alias(const Mat<eT2>& X) const { return (sv.m.n_rows == 1) ? (void_ptr(&X) == void_ptr(&(sv.m))) : false; }
static constexpr bool do_trans = false;
static constexpr bool do_times = false;
static constexpr bool is_fast = false;
static constexpr bool is_fast = false; // can't determine at compile time that memory is reused
const Row<eT> M;
const subview_row<eT>& sv;
const Row<eT> M;
};