1function C = gb_to_real_if_imag_zero (G)
2%GB_TO_REAL_IF_IMAG_ZERO convert complex matrix to real if imag(G) is zero
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: GPL-3.0-or-later
6
7if (contains (gbtype (G), 'complex') && ...
8    gbnvals (gbselect ('nonzero', gbapply ('cimag', G))) == 0)
9    C = gbapply ('creal', G) ;
10else
11    C = G ;
12end
13
14