Skip to content

num::gauss_seidel

Defined in header <linear/solvers/gauss_seidel.hpp>

template <class Mat = with_law<mat<real>, law::diagonally_dominant>,
          bool Parallel = has_omp>
requires claims<Mat, law::diagonally_dominant> || claims<Mat, law::spd>
solver_result gauss_seidel(const Mat &A_in, const vec<real> &b, vec<real> &x,
                           real tol = 1e-10, idx max_iter = 1000);

Gauss-Seidel iterative solver for Ax = b.

Requires strictly diagonally dominant or SPD A; the two are incomparable, so pass num::assume_diagonally_dominant(A) or num::assume_spd(A). The sweep is sequential; Parallel threads only the residual. Use num::jacobi<true> for a parallel sweep.

Parameters

  • A_in: Square matrix claiming the law
  • b: Right-hand side vector
  • x: Solution vector (initial guess on input, solution on output)
  • tol: Convergence tolerance on residual norm (default 1e-10)
  • max_iter: Maximum iterations (default 1000)

Return value

solver_result with convergence info