1function C = full (A, type, identity) 2%FULL convert a matrix into a GraphBLAS full matrix. 3% C = full (A, type, identity) converts the matrix A into a GraphBLAS full 4% matrix C of the given type, by inserting identity values. The type may 5% be any GraphBLAS type: 'double', 'single', 'single complex', 'double 6% complex', 'logical', 'int8', 'int16', 'int32', 'int64', 'uint8', 7% 'uint16', 'uint32', or 'uint64'. 8% 9% If not present, the type defaults to the same type as A, and the identity 10% defaults to zero. A may be any matrix (GraphBLAS, MATLAB sparse or 11% full). To use this method for a MATLAB matrix A, use a GraphBLAS 12% identity value such as GrB(0), or use C = full (GrB (A)). Note that 13% issparse (C) is true, since issparse (A) is true for any GraphBLAS matrix 14% A. 15% 16% Examples: 17% 18% G = GrB (sprand (5, 5, 0.5)) % GraphBLAS sparse matrix 19% C = full (G) % add explicit zeros 20% C = full (G, 'double', inf) % add explicit inf's 21% 22% A = speye (2) 23% C = full (GrB (A), 'double', 0) % full GrB matrix C, from A 24% C = full (GrB (A)) % same matrix C 25% 26% See also GrB/issparse, sparse, cast, GrB.type, GrB, GrB.isfull. 27 28% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 29% SPDX-License-Identifier: GPL-3.0-or-later 30 31A_is_GrB = isobject (A) ; 32if (A_is_GrB) 33 % A is a GraphBLAS matrix 34 Q = A.opaque ; 35else 36 % A is a MATLAB matrix 37 Q = A ; 38end 39 40if (nargin < 2) 41 type = gbtype (Q) ; 42 right_type = true ; 43else 44 right_type = isequal (type, gbtype (Q)) ; 45end 46 47if (gb_isfull (Q) && right_type) 48 49 % nothing to do, A is already full and has the right type 50 if (A_is_GrB) 51 % A is already a GrB matrix, return it as-is 52 C = A ; 53 else 54 % convert A into a GrB matrix 55 C = GrB (A) ; 56 end 57 58else 59 60 % convert A to a full GraphBLAS matrix 61 if (nargin < 3) 62 identity = 0 ; 63 elseif (isobject (identity)) 64 identity = identity.opaque ; 65 end 66 C = GrB (gbfull (Q, type, identity)) ; 67 68end 69 70