LinearConjugateGradient

Prototype

Matrix LinearConjugateGradient ( Matrix x0, Matrix A, Matrix b )

Return Value

The return value is a matrix with n rows and m columns, where n is the dimension of A. The last column approximates the vector inv(A)*b.

Parameters

Matrix x0
A column vector of length n that is an initial guess for the vector inv(A)*b.

Matrix A
An (n x n) symmetric positive definite matrix.

Matrix b
A column vector of length n.

Remarks

The linear conjugate gradient algorithm solves for the solution to the linear system of Ax = b where A is a symmetric positive definite (n x n) matrix. The module requires an initial guess, x0. The module does not verify that the matrix A is symmetric positive definite. The module returns a matrix X with column vectors x0, x1, x2, ..., xm that describe the algorithm’s iteration from x0 to the approximate solution vector xm. The algorithm converges in at most n iterations, so mn.

Example
dim = 5;
A = ComputeSymPosDefMatrix( dim );
x0 = j( dim, 1, 0 );
b = T( 1:dim );
trajectory = LinearConjugateGradient( x0, A, b );
x = trajectory[ , ncol(trajectory) ];
print x "should approximate" (inv(A)*b);
See Also

ComputeSymPosDefMatrix