7017
|
1 ## Copyright (C) 1996, 1997, 2002, 2003, 2004, 2005, 2006, 2007 |
|
2 ## John W. Eaton |
4026
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
7016
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
4026
|
10 ## |
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
4026
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} issymmetric (@var{x}, @var{tol}) |
|
22 ## If @var{x} is symmetric within the tolerance specified by @var{tol}, |
|
23 ## then return the dimension of @var{x}. Otherwise, return 0. If |
|
24 ## @var{tol} is omitted, use a tolerance equal to the machine precision. |
5642
|
25 ## @seealso{size, rows, columns, length, ismatrix, isscalar, |
|
26 ## issquare, isvector} |
4026
|
27 ## @end deftypefn |
|
28 |
|
29 ## Author: A. S. Hodel <scotte@eng.auburn.edu> |
|
30 ## Created: August 1993 |
|
31 ## Adapted-By: jwe |
|
32 |
|
33 function retval = issymmetric (x,tol) |
|
34 |
|
35 if (nargin == 1 || nargin == 2) |
|
36 retval = issquare (x); |
|
37 if (retval != 0) |
|
38 if (nargin == 1) |
|
39 tol = eps; |
|
40 endif |
4630
|
41 norm_x = norm (x); |
|
42 if (norm_x != 0 && norm (x - x') / norm_x > tol) |
4026
|
43 retval = 0; |
|
44 endif |
|
45 endif |
|
46 else |
6046
|
47 print_usage (); |
4026
|
48 endif |
|
49 |
|
50 endfunction |