1function C = gbtest_cast (A, type) 2%GBTEST_CAST cast a MATLAB matrix to another type. 3% C = gbtest_cast (A, type) is identical to C = cast (A, type) when type 4% is a valid MATLAB class ('logical', 'int8', 'int16', 'int32', 'int64', 5% 'uint8', 'uint16', 'uint32', 'uint64', 'single', 'double'). Otherwise, 6% A is converted to a single complex or double complex matrix C. 7% 8% A must be a full MATLAB matrix (not sparse). C is a full MATLAB matrix. 9% To cast any matrix to a GraphBLAS matrix instead, use C = GrB (A, type). 10% 11% See also cast. 12 13% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 14% SPDX-License-Identifier: GPL-3.0-or-later 15 16if (issparse (A)) 17 error ('A must be full') ; 18end 19if (isa (A, 'GrB')) 20 error ('A must be a MATLAB matrix') ; 21end 22 23if (contains (type, 'complex')) 24 if (contains (type, 'single')) 25 C = complex (single (A)) ; 26 else 27 C = complex (double (A)) ; 28 end 29else 30 C = cast (A, type) ; 31end 32 33assert (~issparse (C)) ; 34assert (~isa (C, 'GrB')) ; 35 36