numerics 0.1.0
Loading...
Searching...
No Matches
sparse_op.cpp
Go to the documentation of this file.
2
3#include <stdexcept>
4
5namespace num::operators {
6
7void SparseOp::apply(const Vector& x, Vector& y) const {
8 if (x.size() != A_.n_cols()) {
9 throw std::invalid_argument("SparseOp::apply: input dimension mismatch");
10 }
11 if (y.size() != A_.n_rows()) {
12 y = Vector(A_.n_rows());
13 }
14 sparse_matvec(A_, x, y);
15}
16
17} // namespace num::operators
constexpr idx size() const noexcept
Definition vector.hpp:83
idx n_cols() const
Definition sparse.hpp:36
idx n_rows() const
Definition sparse.hpp:35
void sparse_matvec(const SparseMatrix &A, const Vector &x, Vector &y)
y = A * x
Definition sparse.cpp:122
BasicVector< real > Vector
Real-valued dense vector with full backend dispatch (CPU + GPU)
Definition vector.hpp:129
SparseMatrix adapter for the operator protocol.
void apply(const Vector &x, Vector &y) const
Definition sparse_op.cpp:7