simplifications

This commit is contained in:
conrad
2025-01-17 12:23:08 +10:00
parent 522cfdce58
commit b0fe0d3cff
+10 -15
View File
@@ -25,7 +25,7 @@
template<typename T1>
inline
void
op_reshape::apply(Mat<typename T1::elem_type>& actual_out, const Op<T1,op_reshape>& in)
op_reshape::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_reshape>& in)
{
arma_debug_sigprint();
@@ -34,41 +34,36 @@ op_reshape::apply(Mat<typename T1::elem_type>& actual_out, const Op<T1,op_reshap
const uword new_n_rows = in.aux_uword_a;
const uword new_n_cols = in.aux_uword_b;
if(is_Mat<T1>::value || (arma_config::openmp && Proxy<T1>::use_mp))
if((is_Mat<T1>::value) || (is_Mat<typename Proxy<T1>::stored_type>::value) || (arma_config::openmp && Proxy<T1>::use_mp))
{
const unwrap<T1> U(in.m);
const Mat<eT>& A = U.M;
if(&actual_out == &A)
if(&out == &A)
{
op_reshape::apply_mat_inplace(actual_out, new_n_rows, new_n_cols);
op_reshape::apply_mat_inplace(out, new_n_rows, new_n_cols);
}
else
{
op_reshape::apply_mat_noalias(actual_out, A, new_n_rows, new_n_cols);
op_reshape::apply_mat_noalias(out, A, new_n_rows, new_n_cols);
}
}
else
{
const Proxy<T1> P(in.m);
const bool is_alias = P.is_alias(actual_out);
Mat<eT> tmp;
Mat<eT>& out = (is_alias) ? tmp : actual_out;
if(is_Mat<typename Proxy<T1>::stored_type>::value)
if(P.is_alias(out))
{
const quasi_unwrap<typename Proxy<T1>::stored_type> U(P.Q);
Mat<eT> tmp;
op_reshape::apply_mat_noalias(out, U.M, new_n_rows, new_n_cols);
op_reshape::apply_proxy_noalias(tmp, P, new_n_rows, new_n_cols);
out.steal_mem(tmp);
}
else
{
op_reshape::apply_proxy_noalias(out, P, new_n_rows, new_n_cols);
}
if(is_alias) { actual_out.steal_mem(tmp); }
}
}