Skip to content

num::sparse_matvec

Defined in header <linear/sparse/sparse.hpp>

void sparse_matvec(const spmat &A, const vec<real> &x, vec<real> &y);

Sparse matrix-vector product \(\mathbf{y} \leftarrow A \mathbf{x}\) in \(\mathcal{O}(\text{nnz})\) time.

Parameters

  • A: Compressed Sparse Row (CSR) matrix.
  • x: Input vector of dimension \(A.\text{cols()}\).
  • y: Output vector of dimension \(A.\text{rows()}\).

Exceptions

  • std::invalid_argument: If dimensions do not match.