Mercurial > octave-libgccjit
comparison scripts/linear-algebra/issymmetric.m @ 18921: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 | 9cf6d5868d21 |
children |
comparison
equal
deleted
inserted
replaced
18920:c4def7ab39e7 | 18921:d0d0858cfab1 |
---|---|
16 ## You should have received a copy of the GNU General Public License | 16 ## You should have received a copy of the GNU General Public License |
17 ## along with Octave; see the file COPYING. If not, see | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | 18 ## <http://www.gnu.org/licenses/>. |
19 | 19 |
20 ## -*- texinfo -*- | 20 ## -*- texinfo -*- |
21 ## @deftypefn {Function File} {} issymmetric (@var{x}) | 21 ## @deftypefn {Function File} {} issymmetric (@var{A}) |
22 ## @deftypefnx {Function File} {} issymmetric (@var{x}, @var{tol}) | 22 ## @deftypefnx {Function File} {} issymmetric (@var{A}, @var{tol}) |
23 ## Return true if @var{x} is a symmetric matrix within the tolerance specified | 23 ## Return true if @var{A} is a symmetric matrix within the tolerance specified |
24 ## by @var{tol}. The default tolerance is zero (uses faster code). | 24 ## by @var{tol}. |
25 ## Matrix @var{x} is considered symmetric if | 25 ## |
26 ## @code{norm (@var{x} - @var{x}.', Inf) / norm (@var{x}, Inf) < @var{tol}}. | 26 ## The default tolerance is zero (uses faster code). |
27 ## Matrix @var{A} is considered symmetric if | |
28 ## @code{norm (@var{A} - @var{A}.', Inf) / norm (@var{A}, Inf) < @var{tol}}. | |
27 ## @seealso{ishermitian, isdefinite} | 29 ## @seealso{ishermitian, isdefinite} |
28 ## @end deftypefn | 30 ## @end deftypefn |
29 | 31 |
30 ## Author: A. S. Hodel <scotte@eng.auburn.edu> | 32 ## Author: A. S. Hodel <scotte@eng.auburn.edu> |
31 ## Created: August 1993 | 33 ## Created: August 1993 |
32 ## Adapted-By: jwe | 34 ## Adapted-By: jwe |
33 | 35 |
34 function retval = issymmetric (x, tol = 0) | 36 function retval = issymmetric (A, tol = 0) |
35 | 37 |
36 if (nargin < 1 || nargin > 2) | 38 if (nargin < 1 || nargin > 2) |
37 print_usage (); | 39 print_usage (); |
38 endif | 40 endif |
39 | 41 |
40 retval = (isnumeric (x) || islogical (x)) && issquare (x); | 42 retval = (isnumeric (A) || islogical (A)) && issquare (A); |
41 if (retval) | 43 if (retval) |
42 if (tol == 0) | 44 if (tol == 0) |
43 ## Handle large sparse matrices as well as full ones | 45 ## Handle large sparse matrices as well as full ones |
44 retval = nnz (x != x.') == 0; | 46 retval = nnz (A != A.') == 0; |
45 else | 47 else |
46 norm_x = norm (x, inf); | 48 norm_x = norm (A, inf); |
47 retval = norm_x == 0 || norm (x - x.', inf) / norm_x <= tol; | 49 retval = norm_x == 0 || norm (A - A.', inf) / norm_x <= tol; |
48 endif | 50 endif |
49 endif | 51 endif |
50 | 52 |
51 endfunction | 53 endfunction |
52 | 54 |