ellalgo/conjugate_gradient.hpp file

Classes

class Vector0
class Matrix0

Functions

auto operator+(Vector0 lhs, const Vector0& rhs) -> Vector0
auto operator-(Vector0 lhs, const Vector0& rhs) -> Vector0
auto operator*(Vector0 v, double scalar) -> Vector0
auto operator*(double scalar, Vector0 v) -> Vector0
auto conjugate_gradient(const Matrix0& A, const Vector0& b, const Vector0* x0 = nullptr, double tol = 1e-5, int max_iter = 1000) -> Vector0

Function documentation

Vector0 conjugate_gradient(const Matrix0& A, const Vector0& b, const Vector0* x0 = nullptr, double tol = 1e-5, int max_iter = 1000)

Parameters
A The matrix A in the linear system Ax = b.
b The right-hand side vector b in the linear system Ax = b.
x0 An optional initial guess for the solution vector x.
tol The tolerance for the residual norm, used as the stopping criterion.
max_iter The maximum number of iterations to perform.
Returns The solution vector x.
Exceptions
std::runtime_error if the conjugate gradient method does not converge after the maximum number of iterations.

Solves the linear system Ax = b using the conjugate gradient method.