file
conjugate_gradient2.hpp
Functions
Function documentation
Vector conjugate_gradient2(const Matrix& A, const Vector& b, Vector& x_vector, double tol = 1e-5, int max_iter = 1000)
Parameters | |
---|---|
A | The matrix A in the system of linear equations Ax = b. |
b | The right-hand side vector b in the system of linear equations Ax = b. |
x_vector | The initial guess for the solution vector x. This vector will be updated in-place. |
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 a system of linear equations Ax = b using the Conjugate Gradient method.