1function [arg1, arg2] = bandwidth (G, uplo)
2%BANDWIDTH matrix bandwidth.
3% [lo, hi] = bandwidth (G) returns the upper and lower bandwidth of G.
4% lo = bandwidth (G, 'lower') returns just the lower bandwidth.
5% hi = bandwidth (G, 'upper') returns just the upper bandwidth.
6%
7% See also GrB/isbanded, GrB/isdiag, GrB/istril, GrB/istriu.
8
9% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
10% SPDX-License-Identifier: GPL-3.0-or-later
11
12% FUTURE: this will be much faster when implemented in a mexFunction.
13% It is currently much slower than the MATLAB bandwidth function.
14
15% compute the bandwidth
16G = G.opaque ;
17[lo, hi] = gb_bandwidth (G) ;
18
19% return the result
20if (nargin == 1)
21   arg1 = lo ;
22   arg2 = hi ;
23else
24    if (nargout > 1)
25        error ('too many output arguments') ;
26    elseif isequal (uplo, 'lower')
27        arg1 = lo ;
28    elseif isequal (uplo, 'upper')
29        arg1 = hi ;
30    else
31        error ('unrecognized option') ;
32    end
33end
34
35