Next: , Previous: pcg, Up: Function Reference


22.6.2.17 pcr

— Function File: x = pcr (a, b, tol, maxit, m, x0, ...)
— Function File: [x, flag, relres, iter, resvec] = pcr (...)

Solves the linear system of equations a * x = b by means of the Preconditioned Conjugate Residuals iterative method. The input arguments are

The arguments which follow x0 are treated as parameters, and passed in a proper way to any of the functions (a or m) which are passed to pcr. See the examples below for further details. The output arguments are

Let us consider a trivial problem with a diagonal matrix (we exploit the sparsity of A)

          	N = 10;
          	A = diag([1:N]); A = sparse(A);
          	b = rand(N,1);
     

Example 1: Simplest use of pcr

            x = pcr(A, b)
     

Example 2: pcr with a function which computes a * x.

            function y = applyA(x)
              y = [1:10]'.*x;
            endfunction
          
            x = pcr('applyA',b)
     

Example 3: Preconditioned iteration, with full diagnostics. The preconditioner (quite strange, because even the original matrix a is trivial) is defined as a function

            function y = applyM(x)
              K = floor(length(x)-2);
              y = x;
              y(1:K) = x(1:K)./[1:K]';
            endfunction
          
            [x, flag, relres, iter, resvec] = pcr(A,b,[],[],'applyM')
            semilogy([1:iter+1], resvec);
     

Example 4: Finally, a preconditioner which depends on a parameter k.

            function y = applyM(x, varargin)
              K = varargin{1};
              y = x; y(1:K) = x(1:K)./[1:K]';
            endfunction
          
            [x, flag, relres, iter, resvec] = pcr(A,b,[],[],'applyM',[],3)
     

References

[1] W. Hackbusch, "Iterative Solution of Large Sparse Systems of Equations", section 9.5.4; Springer, 1994

     
     
See also: sparse, pcg.