File: bandwidth.m

package info (click to toggle)
suitesparse-graphblas 7.4.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 67,112 kB
  • sloc: ansic: 1,072,243; cpp: 8,081; sh: 512; makefile: 503; asm: 369; python: 125; awk: 10
file content (30 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function [arg1, arg2] = bandwidth (G, uplo)
%BANDWIDTH matrix bandwidth.
% [lo, hi] = bandwidth (G) returns the upper and lower bandwidth of G.
% lo = bandwidth (G, 'lower') returns just the lower bandwidth.
% hi = bandwidth (G, 'upper') returns just the upper bandwidth.
%
% See also GrB/isbanded, GrB/isdiag, GrB/istril, GrB/istriu.

% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
% SPDX-License-Identifier: Apache-2.0

if (nargin == 1)
    % compute lo, and compute hi if present in output argument list
    [lo, hi] = gbbandwidth (G.opaque, 1, nargout > 1) ;
    arg1 = lo ;
    arg2 = hi ;
else
    if (nargout > 1)
        error ('GrB:error', 'too many output arguments') ;
    elseif isequal (uplo, 'lower')
        [lo, ~] = gbbandwidth (G.opaque, 1, 0) ;
        arg1 = lo ;
    elseif isequal (uplo, 'upper')
        [~, hi] = gbbandwidth (G.opaque, 0, 1) ;
        arg1 = hi ;
    else
        error ('GrB:error', 'unrecognized option') ;
    end
end