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 "operator/dense.hpp"
8#include <stdexcept>
9
10namespace num {
11
12LanczosResult lanczos(const Matrix& A, idx k, real tol, idx max_steps, Backend backend) {
13 if (A.rows() != A.cols()) {
14 throw std::invalid_argument("lanczos: matrix must be square");
15 }
16 operators::DenseOp op(A, backend);
17 return lanczos(operators::assume_symmetric(op), k, tol, max_steps, backend);
18}
19
21 idx k,
22 real tol,
23 idx max_steps,
24 Backend backend) {
25 if (A.n_rows() != A.n_cols()) {
26 throw std::invalid_argument("lanczos: matrix must be square");
27 }
28 (void)backend;
30 return lanczos(operators::assume_symmetric(op), k, tol, max_steps, backend);
31}
32
33} // 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:17
idx n_cols() const
Definition sparse.hpp:36
idx n_rows() const
Definition sparse.hpp:35
Lanczos eigensolver for symmetric operators.
SymmetricOp< Op > assume_symmetric(Op op)
double real
Definition types.hpp:10
LanczosResult lanczos(const Op &A, idx k, real tol=1e-10, idx max_steps=0, Backend backend=Backend::seq)
Operator Lanczos for a declared symmetric adapter.
Definition lanczos.hpp:156
Backend
Definition policy.hpp:7
std::size_t idx
Definition types.hpp:11
Dense Matrix adapter for the operator protocol.
Declared mathematical properties for linear operators.
SparseMatrix adapter for the operator protocol.
Adapt a dense Matrix to the operator protocol.
Definition dense.hpp:12
Adapt a SparseMatrix to the operator protocol.
Definition sparse_op.hpp:15