File: cat.m

package info (click to toggle)
suitesparse-graphblas 7.4.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 67,112 kB
  • sloc: ansic: 1,072,243; cpp: 8,081; sh: 512; makefile: 503; asm: 369; python: 125; awk: 10
file content (52 lines) | stat: -rw-r--r-- 1,468 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function C = cat (dim, varargin)
%CAT Concatenate arrays.
% C = cat (dim, A, B) concatenates the two matrices A and B along the
% dimension dim, which must be 1 or 2.  Multidimensional @GrB matrices
% are not supported.  C = cat (2,A,B) is the same as C = [A,B], and
% C = cat (1,A,B) is the same as C = [A;B].
%
% C = cat (dim, A1, A2, A3 ...) is the same as [A1,A2,A3,...] if dim
% is 2, and [A1;A2;A3;...] if dim is 1.
%
% If A and B are @GrB matrices and S = {A B} is a cell array, then
% C = cat (dim, S) does not trigger the @GrB/cat method, but uses
% the built-in method instead.  Use GrB.cell2mat instead.
%
% If the matrices have different types, the type is determined
% according to the rules in GrB.optype.
%
% Example:
%
%   A = GrB (magic (3))
%   B = GrB (pascal (3))
%   C1 = [A ; B]
%   C2 = cat (1, A, B)
%   assert (isequal (C1, C2)) ;
%   C1 = [A B]
%   C2 = cat (2, A, B)
%   assert (isequal (C1, C2)) ;
%
% See also GrB/horzcat, GrB/vertcat, GrB.cell2mat, GrB/mat2cell,
% GrB/num2cell.

% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
% SPDX-License-Identifier: Apache-2.0

% get the input matrices
nmatrices = length (varargin) ;
for k = 1:nmatrices
    Tile = varargin {k} ;
    if (isobject (Tile))
        varargin {k} = Tile.opaque ;
    end
end

% concatenate the matrices
if (dim == 1)
    % same as vertcat
    C = GrB (gbcat (varargin')) ;
else
    % same as horzcat
    C = GrB (gbcat (varargin)) ;
end