numerics 0.1.0
Loading...
Searching...
No Matches
lanczos.cpp
Go to the documentation of this file.
1/// @file eigen/lanczos.cpp
2/// @brief Lanczos overload wrappers.
3
6#include <stdexcept>
7
8namespace num {
9
10LanczosResult lanczos(const Matrix& A, idx k, real tol, idx max_steps, Backend backend) {
11 if (A.rows() != A.cols()) {
12 throw std::invalid_argument("lanczos: matrix must be square");
13 }
14 operators::DenseOp op(A, backend);
15 return lanczos(op, k, tol, max_steps, backend);
16}
17
19 idx k,
20 real tol,
21 idx max_steps,
22 Backend backend) {
23 if (A.n_rows() != A.n_cols()) {
24 throw std::invalid_argument("lanczos: matrix must be square");
25 }
26 (void)backend;
28 return lanczos(op, k, tol, max_steps, backend);
29}
30
31} // namespace num
constexpr idx rows() const noexcept
Definition matrix.hpp:87
constexpr idx cols() const noexcept
Definition matrix.hpp:88
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
Lanczos eigensolver for symmetric operators.
double real
Definition types.hpp:10
Backend
Definition policy.hpp:7
std::size_t idx
Definition types.hpp:11
LanczosResult lanczos(const Op &A, idx k, real tol=1e-10, idx max_steps=0, Backend backend=Backend::seq)
Operator Lanczos for any symmetric adapter.
Definition lanczos.hpp:31
Umbrella include for operator concepts and adapters.
Adapt a dense Matrix to the operator protocol.
Definition dense.hpp:12
Adapt a SparseMatrix to the operator protocol.
Definition sparse.hpp:11