1 function [x, k] = conjugate_gradient_method(A, b, x0, tolerance, max_iterations)
9 % min [phi(x) = (1/2)*<Ax,x> + <b,x>]
11 % using the conjugate_gradient_method.
15 % - ``A`` -- The coefficient matrix of the system to solve. Must
16 % be positive definite.
18 % - ``b`` -- The right-hand-side of the system to solve.
20 % - ``x0`` -- The starting point for the search.
22 % - ``tolerance`` -- How close ``Ax`` has to be to ``b`` (in
23 % magnitude) before we stop.
25 % - ``max_iterations`` -- The maximum number of iterations to perform.
29 % - ``x`` - The solution to Ax=b.
31 % - ``k`` - The ending value of k; that is, the number of iterations that
36 % All vectors are assumed to be *column* vectors.
38 % The rather verbose name of this function was chosen to avoid
39 % conflicts with other implementations.
44 % The standard CGM is equivalent to the preconditioned CGM is you
45 % use the identity matrix as your preconditioner.
46 [x, k] = preconditioned_conjugate_gradient_method(A, ...