From 20db1e4eeabaa65bb75fedf41bd730c300b48160 Mon Sep 17 00:00:00 2001 From: conrad Date: Thu, 20 Jul 2023 15:06:58 +1000 Subject: [PATCH] speedup by transpose based multiplication --- .../newarp_SparseGenMatProd_bones.hpp | 1 + .../newarp_SparseGenMatProd_meat.hpp | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/armadillo_bits/newarp_SparseGenMatProd_bones.hpp b/include/armadillo_bits/newarp_SparseGenMatProd_bones.hpp index fb3cefa8..2028aee2 100644 --- a/include/armadillo_bits/newarp_SparseGenMatProd_bones.hpp +++ b/include/armadillo_bits/newarp_SparseGenMatProd_bones.hpp @@ -27,6 +27,7 @@ class SparseGenMatProd private: const SpMat& op_mat; + SpMat op_mat_st; public: diff --git a/include/armadillo_bits/newarp_SparseGenMatProd_meat.hpp b/include/armadillo_bits/newarp_SparseGenMatProd_meat.hpp index 0f10f125..bbe539a1 100644 --- a/include/armadillo_bits/newarp_SparseGenMatProd_meat.hpp +++ b/include/armadillo_bits/newarp_SparseGenMatProd_meat.hpp @@ -28,6 +28,8 @@ SparseGenMatProd::SparseGenMatProd(const SpMat& mat_obj) , n_cols(mat_obj.n_cols) { arma_extra_debug_sigprint(); + + op_mat_st = op_mat.st(); // pre-calculate transpose } @@ -41,10 +43,20 @@ SparseGenMatProd::perform_op(eT* x_in, eT* y_out) const { arma_extra_debug_sigprint(); - const Col x(x_in , n_cols, false, true); - Col y(y_out, n_rows, false, true); + // // OLD METHOD + // + // const Col x(x_in , n_cols, false, true); + // Col y(y_out, n_rows, false, true); + // + // y = op_mat * x; - y = op_mat * x; + + // NEW METHOD + + const Row x(x_in , n_cols, false, true); + Row y(y_out, n_rows, false, true); + + y = x * op_mat_st; }