numerics
Loading...
Searching...
No Matches
gauss_seidel.hpp
Go to the documentation of this file.
1/// @file gauss_seidel.hpp
2/// @brief Gauss-Seidel iterative solver
3#pragma once
5#include "core/matrix.hpp"
6#include "core/vector.hpp"
7#include "core/policy.hpp"
8
9namespace num {
10
11/// @brief Gauss-Seidel iterative solver for Ax = b
12///
13/// Updates each component x[i] in-place using the latest values of all
14/// other components. Converges for strictly diagonally dominant or symmetric
15/// positive definite A.
16///
17/// With Backend::omp the residual computation is parallelised; the update
18/// sweep remains sequential to preserve convergence properties.
19///
20/// @param A Square matrix
21/// @param b Right-hand side vector
22/// @param x Solution vector (initial guess on input, solution on output)
23/// @param tol Convergence tolerance on residual norm (default 1e-10)
24/// @param max_iter Maximum iterations (default 1000)
25/// @param backend Execution backend (default: default_backend)
26/// @return SolverResult with convergence info
27SolverResult gauss_seidel(const Matrix& A, const Vector& b, Vector& x,
28 real tol = 1e-10, idx max_iter = 1000,
29 Backend backend = default_backend);
30
31} // namespace num
Matrix operations.
double real
Definition types.hpp:10
Backend
Selects which backend handles a linalg operation.
Definition policy.hpp:19
constexpr T ipow(T x) noexcept
Compute x^N at compile time via repeated squaring.
std::size_t idx
Definition types.hpp:11
constexpr real e
Definition math.hpp:41
SolverResult gauss_seidel(const Matrix &A, const Vector &b, Vector &x, real tol=1e-10, idx max_iter=1000, Backend backend=default_backend)
Gauss-Seidel iterative solver for Ax = b.
BasicVector< real > Vector
Real-valued dense vector with full backend dispatch (CPU + GPU)
Definition vector.hpp:122
constexpr Backend default_backend
Definition policy.hpp:57
Backend enum for linear algebra operations.
Common result type shared by all iterative solvers.
Vector operations.