This file is indexed.

/usr/share/freemat/toolbox/array/cat.m is in freemat-data 4.0-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
% CAT CAT Concatenation of Arrays
% 
% Usage
% 
% This function concatenates arrays in a given
% dimension.  The syntax for its use is
% 
%    cat (DIM, A, B)
%    cat (DIM, A, B, C ...)
% 
% to return the concatenation along the dimension DIM of all arguments. 
% cat(1, A, B, C) is the same as [A; B; C] or vertcat(A, B, C).
% cat(2, A, B, C) is the same as [A, B, C] or horzcat(A, B, C).

function ret = cat(varargin)
    if nargin < 2
        disp('Invalid use of cat.  Correct usage is:')
        help cat
        retall
    end
    if nargin == 2
        ret = varargin{2};
        return
    else
        dim = varargin{1};
        if ~isscalar(dim)
            error('Dimension must be a scalar.')
        end
        if dim < 1
            error('Invalid dimension argument.')
        elseif dim == 1
            ret = vertcat(varargin{2:end});
        elseif dim == 2
            ret = horzcat(varargin{2:end});
        else % dim>=3
            for jj = 2:nargin
                if ~isempty(varargin{jj})
                    break
                end
            end
            ret = varargin{jj};
            if isempty(ret)
                % All input arrays are empty
                return
            end
            for ii = jj+1:nargin
                if isempty(varargin{ii})
                    continue
                end
                ret = hi_dim_cat2(varargin{1},ret,varargin{ii});
            end
        end
    end

function C = hi_dim_cat2(dim, A, B) 
    sizA = size(A);
    sizB = size(B);
    ndimA = numel(sizA);
    ndimB = numel(sizB);
    ndimC = max([dim, ndimA, ndimB]);
    sizA2 = ones(1,ndimC);
    sizB2 = ones(1,ndimC);
    sizA2(1:ndimA) = sizA;
    sizB2(1:ndimB) = sizB;
    
    % All size elements of A and B must be the same 
    % except can be possibly different at "dim" location
    if sizA2([1:dim-1,dim+1:ndimC]) ~= sizB2([1:dim-1,dim+1:ndimC])
        strdim = num2str(dim);
        strdims = num2str([1:dim-1,dim+1:ndimC]);
        error(['Concatenating in dimension ', strdim, ' requires size matching in all dimension(s) ', strdims ,'.'])
    else
        sizC = sizA2;
        sizC(dim) = sizA2(dim)+sizB2(dim);
        C = zeros(sizC);
        dA = cell(ndimC,1);
        for ii = 1:ndimC
            dA{ii} = 1:sizA2(ii);
        end
        dB = dA;
        dB{dim} = 1:sizB2(dim);
        dAC = dA;
        dBC = dB;
        dBC{dim} = sizA2(dim) + dBC{dim};
        C(dAC{:})  = A(dA{:});
        C(dBC{:})  = B(dB{:});
    end