From dca21aa5f1996ac4fff862ece237deb0a162aa2a Mon Sep 17 00:00:00 2001 From: conrad Date: Fri, 14 Feb 2025 14:32:11 +1000 Subject: [PATCH] optimisation for spglue_schur --- include/armadillo_bits/fn_accu.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/armadillo_bits/fn_accu.hpp b/include/armadillo_bits/fn_accu.hpp index 8990bd44..c3cb9bd9 100644 --- a/include/armadillo_bits/fn_accu.hpp +++ b/include/armadillo_bits/fn_accu.hpp @@ -1119,6 +1119,22 @@ accu(const SpGlue& expr) const SpProxy px(expr.A); const SpProxy py(expr.B); + arma_conform_assert_same_size(px.get_n_rows(), px.get_n_cols(), py.get_n_rows(), py.get_n_cols(), "element-wise multiplication"); + + typedef typename SpProxy::stored_type px_Q_type; + typedef typename SpProxy::stored_type py_Q_type; + + if(is_SpMat::value && is_SpMat::value) + { + const unwrap_spmat UX(px.Q); + const unwrap_spmat UY(py.Q); + + const SpMat& X = UX.M; + const SpMat& Y = UY.M; + + if(&X == &Y) { return op_dot::direct_dot(X.n_nonzero, X.values, X.values); } + } + typename SpProxy::const_iterator_type x_it = px.begin(); typename SpProxy::const_iterator_type x_it_end = px.end();