experiment with avoiding unnecessary alias checks
This commit is contained in:
@@ -958,4 +958,8 @@ class Mat_aux
|
||||
|
||||
|
||||
|
||||
template<typename eT> class Mat_noalias : public Mat<eT> {};
|
||||
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
@@ -5066,10 +5066,12 @@ Mat<eT>::Mat(const Op<T1, op_type>& X)
|
||||
, mem()
|
||||
{
|
||||
arma_debug_sigprint_this(this);
|
||||
|
||||
|
||||
arma_type_check(( is_same_type< eT, typename T1::elem_type >::no ));
|
||||
|
||||
op_type::apply(*this, X);
|
||||
// op_type::apply(*this, X);
|
||||
|
||||
op_type::apply(static_cast< Mat_noalias<eT>& >(*this), X);
|
||||
}
|
||||
|
||||
|
||||
@@ -5082,7 +5084,7 @@ Mat<eT>&
|
||||
Mat<eT>::operator=(const Op<T1, op_type>& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
|
||||
arma_type_check(( is_same_type< eT, typename T1::elem_type >::no ));
|
||||
|
||||
op_type::apply(*this, X);
|
||||
|
||||
@@ -31,6 +31,8 @@ template<typename eT> class Row;
|
||||
template<typename eT> class Cube;
|
||||
template<typename oT> class field;
|
||||
|
||||
template<typename eT> class Mat_noalias;
|
||||
|
||||
template<typename eT> struct xvec_htrans;
|
||||
template<typename eT, bool do_conj> struct xtrans_mat;
|
||||
|
||||
|
||||
@@ -77,6 +77,12 @@ struct op_htrans
|
||||
|
||||
template<typename T1>
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans>& in, const typename arma_cx_only<typename T1::elem_type>::result* junk = nullptr);
|
||||
|
||||
template<typename T1>
|
||||
inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1,op_htrans>& in, const typename arma_not_cx<typename T1::elem_type>::result* junk = nullptr);
|
||||
|
||||
template<typename T1>
|
||||
inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1,op_htrans>& in, const typename arma_cx_only<typename T1::elem_type>::result* junk = nullptr);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -377,6 +377,54 @@ op_htrans::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_htrans>& in, c
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
void
|
||||
op_htrans::apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1,op_htrans>& in, const typename arma_not_cx<typename T1::elem_type>::result* junk)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
if((is_Mat<typename Proxy<T1>::stored_type>::value) || (arma_config::openmp && Proxy<T1>::use_mp))
|
||||
{
|
||||
const quasi_unwrap<T1> U(in.m);
|
||||
|
||||
op_strans::apply_mat_noalias(out, U.M);
|
||||
}
|
||||
else
|
||||
{
|
||||
const Proxy<T1> P(in.m);
|
||||
|
||||
op_strans::apply_proxy(out, P);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
void
|
||||
op_htrans::apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1,op_htrans>& in, const typename arma_cx_only<typename T1::elem_type>::result* junk)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
if((is_Mat<typename Proxy<T1>::stored_type>::value) || (arma_config::openmp && Proxy<T1>::use_mp))
|
||||
{
|
||||
const quasi_unwrap<T1> U(in.m);
|
||||
|
||||
op_htrans::apply_mat_noalias(out, U.M);
|
||||
}
|
||||
else
|
||||
{
|
||||
const Proxy<T1> P(in.m);
|
||||
|
||||
op_htrans::apply_proxy(out, P);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// op_htrans2
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ struct op_mean
|
||||
template<typename T1>
|
||||
inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1,op_mean>& in);
|
||||
|
||||
template<typename T1>
|
||||
inline static void apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1,op_mean>& in);
|
||||
|
||||
template<typename eT>
|
||||
inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& X, const uword dim);
|
||||
|
||||
|
||||
@@ -52,6 +52,24 @@ op_mean::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_mean>& in)
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
void
|
||||
op_mean::apply(Mat_noalias<typename T1::elem_type>& out, const Op<T1,op_mean>& in)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
const uword dim = in.aux_uword_a;
|
||||
|
||||
arma_conform_check( (dim > 1), "mean(): parameter 'dim' must be 0 or 1" );
|
||||
|
||||
const quasi_unwrap<T1> U(in.m);
|
||||
|
||||
op_mean::apply_noalias(out, U.M, dim);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename eT>
|
||||
inline
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user