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