Mercurial > octave-nkf
changeset 18955:d0d0858cfab1
doc: Match docstring variable names to function variable names for linear-algebra m-files.
* isbanded.m, isdefinite.m, isdiag.m, ishermitian.m, issymmetric.m, istril.m,
istriu.m: Use 'A' for input matrix in linear algebra routines. Change docstrings
from 'x' to 'A'.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 14 Jul 2014 08:54:45 -0700 |
parents | c4def7ab39e7 |
children | 9a5e03801d23 |
files | scripts/linear-algebra/isbanded.m scripts/linear-algebra/isdefinite.m scripts/linear-algebra/isdiag.m scripts/linear-algebra/ishermitian.m scripts/linear-algebra/issymmetric.m scripts/linear-algebra/istril.m scripts/linear-algebra/istriu.m |
diffstat | 7 files changed, 47 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/linear-algebra/isbanded.m Sun Jul 13 21:25:47 2014 -0700 +++ b/scripts/linear-algebra/isbanded.m Mon Jul 14 08:54:45 2014 -0700 @@ -17,8 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} isbanded (@var{x}, @var{lower}, @var{upper}) -## Return true if @var{x} is a matrix with entries confined between +## @deftypefn {Function File} {} isbanded (@var{A}, @var{lower}, @var{upper}) +## Return true if @var{A} is a matrix with entries confined between ## @var{lower} diagonals below the main diagonal and @var{upper} diagonals ## above the main diagonal. ##
--- a/scripts/linear-algebra/isdefinite.m Sun Jul 13 21:25:47 2014 -0700 +++ b/scripts/linear-algebra/isdefinite.m Mon Jul 14 08:54:45 2014 -0700 @@ -17,13 +17,13 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} isdefinite (@var{x}) -## @deftypefnx {Function File} {} isdefinite (@var{x}, @var{tol}) -## Return 1 if @var{x} is symmetric positive definite within the -## tolerance specified by @var{tol} or 0 if @var{x} is symmetric +## @deftypefn {Function File} {} isdefinite (@var{A}) +## @deftypefnx {Function File} {} isdefinite (@var{A}, @var{tol}) +## Return 1 if @var{A} is symmetric positive definite within the +## tolerance specified by @var{tol} or 0 if @var{A} is symmetric ## positive semidefinite. Otherwise, return -1. If @var{tol} ## is omitted, use a tolerance of -## @code{100 * eps * norm (@var{x}, "fro")} +## @code{100 * eps * norm (@var{A}, "fro")} ## @seealso{issymmetric, ishermitian} ## @end deftypefn @@ -31,30 +31,30 @@ ## Created: November 2003 ## Adapted-By: jwe -function retval = isdefinite (x, tol) +function retval = isdefinite (A, tol) if (nargin < 1 || nargin > 2) print_usage (); endif - if (! isfloat (x)) - x = double (x); + if (! isfloat (A)) + A = double (A); endif if (nargin == 1) - tol = 100 * eps (class (x)) * norm (x, "fro"); + tol = 100 * eps (class (A)) * norm (A, "fro"); endif - if (! ishermitian (x, tol)) - error ("isdefinite: X must be a Hermitian matrix"); + if (! ishermitian (A, tol)) + error ("isdefinite: A must be a Hermitian matrix"); endif - e = tol * eye (rows (x)); - [r, p] = chol (x - e); + e = tol * eye (rows (A)); + [r, p] = chol (A - e); if (p == 0) retval = 1; else - [r, p] = chol (x + e); + [r, p] = chol (A + e); if (p == 0) retval = 0; else @@ -83,5 +83,5 @@ %!error isdefinite () %!error isdefinite (1,2,3) -%!error <X must be a Hermitian matrix> isdefinite ([1 2; 3 4]) +%!error <A must be a Hermitian matrix> isdefinite ([1 2; 3 4])
--- a/scripts/linear-algebra/isdiag.m Sun Jul 13 21:25:47 2014 -0700 +++ b/scripts/linear-algebra/isdiag.m Mon Jul 14 08:54:45 2014 -0700 @@ -17,8 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} isdiag (@var{x}) -## Return true if @var{x} is a diagonal matrix. +## @deftypefn {Function File} {} isdiag (@var{A}) +## Return true if @var{A} is a diagonal matrix. ## @seealso{isbanded, istril, istriu, diag, bandwidth} ## @end deftypefn
--- a/scripts/linear-algebra/ishermitian.m Sun Jul 13 21:25:47 2014 -0700 +++ b/scripts/linear-algebra/ishermitian.m Mon Jul 14 08:54:45 2014 -0700 @@ -18,13 +18,14 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} ishermitian (@var{x}) -## @deftypefnx {Function File} {} ishermitian (@var{x}, @var{tol}) -## Return true if @var{x} is Hermitian within the tolerance specified by +## @deftypefn {Function File} {} ishermitian (@var{A}) +## @deftypefnx {Function File} {} ishermitian (@var{A}, @var{tol}) +## Return true if @var{A} is Hermitian within the tolerance specified by ## @var{tol}. +## ## The default tolerance is zero (uses faster code). -## Matrix @var{x} is considered symmetric if -## @code{norm (@var{x} - @var{x}', Inf) / norm (@var{x}, Inf) < @var{tol}}. +## Matrix @var{A} is considered symmetric if +## @code{norm (@var{A} - @var{A}', Inf) / norm (@var{A}, Inf) < @var{tol}}. ## @seealso{issymmetric, isdefinite} ## @end deftypefn @@ -32,19 +33,19 @@ ## Created: August 1993 ## Adapted-By: jwe -function retval = ishermitian (x, tol = 0) +function retval = ishermitian (A, tol = 0) if (nargin < 1 || nargin > 2) print_usage (); endif - retval = isnumeric (x) && issquare (x); + retval = isnumeric (A) && issquare (A); if (retval) if (tol == 0) - retval = all ((x == x')(:)); + retval = all ((A == A')(:)); else - norm_x = norm (x, inf); - retval = norm_x == 0 || norm (x - x', inf) / norm_x <= tol; + norm_x = norm (A, inf); + retval = norm_x == 0 || norm (A - A', inf) / norm_x <= tol; endif endif
--- a/scripts/linear-algebra/issymmetric.m Sun Jul 13 21:25:47 2014 -0700 +++ b/scripts/linear-algebra/issymmetric.m Mon Jul 14 08:54:45 2014 -0700 @@ -18,12 +18,14 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} issymmetric (@var{x}) -## @deftypefnx {Function File} {} issymmetric (@var{x}, @var{tol}) -## Return true if @var{x} is a symmetric matrix within the tolerance specified -## by @var{tol}. The default tolerance is zero (uses faster code). -## Matrix @var{x} is considered symmetric if -## @code{norm (@var{x} - @var{x}.', Inf) / norm (@var{x}, Inf) < @var{tol}}. +## @deftypefn {Function File} {} issymmetric (@var{A}) +## @deftypefnx {Function File} {} issymmetric (@var{A}, @var{tol}) +## Return true if @var{A} is a symmetric matrix within the tolerance specified +## by @var{tol}. +## +## The default tolerance is zero (uses faster code). +## Matrix @var{A} is considered symmetric if +## @code{norm (@var{A} - @var{A}.', Inf) / norm (@var{A}, Inf) < @var{tol}}. ## @seealso{ishermitian, isdefinite} ## @end deftypefn @@ -31,20 +33,20 @@ ## Created: August 1993 ## Adapted-By: jwe -function retval = issymmetric (x, tol = 0) +function retval = issymmetric (A, tol = 0) if (nargin < 1 || nargin > 2) print_usage (); endif - retval = (isnumeric (x) || islogical (x)) && issquare (x); + retval = (isnumeric (A) || islogical (A)) && issquare (A); if (retval) if (tol == 0) ## Handle large sparse matrices as well as full ones - retval = nnz (x != x.') == 0; + retval = nnz (A != A.') == 0; else - norm_x = norm (x, inf); - retval = norm_x == 0 || norm (x - x.', inf) / norm_x <= tol; + norm_x = norm (A, inf); + retval = norm_x == 0 || norm (A - A.', inf) / norm_x <= tol; endif endif
--- a/scripts/linear-algebra/istril.m Sun Jul 13 21:25:47 2014 -0700 +++ b/scripts/linear-algebra/istril.m Mon Jul 14 08:54:45 2014 -0700 @@ -17,8 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} istril (@var{x}) -## Return true if @var{x} is a lower triangular matrix. +## @deftypefn {Function File} {} istril (@var{A}) +## Return true if @var{A} is a lower triangular matrix. ## ## A lower triangular matrix has nonzero entries only on the main diagonal ## and below.
--- a/scripts/linear-algebra/istriu.m Sun Jul 13 21:25:47 2014 -0700 +++ b/scripts/linear-algebra/istriu.m Mon Jul 14 08:54:45 2014 -0700 @@ -17,8 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} istriu (@var{x}) -## Return true if @var{x} is an upper triangular matrix. +## @deftypefn {Function File} {} istriu (@var{A}) +## Return true if @var{A} is an upper triangular matrix. ## ## An upper triangular matrix has nonzero entries only on the main diagonal ## and above.