Solve A x = b
, where A is a square matrix, using the
Conjugate Gradients Squared method.
min (20, numel (b))
is used.
zeros (size (b))
is used.
A can be passed as a matrix or as a function handle or inline
function f
such that f(x) = A*x
.
The preconditioner P is given as P = M1 * M2
. Both M1
and M2 can be passed as a matrix or as a function handle or inline
function g
such that g(x) = M1 \ x
or g(x) = M2 \ x
.
If called with more than one output parameter
(the value 2 is unused but skipped for compatibility).
See also: pcg, bicgstab, bicg, gmres, qmr.
The following code
% Solve system of A*x=b A = [5 -1 3;-1 2 -2;3 -2 3]; b = [7;-1;4]; [a,b,c,d,e] = cgs (A,b)
Produces the following output
a = 1.00000 1.00000 1.00000 b = 0 c = 1.2529e-14 d = 3 e = 1.0000e+00 1.9178e-01 7.2378e-03 1.2529e-14
Package: octave