speedup by transpose based multiplication

This commit is contained in:
conrad
2023-07-20 15:06:58 +10:00
parent 125858f7f2
commit 20db1e4eea
2 changed files with 16 additions and 3 deletions
@@ -27,6 +27,7 @@ class SparseGenMatProd
private:
const SpMat<eT>& op_mat;
SpMat<eT> op_mat_st;
public:
@@ -28,6 +28,8 @@ SparseGenMatProd<eT>::SparseGenMatProd(const SpMat<eT>& 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<eT>::perform_op(eT* x_in, eT* y_out) const
{
arma_extra_debug_sigprint();
const Col<eT> x(x_in , n_cols, false, true);
Col<eT> y(y_out, n_rows, false, true);
// // OLD METHOD
//
// const Col<eT> x(x_in , n_cols, false, true);
// Col<eT> y(y_out, n_rows, false, true);
//
// y = op_mat * x;
y = op_mat * x;
// NEW METHOD
const Row<eT> x(x_in , n_cols, false, true);
Row<eT> y(y_out, n_rows, false, true);
y = x * op_mat_st;
}