Mercurial > octave
changeset 22827:c3d3a81ad986 stable
doc: Update documentation for norm, normest, normest1, condest.
* data.cc (Fnorm): Add normest and normest1 to @seealso list.
* condest.m: Delete extra space after colon.
* normest.m: Rename output 'n' to 'nest' for norm estimate. Rename output 'c'
to 'iter'. Add @seealso block.
* normest1.m: Rewrite docstring.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 24 Nov 2016 08:09:54 -0800 |
parents | fb913df7babb |
children | 41a751b19fd2 e23f7f47d8a3 |
files | libinterp/corefcn/data.cc scripts/linear-algebra/condest.m scripts/linear-algebra/normest.m scripts/linear-algebra/normest1.m |
diffstat | 4 files changed, 51 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/data.cc Thu Nov 24 07:11:23 2016 -0800 +++ b/libinterp/corefcn/data.cc Thu Nov 24 08:09:54 2016 -0800 @@ -5620,7 +5620,7 @@ @deftypefnx {} {} norm (@var{A}, @var{p}, @var{opt}) Compute the p-norm of the matrix @var{A}. -If the second argument is missing, @w{@code{p = 2}} is assumed. +If the second argument is not given, @w{@code{p = 2}} is used. If @var{A} is a matrix (or sparse matrix): @@ -5657,7 +5657,7 @@ Frobenius norm of @var{A}, @code{sqrt (sumsq (abs (A)))}. @item @var{p} = 0 -Hamming norm - the number of nonzero elements. +Hamming norm---the number of nonzero elements. @item other @var{p}, @code{@var{p} > 1} p-norm of @var{A}, @code{(sum (abs (@var{A}) .^ @var{p})) ^ (1/@var{p})}. @@ -5670,7 +5670,7 @@ compute its norm. The result is returned as a column vector. Similarly, if @var{opt} is @qcode{"columns"} or @qcode{"cols"} then compute the norms of each column and return a row vector. -@seealso{cond, svd} +@seealso{normest, normest1, cond, svd} @end deftypefn */) { int nargin = args.length ();
--- a/scripts/linear-algebra/condest.m Thu Nov 24 07:11:23 2016 -0800 +++ b/scripts/linear-algebra/condest.m Thu Nov 24 08:09:54 2016 -0800 @@ -78,7 +78,7 @@ ## large; it satisfies the equation ## @code{norm (A*v, 1) == norm (A, 1) * norm (@var{v}, 1) / @var{est}}. ## -## Algorithm Note: @code{condest} uses a randomized algorithm to approximate +## Algorithm Note: @code{condest} uses a randomized algorithm to approximate ## the 1-norms. Therefore, if consistent results are required, the ## @qcode{"state"} of the random generator should be fixed before invoking ## @code{condest}.
--- a/scripts/linear-algebra/normest.m Thu Nov 24 07:11:23 2016 -0800 +++ b/scripts/linear-algebra/normest.m Thu Nov 24 08:09:54 2016 -0800 @@ -18,9 +18,9 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {} {@var{n} =} normest (@var{A}) -## @deftypefnx {} {@var{n} =} normest (@var{A}, @var{tol}) -## @deftypefnx {} {[@var{n}, @var{c}] =} normest (@dots{}) +## @deftypefn {} {@var{nest} =} normest (@var{A}) +## @deftypefnx {} {@var{nest} =} normest (@var{A}, @var{tol}) +## @deftypefnx {} {[@var{nest}, @var{iter}] =} normest (@dots{}) ## Estimate the 2-norm of the matrix @var{A} using a power series analysis. ## ## This is typically used for large matrices, where the cost of calculating @@ -30,8 +30,9 @@ ## @var{tol} is the tolerance to which the 2-norm is calculated. By default ## @var{tol} is 1e-6. ## -## The optional output @var{c} returns the number of iterations needed for -## @code{normest} to converge. +## The optional output @var{iter} returns the number of iterations that were +## required for @code{normest} to converge. +## @seealso{normest1, norm, cond, condest} ## @end deftypefn function [n, c] = normest (A, tol = 1e-6)
--- a/scripts/linear-algebra/normest1.m Thu Nov 24 07:11:23 2016 -0800 +++ b/scripts/linear-algebra/normest1.m Thu Nov 24 08:09:54 2016 -0800 @@ -17,41 +17,40 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {} {@var{c} =} normest1 (@var{a}) -## @deftypefnx {} {@var{c} =} normest1 (@var{a}, @var{t}) -## @deftypefnx {} {@var{c} =} normest1 (@var{a}, @var{t}, @var{x0}) -## @deftypefnx {} {@var{c} =} normest1 (@var{afun}, @var{t}, @var{x0}, @var{p1}, @var{p2}, @dots{}) -## @deftypefnx {} {[@var{c}, @var{v}] =} normest1 (@var{a}, @dots{}) -## @deftypefnx {} {[@var{c}, @var{v}, @var{w}] =} normest1 (@var{a}, @dots{}) -## @deftypefnx {} {[@var{c}, @var{v}, @var{w}, @var{it}] =} normest1 (@var{a}, @dots{}) -## Estimate the 1-norm of the matrix @var{a} using a block algorithm. +## @deftypefn {} {@var{nest} =} normest1 (@var{A}) +## @deftypefnx {} {@var{nest} =} normest1 (@var{A}, @var{t}) +## @deftypefnx {} {@var{nest} =} normest1 (@var{A}, @var{t}, @var{x0}) +## @deftypefnx {} {@var{nest} =} normest1 (@var{Afun}, @var{t}, @var{x0}, @var{p1}, @var{p2}, @dots{}) +## @deftypefnx {} {[@var{nest}, @var{v}] =} normest1 (@var{A}, @dots{}) +## @deftypefnx {} {[@var{nest}, @var{v}, @var{w}] =} normest1 (@var{A}, @dots{}) +## @deftypefnx {} {[@var{nest}, @var{v}, @var{w}, @var{iter}] =} normest1 (@var{A}, @dots{}) +## Estimate the 1-norm of the matrix @var{A} using a block algorithm. ## -## For a medium size matrix @var{a}, @code{norm (@var{a}, 1)} should be -## used instead. For a large sparse matrix, when only an estimate of the norm -## is needed, @code{normest1 (@var{a})} might be faster. Moreover, it can be -## used for the estimate of the 1-norm of a linear -## operator @var{a} when matrix-vector products @code{@var{a} * @var{x}} and -## @code{@var{a}' * @var{x}} can be cheaply computed. In this case, -## instead of the matrix @var{a}, a function -## @code{@var{afun} (@var{flag}, @var{x})} can be used. It should return: +## @code{normest1} is best for large sparse matrices where only an estimate of +## the norm is required. For small to medium sized matrices, consider using +## @code{norm (@var{A}, 1)}. In addition, @code{normest1} can be used for the +## estimate of the 1-norm of a linear operator @var{A} when matrix-vector +## products @code{@var{A} * @var{x}} and @code{@var{A}' * @var{x}} can be +## cheaply computed. In this case, instead of the matrix @var{A}, a function +## @code{@var{Afun} (@var{flag}, @var{x})} is used; it must return: ## ## @itemize @bullet ## @item -## the dimension @var{n} of @var{a}, if @var{flag} is @qcode{"dim"} +## the dimension @var{n} of @var{A}, if @var{flag} is @qcode{"dim"} ## ## @item -## true if @var{a} is a real operator, if @var{flag} is @qcode{"real"} +## true if @var{A} is a real operator, if @var{flag} is @qcode{"real"} ## ## @item -## the result @code{@var{a} * @var{x}}, if @var{flag} is @qcode{"notransp"} +## the result @code{@var{A} * @var{x}}, if @var{flag} is @qcode{"notransp"} ## ## @item -## the result @code{@var{a}' * @var{x}}, if @var{flag} is @qcode{"transp"} +## the result @code{@var{A}' * @var{x}}, if @var{flag} is @qcode{"transp"} ## @end itemize ## -## A typical case is @var{a} defined by @code{@var{b} ^ @var{m}}, -## in which the result @code{@var{a} * @var{x}} can be computed without -## even forming explicitly @code{@var{b} ^ @var{m}} by: +## A typical case is @var{A} defined by @code{@var{b} ^ @var{m}}, in which the +## result @code{@var{A} * @var{x}} can be computed without even forming +## explicitly @code{@var{b} ^ @var{m}} by: ## ## @example ## @group @@ -63,35 +62,36 @@ ## @end example ## ## The parameters @var{p1}, @var{p2}, @dots{} are arguments of -## @code{@var{afun} (@var{flag}, @var{x}, @var{p1}, @var{p2}, @dots{})}. +## @code{@var{Afun} (@var{flag}, @var{x}, @var{p1}, @var{p2}, @dots{})}. ## -## The default value for @var{t} is 2. The algorithm requires -## matrix-matrix products with sizes @var{n} x @var{n} and -## @var{n} x @var{t}. +## The default value for @var{t} is 2. The algorithm requires matrix-matrix +## products with sizes @var{n} x @var{n} and @var{n} x @var{t}. ## -## The initial matrix @var{x0} should have columns of unit 1-norm. -## The default initial matrix @var{x0} has the first column -## @code{ones (@var{n}, 1) / @var{n}} -## and, if @var{t} > 1, the remaining columns with random elements -## @code{-1 / @var{n}}, @code{1 / @var{n}}, divided by @var{n}. +## The initial matrix @var{x0} should have columns of unit 1-norm. The default +## initial matrix @var{x0} has the first column +## @code{ones (@var{n}, 1) / @var{n}} and, if @var{t} > 1, the remaining +## columns with random elements @code{-1 / @var{n}}, @code{1 / @var{n}}, +## divided by @var{n}. +## +## On output, @var{nest} is the desired estimate, @var{v} and @var{w} +## are vectors such that @code{@var{w} = @var{A} * @var{v}}, with +## @code{norm (@var{w}, 1)} = @code{@var{c} * norm (@var{v}, 1)}. @var{iter} +## contains in @code{@var{iter}(1)} the number of iterations (the maximum is +## hardcoded to 5) and in @code{@var{iter}(2)} the total number of products +## @code{@var{A} * @var{x}} or @code{@var{A}' * @var{x}} performed by the +## algorithm. +## +## Algorithm Note: @code{normest1} uses random numbers during evaluation. ## Therefore, if consistent results are required, the @qcode{"state"} of the ## random generator should be fixed before invoking @code{normest1}. ## -## On output, @var{c} is the desired estimate, @var{v} and @var{w} -## vectors such that @code{@var{w} = @var{a} * @var{v}}, with -## @code{norm (@var{w}, 1)} = @code{@var{c} * norm (@var{v}, 1)}. -## @var{it} contains in @code{@var{it}(1)} the number of iterations -## (the maximum number is hardcoded to 5) and in @code{@var{it}(2)} -## the total number of products @code{@var{a} * @var{x}} or -## @code{@var{a}' * @var{x}} performed by the algorithm. -## ## Reference: @nospell{N. J. Higham and F. Tisseur}, ## @cite{A block algorithm for matrix 1-norm estimation, with and ## application to 1-norm @nospell{pseudospectra}}, ## @nospell{SIAM J. Matrix Anal. Appl.}, ## pp. 1185--1201, Vol 21, No. 4, 2000. ## -## @seealso{normest, rand} +## @seealso{normest, norm, cond, condest} ## @end deftypefn ## Ideally, we would set t and X to their default values but Matlab