1function C = cat (dim, varargin) 2%CAT Concatenate arrays. 3% C = cat (dim, A, B) concatenates the two matrices A and B along the 4% dimension dim, which must be 1 or 2. Multidimensional @GrB matrices 5% are not supported. C = cat (2,A,B) is the same as C = [A,B], and 6% C = cat (1,A,B) is the same as C = [A;B]. 7% 8% C = cat (dim, A1, A2, A3 ...) is the same as [A1,A2,A3,...] if dim 9% is 2, and [A1;A2;A3;...] if dim is 1. 10% 11% If A and B are @GrB matrices and S = {A B} is a cell array, then 12% C = cat (dim, S) does not trigger the @GrB/cat method, but uses 13% the MATLAB built-in method instead. Use GrB.cell2mat instead. 14% 15% If the matrices have different types, the type is determined 16% according to the rules in GrB.optype. 17% 18% Example: 19% 20% A = GrB (magic (3)) 21% B = GrB (pascal (3)) 22% C1 = [A ; B] 23% C2 = cat (1, A, B) 24% assert (isequal (C1, C2)) ; 25% C1 = [A B] 26% C2 = cat (2, A, B) 27% assert (isequal (C1, C2)) ; 28% 29% See also GrB/horzcat, GrB/vertcat, GrB.cell2mat, GrB/mat2cell, 30% GrB/num2cell. 31 32% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 33% SPDX-License-Identifier: GPL-3.0-or-later 34 35% get the input matrices 36nmatrices = length (varargin) ; 37for k = 1:nmatrices 38 Tile = varargin {k} ; 39 if (isobject (Tile)) 40 varargin {k} = Tile.opaque ; 41 end 42end 43 44% concatenate the matrices 45if (dim == 1) 46 % same as vertcat 47 C = GrB (gbcat (varargin')) ; 48else 49 % same as horzcat 50 C = GrB (gbcat (varargin)) ; 51end 52 53