We want to do matrix multiplication for 3 cases: dense times dense sparse times dense for sparse matrices of class dgCMatrix sparse times dense for sparse matrices of class indMatrix, using R’s Matrix package for sparse matrices in R and RcppArmadillo for C++ linear algebra: // ] #include <RcppArmadillo.h> using namespace Rcpp ; arma::mat matmult_sp(const arma::sp_mat X, const arma::mat Y){ ...