numerics
Loading...
Searching...
No Matches
jacobi.hpp
Go to the documentation of this file.
1/// @file jacobi.hpp
2/// @brief Jacobi 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 Jacobi iterative solver for Ax = b
12///
13/// Updates all components simultaneously using only values from the previous
14/// iteration. Converges for strictly diagonally dominant A. Trivially
15/// parallelisable with Backend::omp.
16///
17/// @param A Square matrix
18/// @param b Right-hand side vector
19/// @param x Solution vector (initial guess on input, solution on output)
20/// @param tol Convergence tolerance on residual norm (default 1e-10)
21/// @param max_iter Maximum iterations (default 1000)
22/// @param backend Execution backend (default: default_backend)
23/// @return SolverResult with convergence info
24SolverResult jacobi(const Matrix& A, const Vector& b, Vector& x,
25 real tol = 1e-10, idx max_iter = 1000,
26 Backend backend = default_backend);
27
28} // 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
BasicVector< real > Vector
Real-valued dense vector with full backend dispatch (CPU + GPU)
Definition vector.hpp:122
SolverResult jacobi(const Matrix &A, const Vector &b, Vector &x, real tol=1e-10, idx max_iter=1000, Backend backend=default_backend)
Jacobi iterative solver for Ax = b.
Definition jacobi.cpp:7
constexpr Backend default_backend
Definition policy.hpp:57
Backend enum for linear algebra operations.
Common result type shared by all iterative solvers.
Vector operations.