1function s = isdiag (G)
2%ISDIAG true if G is a diagonal matrix.
3% isdiag (G) is true if G is a diagonal matrix, and false otherwise.
4%
5% See also GrB/isbanded.
6
7% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
8% SPDX-License-Identifier: GPL-3.0-or-later
9
10% FUTURE: this will be faster when 'gb_bandwidth' is a mexFunction,
11% but this version is fairly fast anyway.
12
13G = G.opaque ;
14
15% using gb_bandwidth instead:
16% [lo, hi] = gb_bandwidth (G) ;
17% s = (lo == 0) & (hi == 0) ;
18
19s = (gbnvals (gbselect ('diag', G, 0)) == gbnvals (G)) ;
20
21