From b0fe0d3cff0271730ca749b7ddeda7acec7deb9f Mon Sep 17 00:00:00 2001 From: conrad Date: Fri, 17 Jan 2025 12:23:08 +1000 Subject: [PATCH] simplifications --- include/armadillo_bits/op_reshape_meat.hpp | 25 +++++++++------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/include/armadillo_bits/op_reshape_meat.hpp b/include/armadillo_bits/op_reshape_meat.hpp index 454f733a..b2a0badc 100644 --- a/include/armadillo_bits/op_reshape_meat.hpp +++ b/include/armadillo_bits/op_reshape_meat.hpp @@ -25,7 +25,7 @@ template inline void -op_reshape::apply(Mat& actual_out, const Op& in) +op_reshape::apply(Mat& out, const Op& in) { arma_debug_sigprint(); @@ -34,41 +34,36 @@ op_reshape::apply(Mat& actual_out, const Op::value || (arma_config::openmp && Proxy::use_mp)) + if((is_Mat::value) || (is_Mat::stored_type>::value) || (arma_config::openmp && Proxy::use_mp)) { const unwrap U(in.m); const Mat& 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 P(in.m); - const bool is_alias = P.is_alias(actual_out); - - Mat tmp; - Mat& out = (is_alias) ? tmp : actual_out; - - if(is_Mat::stored_type>::value) + if(P.is_alias(out)) { - const quasi_unwrap::stored_type> U(P.Q); + Mat 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); } } }