comparison scripts/linear-algebra/isbanded.m @ 30558:83aeaba707d8

doc: Use TF for output variable in documentation for isXXX functions in scripts/ directory. * isplaying.m, isrecording.m, isequal.m, isequaln.m, iscolormap.m, is_valid_file_id.m, isdir.m, isstr.m, isbanded.m, isdefinite.m, isdiag.m, ishermitian.m, issymmetric.m, istril.m, istriu.m, isdeployed.m, isfolder.m, ismac.m, ismethod.m, ispc.m, isunix.m, isaxes.m, isfigure.m, isgraphics.m, ishandle.m, ishold.m, ispref.m, isprime.m, isletter.m, isstring.m, isstrprop.m, is_leap_year.m: Use TF for output variable in documentation for isXXX functions. Change variable name in code function prototype to match documentation.
author Rik <rik@octave.org>
date Mon, 27 Dec 2021 16:07:08 -0800
parents 7854d5752dd2
children 83f9f8bda883
comparison
equal deleted inserted replaced
30557:16c5cdc7741e 30558:83aeaba707d8
22 ## <https://www.gnu.org/licenses/>. 22 ## <https://www.gnu.org/licenses/>.
23 ## 23 ##
24 ######################################################################## 24 ########################################################################
25 25
26 ## -*- texinfo -*- 26 ## -*- texinfo -*-
27 ## @deftypefn {} {} isbanded (@var{A}, @var{lower}, @var{upper}) 27 ## @deftypefn {} {@var{tf} =} isbanded (@var{A}, @var{lower}, @var{upper})
28 ## Return true if @var{A} is a matrix with entries confined between 28 ## Return true if @var{A} is a matrix with entries confined between
29 ## @var{lower} diagonals below the main diagonal and @var{upper} diagonals 29 ## @var{lower} diagonals below the main diagonal and @var{upper} diagonals
30 ## above the main diagonal. 30 ## above the main diagonal.
31 ## 31 ##
32 ## @var{lower} and @var{upper} must be non-negative integers. 32 ## @var{lower} and @var{upper} must be non-negative integers.
33 ## @seealso{isdiag, istril, istriu, bandwidth} 33 ## @seealso{isdiag, istril, istriu, bandwidth}
34 ## @end deftypefn 34 ## @end deftypefn
35 35
36 function retval = isbanded (A, lower, upper) 36 function tf = isbanded (A, lower, upper)
37 37
38 if (nargin != 3) 38 if (nargin != 3)
39 print_usage (); 39 print_usage ();
40 endif 40 endif
41 41
42 if (! isreal (lower) || ! isreal (upper) || lower < 0 || upper < 0) 42 if (! isreal (lower) || ! isreal (upper) || lower < 0 || upper < 0)
43 error ("isbanded: LOWER and UPPER must be non-negative integers"); 43 error ("isbanded: LOWER and UPPER must be non-negative integers");
44 endif 44 endif
45 45
46 if (isempty (A)) 46 if (isempty (A))
47 retval = []; 47 tf = [];
48 else 48 else
49 retval = (isnumeric (A) || islogical (A)) && ndims (A) == 2; 49 tf = (isnumeric (A) || islogical (A)) && ndims (A) == 2;
50 if (retval) 50 if (tf)
51 [i, j] = find (A); 51 [i, j] = find (A);
52 pupp = j >= i; 52 pupp = j >= i;
53 retval = all (j(pupp) - i(pupp) <= upper); 53 tf = all (j(pupp) - i(pupp) <= upper);
54 if (retval) 54 if (tf)
55 plow = i >= j; 55 plow = i >= j;
56 retval = all (i(plow) - j(plow) <= lower); 56 tf = all (i(plow) - j(plow) <= lower);
57 endif 57 endif
58 endif 58 endif
59 endif 59 endif
60 60
61 endfunction 61 endfunction