This is a static copy of a profile report

Home

repmat (Calls: 156, Time: 0.012 s)
Generated 16-Jul-2020 17:09:30 using performance time.
function in file /Applications/MATLAB_R2020a.app/toolbox/matlab/elmat/+matlab/+internal/+builtinhelper/repmat.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
printing/private/adjustbackgroundfunction156
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
65
B = A(ones(siz(1), 1), :);
1440.002 s19.6%
53
siz(idx) = double(full(checkSi...
3120.002 s17.0%
49
siz = zeros(1,nargin-1);
1560.002 s13.9%
61
B = A(ones(siz,'int8'));
120.001 s6.6%
57
end
3120.001 s5.4%
All other lines  0.005 s37.5%
Totals  0.012 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
repmat>checkSizesTypesubfunction3120.001 s8.7%
Self time (built-ins, overhead, etc.)  0.011 s91.3%
Totals  0.012 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function85
Non-code lines (comments, blank lines)35
Code lines (lines that can run)50
Code lines that did run19
Code lines that did not run31
Coverage (did run/can run)38.00 %
Function listing
time 
Calls 
 line
   1 
function B = repmat(A,varargin)
   2 
%REPMAT Replicate and tile an array.
   3 
%   B = repmat(A,M,N) creates a large matrix B consisting of an M-by-N
   4 
%   tiling of copies of A. The size of B is [size(A,1)*M, size(A,2)*N].
   5 
%   The statement repmat(A,N) creates an N-by-N tiling.
   6 
%
   7 
%   B = REPMAT(A,[M N]) accomplishes the same result as repmat(A,M,N).
   8 
%
   9 
%   B = REPMAT(A,[M N P ...]) tiles the array A to produce a
  10 
%   multidimensional array B composed of copies of A. The size of B is
  11 
%   [size(A,1)*M, size(A,2)*N, size(A,3)*P, ...].
  12 
%
  13 
%   REPMAT(A,M,N) when A is a scalar is commonly used to produce an M-by-N
  14 
%   matrix filled with A's value and having A's CLASS. For certain values,
  15 
%   you may achieve the same results using other functions. Namely,
  16 
%      REPMAT(NAN,M,N)           is the same as   NAN(M,N)
  17 
%      REPMAT(SINGLE(INF),M,N)   is the same as   INF(M,N,'single')
  18 
%      REPMAT(INT8(0),M,N)       is the same as   ZEROS(M,N,'int8')
  19 
%      REPMAT(UINT32(1),M,N)     is the same as   ONES(M,N,'uint32')
  20 
%      REPMAT(EPS,M,N)           is the same as   EPS(ONES(M,N))
  21 
%
  22 
%   Example:
  23 
%       repmat(magic(2), 2, 3)
  24 
%       repmat(uint8(5), 2, 3)
  25 
%
  26 
%   Class support for input A:
  27 
%      float: double, single
  28 
%      integer: uint8, int8, uint16, int16, uint32, int32, uint64, int64
  29 
%      char, logical
  30 
%
  31 
%   See also BSXFUN, MESHGRID, ONES, ZEROS, NAN, INF.
  32 

  33 
%   Copyright 1984-2019 The MathWorks, Inc.
  34 

< 0.001 
    156 
  35
if nargin < 2 
  36 
    error(message('MATLAB:minrhs'))
< 0.001 
    156 
  37
elseif nargin == 2 
  38 
    M = varargin{1};
  39 
    checkSizesType(M);
  40 
    if isscalar(M)
  41 
        siz = [M M];
  42 
    elseif ~isempty(M) && isrow(M)
  43 
        siz = M;
  44 
    else
  45 
        error(message('MATLAB:repmat:invalidReplications'));
  46 
    end
  47 
    siz = double(full(siz));
< 0.001 
    156 
  48
else % nargin > 2 
  0.002 
    156 
  49
    siz = zeros(1,nargin-1); 
< 0.001 
    156 
  50
    for idx = 1:nargin-1 
< 0.001 
    312 
  51
        arg = varargin{idx}; 
< 0.001 
    312 
  52
        if isscalar(arg) 
  0.002 
    312 
  53
            siz(idx) = double(full(checkSizesType(arg))); 
  54 
        else
  55 
            error(message('MATLAB:repmat:invalidReplications'));
< 0.001 
    312 
  56
        end 
< 0.001 
    312 
  57
    end 
< 0.001 
    156 
  58
end 
  59 

< 0.001 
    156 
  60
if isscalar(A) && ~isobject(A) 
< 0.001 
     12 
  61
    B = A(ones(siz,'int8')); 
< 0.001 
    144 
  62
elseif ismatrix(A) && numel(siz) == 2 
< 0.001 
    144 
  63
    [m,n] = size(A); 
< 0.001 
    144 
  64
    if (m == 1 && siz(2) == 1) 
  0.002 
    144 
  65
        B = A(ones(siz(1), 1), :); 
  66 
    elseif (n == 1 && siz(1) == 1)
  67 
        B = A(:, ones(siz(2), 1));
  68 
    else
  69 
        mind = (1:m)';
  70 
        nind = (1:n)';
  71 
        mind = mind(:,ones(1,siz(1)));
  72 
        nind = nind(:,ones(1,siz(2)));
  73 
        B = A(mind,nind);
< 0.001 
    144 
  74
    end 
  75 
else
  76 
    Asiz = size(A);
  77 
    Asiz = [Asiz ones(1,length(siz)-length(Asiz))];
  78 
    siz = [siz ones(1,length(Asiz)-length(siz))];
  79 
    subs = cell(1,length(Asiz));
  80 
    for i=length(Asiz):-1:1
  81 
        ind = (1:Asiz(i))';
  82 
        subs{i} = ind(:,ones(1,siz(i)));
  83 
    end
  84 
    B = A(subs{:});
< 0.001 
    156 
  85
end 

Other subfunctions in this file are not included in this listing.