1function C = sign (G)
2%SIGN signum function.
3% C = sign (G) is the signum function for each entry of G.  For real
4% values, sign(x) is 1 if x > 0, zero if x is zero, and -1 if x < 0.
5% For the complex case, sign(x) = x ./ abs (x).
6%
7% See also GrB/abs.
8
9% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
10% SPDX-License-Identifier: GPL-3.0-or-later
11
12Q = G.opaque ;
13type = gbtype (Q) ;
14
15if (isequal (type, 'logical'))
16    C = G ;
17elseif (~gb_isfloat (type))
18    C = GrB (gbnew (gbapply ('signum.single', Q), type)) ;
19else
20    C = GrB (gbapply ('signum', Q)) ;
21end
22
23