numerics 0.1.0
Loading...
Searching...
No Matches
sparse.hpp
Go to the documentation of this file.
1/// @file operator/sparse.hpp
2/// @brief SparseMatrix adapter for the operator protocol.
3#pragma once
4
7
8namespace num::operators {
9
10/// @brief Adapt a SparseMatrix to the operator protocol.
11struct SparseOp final {
12 explicit SparseOp(const SparseMatrix& A)
13 : A_(A) {}
14
15 void apply(const Vector& x, Vector& y) const;
16 [[nodiscard]] idx rows() const noexcept { return A_.n_rows(); }
17 [[nodiscard]] idx cols() const noexcept { return A_.n_cols(); }
18
19 private:
20 const SparseMatrix& A_;
21};
22
23static_assert(LinearOperator<SparseOp>);
24
25} // namespace num::operators
Sparse matrix in Compressed Sparse Row (CSR) format.
Definition sparse.hpp:15
idx n_cols() const
Definition sparse.hpp:34
idx n_rows() const
Definition sparse.hpp:33
Compressed Sparse Row (CSR) matrix and operations.
std::size_t idx
Definition types.hpp:11
Concepts for operator-oriented numerical algorithms.
Adapt a SparseMatrix to the operator protocol.
Definition sparse.hpp:11
idx rows() const noexcept
Definition sparse.hpp:16
idx cols() const noexcept
Definition sparse.hpp:17
void apply(const Vector &x, Vector &y) const
Definition operator.cpp:18
SparseOp(const SparseMatrix &A)
Definition sparse.hpp:12