numerics 0.1.0
Loading...
Searching...
No Matches
linear_solver.hpp
Go to the documentation of this file.
1/// @file linalg/solvers/linear_solver.hpp
2/// @brief Universal linear solver callable type.
3///
4/// LinearSolver is a first-class callable: given a right-hand side vector,
5/// it solves A*x = rhs in-place. Any algorithm (CG, LU, Cholesky, ...) that
6/// satisfies this contract can be stored as a LinearSolver and passed to ODE
7/// integrators, PDE time-steppers, or nonlinear solvers without change.
8///
9/// Factory functions in linalg/solvers/ return LinearSolver:
10/// num::make_cg_solver(A)
11/// num::make_lu_solver(A) (planned)
12/// num::make_chol_solver(A) (planned)
13#pragma once
14
15#include "core/vector.hpp"
17#include <functional>
18
19namespace num {
20
21/// Callable that solves A*x = rhs in-place. rhs is passed by value so
22/// the solver can use it as a work vector without copying.
23using LinearSolver = std::function<SolverResult(const Vector &rhs, Vector &x)>;
24
25} // namespace num
std::function< SolverResult(const Vector &rhs, Vector &x)> LinearSolver
Common result type shared by all iterative solvers.
Vector operations.