I'm trying to do matrix multiplication with a very large, but sparse matrix. I'm first mean centering the sparse matrix by subtracting the average row from each row. Then, I multiply this result to a vector. Is there some manipulation I can do to this expression to make it more efficient to calculate? I'm dealing with a very high dimensional matrix.
I'm reading into CSR representations of a sparse matrix, but I'm not sure how to compute the dot product efficiently in this representation.
Subtracting the mean would lose the sparsity. let's switch the order of operation around to take advantage of the sparseness.
Let $ A \in \mathbb{R}^{m \times n}$, you are computing $\left[A-e\left(\frac1{m}e^TA\right)\right]x$ where $e$ is the all one vector, $A$ is sparse and $x$ is an vector.
\begin{align} \left[A-e\left(\frac1{m}e^TA\right)\right]x &= (I- \frac1m ee^T) (Ax)\\ &= (Ax) - e\left(\frac1me^T(Ax)\right) \end{align}