comparison scripts/sparse/pcr.m @ 20164:df437a52bcaf stable

doc: Update more docstrings to have one sentence summary as first line. Reviewed miscellaneous, sparse, strings in scripts directory. * scripts/miscellaneous/bzip2.m, scripts/miscellaneous/citation.m, scripts/miscellaneous/compare_versions.m, scripts/miscellaneous/computer.m, scripts/miscellaneous/debug.m, scripts/miscellaneous/dir.m, scripts/miscellaneous/edit.m, scripts/miscellaneous/error_ids.m, scripts/miscellaneous/fileattrib.m, scripts/miscellaneous/fullfile.m, scripts/miscellaneous/genvarname.m, scripts/miscellaneous/gzip.m, scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/news.m, scripts/miscellaneous/open.m, scripts/miscellaneous/parseparams.m, scripts/miscellaneous/recycle.m, scripts/miscellaneous/run.m, scripts/miscellaneous/swapbytes.m, scripts/miscellaneous/tar.m, scripts/miscellaneous/tmpnam.m, scripts/miscellaneous/unpack.m, scripts/miscellaneous/what.m, scripts/sparse/bicg.m, scripts/sparse/bicgstab.m, scripts/sparse/cgs.m, scripts/sparse/colperm.m, scripts/sparse/eigs.m, scripts/sparse/etreeplot.m, scripts/sparse/gmres.m, scripts/sparse/gplot.m, scripts/sparse/ichol.m, scripts/sparse/ilu.m, scripts/sparse/pcg.m, scripts/sparse/pcr.m, scripts/sparse/qmr.m, scripts/sparse/spaugment.m, scripts/sparse/spconvert.m, scripts/sparse/spdiags.m, scripts/sparse/spfun.m, scripts/sparse/spones.m, scripts/sparse/sprandsym.m, scripts/sparse/spstats.m, scripts/sparse/spy.m, scripts/sparse/svds.m, scripts/sparse/treelayout.m, scripts/sparse/treeplot.m, scripts/strings/base2dec.m, scripts/strings/bin2dec.m, scripts/strings/blanks.m, scripts/strings/cstrcat.m, scripts/strings/deblank.m, scripts/strings/dec2base.m, scripts/strings/dec2bin.m, scripts/strings/dec2hex.m, scripts/strings/findstr.m, scripts/strings/hex2dec.m, scripts/strings/index.m, scripts/strings/isletter.m, scripts/strings/isstrprop.m, scripts/strings/mat2str.m, scripts/strings/ostrsplit.m, scripts/strings/regexptranslate.m, scripts/strings/rindex.m, scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strchr.m, scripts/strings/strjoin.m, scripts/strings/strjust.m, scripts/strings/strmatch.m, scripts/strings/strsplit.m, scripts/strings/strtok.m, scripts/strings/strtrim.m, scripts/strings/strtrunc.m, scripts/strings/substr.m, scripts/strings/untabify.m, scripts/time/datenum.m: Update more docstrings to have one sentence summary as first line.
author Rik <rik@octave.org>
date Mon, 04 May 2015 14:22:02 -0700
parents 4197fc428c7d
children
comparison
equal deleted inserted replaced
20163:075a5e2e1ba5 20164:df437a52bcaf
18 18
19 ## -*- texinfo -*- 19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {@var{x} =} pcr (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{m}, @var{x0}, @dots{}) 20 ## @deftypefn {Function File} {@var{x} =} pcr (@var{A}, @var{b}, @var{tol}, @var{maxit}, @var{m}, @var{x0}, @dots{})
21 ## @deftypefnx {Function File} {[@var{x}, @var{flag}, @var{relres}, @var{iter}, @var{resvec}] =} pcr (@dots{}) 21 ## @deftypefnx {Function File} {[@var{x}, @var{flag}, @var{relres}, @var{iter}, @var{resvec}] =} pcr (@dots{})
22 ## 22 ##
23 ## Solve the linear system of equations @code{@var{A} * @var{x} = @var{b}} 23 ## Solve the linear system of equations @code{@var{A} * @var{x} = @var{b}} by
24 ## by means of the Preconditioned Conjugate Residuals iterative 24 ## means of the Preconditioned Conjugate Residuals iterative method.
25 ## method. The input arguments are 25 ##
26 ## The input arguments are
26 ## 27 ##
27 ## @itemize 28 ## @itemize
28 ## @item 29 ## @item
29 ## @var{A} can be either a square (preferably sparse) matrix or a 30 ## @var{A} can be either a square (preferably sparse) matrix or a function
30 ## function handle, inline function or string containing the name 31 ## handle, inline function or string containing the name of a function which
31 ## of a function which computes @code{@var{A} * @var{x}}. In principle 32 ## computes @code{@var{A} * @var{x}}. In principle @var{A} should be
32 ## @var{A} should be symmetric and non-singular; if @code{pcr} 33 ## symmetric and non-singular; if @code{pcr} finds @var{A} to be numerically
33 ## finds @var{A} to be numerically singular, you will get a warning 34 ## singular, you will get a warning message and the @var{flag} output
34 ## message and the @var{flag} output parameter will be set. 35 ## parameter will be set.
35 ## 36 ##
36 ## @item 37 ## @item
37 ## @var{b} is the right hand side vector. 38 ## @var{b} is the right hand side vector.
38 ## 39 ##
39 ## @item 40 ## @item
43 ## @var{tol} * norm (@var{b} - @var{A} * @var{x0})}. 44 ## @var{tol} * norm (@var{b} - @var{A} * @var{x0})}.
44 ## If @var{tol} is empty or is omitted, the function sets 45 ## If @var{tol} is empty or is omitted, the function sets
45 ## @code{@var{tol} = 1e-6} by default. 46 ## @code{@var{tol} = 1e-6} by default.
46 ## 47 ##
47 ## @item 48 ## @item
48 ## @var{maxit} is the maximum allowable number of iterations; if 49 ## @var{maxit} is the maximum allowable number of iterations; if @code{[]} is
49 ## @code{[]} is supplied for @code{maxit}, or @code{pcr} has less 50 ## supplied for @code{maxit}, or @code{pcr} has less arguments, a default
50 ## arguments, a default value equal to 20 is used. 51 ## value equal to 20 is used.
51 ## 52 ##
52 ## @item 53 ## @item
53 ## @var{m} is the (left) preconditioning matrix, so that the iteration is 54 ## @var{m} is the (left) preconditioning matrix, so that the iteration is
54 ## (theoretically) equivalent to solving by @code{pcr} @code{@var{P} * 55 ## (theoretically) equivalent to solving by
55 ## @var{x} = @var{m} \ @var{b}}, with @code{@var{P} = @var{m} \ @var{A}}. 56 ## @code{pcr} @code{@var{P} * @var{x} = @var{m} \ @var{b}}, with
56 ## Note that a proper choice of the preconditioner may dramatically 57 ## @code{@var{P} = @var{m} \ @var{A}}. Note that a proper choice of the
57 ## improve the overall performance of the method. Instead of matrix 58 ## preconditioner may dramatically improve the overall performance of the
58 ## @var{m}, the user may pass a function which returns the results of 59 ## method. Instead of matrix @var{m}, the user may pass a function which
59 ## applying the inverse of @var{m} to a vector (usually this is the 60 ## returns the results of applying the inverse of @var{m} to a vector
60 ## preferred way of using the preconditioner). If @code{[]} is supplied 61 ## (usually this is the preferred way of using the preconditioner). If
61 ## for @var{m}, or @var{m} is omitted, no preconditioning is applied. 62 ## @code{[]} is supplied for @var{m}, or @var{m} is omitted, no
63 ## preconditioning is applied.
62 ## 64 ##
63 ## @item 65 ## @item
64 ## @var{x0} is the initial guess. If @var{x0} is empty or omitted, the 66 ## @var{x0} is the initial guess. If @var{x0} is empty or omitted, the
65 ## function sets @var{x0} to a zero vector by default. 67 ## function sets @var{x0} to a zero vector by default.
66 ## @end itemize 68 ## @end itemize
67 ## 69 ##
68 ## The arguments which follow @var{x0} are treated as parameters, and 70 ## The arguments which follow @var{x0} are treated as parameters, and passed
69 ## passed in a proper way to any of the functions (@var{A} or @var{m}) 71 ## in a proper way to any of the functions (@var{A} or @var{m}) which are
70 ## which are passed to @code{pcr}. See the examples below for further 72 ## passed to @code{pcr}. See the examples below for further details.
71 ## details. The output arguments are 73 ##
74 ## The output arguments are
72 ## 75 ##
73 ## @itemize 76 ## @itemize
74 ## @item 77 ## @item
75 ## @var{x} is the computed approximation to the solution of 78 ## @var{x} is the computed approximation to the solution of
76 ## @code{@var{A} * @var{x} = @var{b}}. 79 ## @code{@var{A} * @var{x} = @var{b}}.
77 ## 80 ##
78 ## @item 81 ## @item
79 ## @var{flag} reports on the convergence. @code{@var{flag} = 0} means 82 ## @var{flag} reports on the convergence. @code{@var{flag} = 0} means the
80 ## the solution converged and the tolerance criterion given by @var{tol} 83 ## solution converged and the tolerance criterion given by @var{tol} is
81 ## is satisfied. @code{@var{flag} = 1} means that the @var{maxit} limit 84 ## satisfied. @code{@var{flag} = 1} means that the @var{maxit} limit for the
82 ## for the iteration count was reached. @code{@var{flag} = 3} reports t 85 ## iteration count was reached. @code{@var{flag} = 3} reports a @code{pcr}
83 ## @code{pcr} breakdown, see [1] for details. 86 ## breakdown, see [1] for details.
84 ## 87 ##
85 ## @item 88 ## @item
86 ## @var{relres} is the ratio of the final residual to its initial value, 89 ## @var{relres} is the ratio of the final residual to its initial value,
87 ## measured in the Euclidean norm. 90 ## measured in the Euclidean norm.
88 ## 91 ##
89 ## @item 92 ## @item
90 ## @var{iter} is the actual number of iterations performed. 93 ## @var{iter} is the actual number of iterations performed.
91 ## 94 ##
92 ## @item 95 ## @item
93 ## @var{resvec} describes the convergence history of the method, 96 ## @var{resvec} describes the convergence history of the method, so that
94 ## so that @code{@var{resvec} (i)} contains the Euclidean norms of the 97 ## @code{@var{resvec} (i)} contains the Euclidean norms of the residual after
95 ## residual after the (@var{i}-1)-th iteration, @code{@var{i} = 98 ## the (@var{i}-1)-th iteration, @code{@var{i} = 1,2, @dots{}, @var{iter}+1}.
96 ## 1,2, @dots{}, @var{iter}+1}.
97 ## @end itemize 99 ## @end itemize
98 ## 100 ##
99 ## Let us consider a trivial problem with a diagonal matrix (we exploit the 101 ## Let us consider a trivial problem with a diagonal matrix (we exploit the
100 ## sparsity of A) 102 ## sparsity of A)
101 ## 103 ##