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} {} issquare (@var{x}) |
|
21 ## If @var{x} is a square matrix, then return the dimension of @var{x}. |
|
22 ## Otherwise, return 0. |
5642
|
23 ## @seealso{size, rows, columns, length, ismatrix, isscalar, isvector} |
4026
|
24 ## @end deftypefn |
|
25 |
|
26 ## Author: A. S. Hodel <scotte@eng.auburn.edu> |
|
27 ## Created: August 1993 |
|
28 ## Adapted-By: jwe |
|
29 |
|
30 function retval = issquare (x) |
|
31 |
|
32 retval = 0; |
|
33 |
|
34 if (nargin == 1) |
4890
|
35 if (ismatrix (x) && ndims (x) < 3) |
4026
|
36 [nr, nc] = size (x); |
|
37 if (nr == nc && nr > 0) |
|
38 retval = nr; |
|
39 endif |
|
40 endif |
|
41 else |
6046
|
42 print_usage (); |
4026
|
43 endif |
|
44 |
|
45 endfunction |