This is a static copy of a profile report

Home

Function details for blkdiagThis is a static copy of a profile report

Home

blkdiag (Calls: 18254, Time: 37.858 s)
Generated 20-Jul-2018 02:24:57 using performance time.
function in file C:\Program Files\MATLAB\R2018a\toolbox\matlab\elmat\blkdiag.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
kron_groups_simplefunction4063
qap_admm_blkdiagfunction2
run_admmfunction14189
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
45
y(p1(k)+1:p1(k+1),m1(k)+1:m1(k...
280942825.650 s67.8%
34
if any(cellfun(@issparse,varar...
182545.275 s13.9%
38
[p2,m2] = cellfun(@size,vararg...
141924.614 s12.2%
43
y = zeros(p1(end),m1(end),outc...
141920.604 s1.6%
20
any(~cellfun('isclass',varargi...
182540.371 s1.0%
All other lines  1.342 s3.5%
Totals  37.858 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
elmat\private\blkdiagmexfunction40620.173 s0.5%
Self time (built-ins, overhead, etc.)  37.685 s99.5%
Totals  37.858 s100% 
Code Analyzer results
Line numberMessage
34Extra semicolon is unnecessary in IF statement before newline.
Coverage results
Show coverage for parent directory
Total lines in function47
Non-code lines (comments, blank lines)20
Code lines (lines that can run)27
Code lines that did run16
Code lines that did not run11
Coverage (did run/can run)59.26 %
Function listing
time 
Calls 
 line
   1 
function y = blkdiag(varargin)
   2 
%BLKDIAG  Block diagonal concatenation of matrix input arguments.
   3 
%
   4 
%                                   |A 0 .. 0|
   5 
%   Y = BLKDIAG(A,B,...)  produces  |0 B .. 0|
   6 
%                                   |0 0 ..  |
   7 
%
   8 
%   Class support for inputs:
   9 
%      float: double, single
  10 
%      integer: uint8, int8, uint16, int16, uint32, int32, uint64, int64
  11 
%      char, logical
  12 
%
  13 
%   See also DIAG, HORZCAT, VERTCAT
  14 

  15 
% Copyright 1984-2013 The MathWorks, Inc.
  16 

  0.005 
  18254 
  17
if nargin > 0 
  0.362 
  18254 
  18
    outclass = class(varargin{1}); 
  0.390 
  18254 
  19
    if isobject(varargin{1}) || ~isnumeric(varargin{1}) || ... 
  18254 
  20
            any(~cellfun('isclass',varargin,outclass)) 
  21 
        y = [];
  22 
        for k=1:nargin
  23 
            x = varargin{k};
  24 
            [p1,m1] = size(y); 
  25 
            [p2,m2] = size(x);
  26 
            y = [y zeros(p1,m2); zeros(p2,m1) x]; %#ok
  27 
        end
  28 
        return
  29 
    end
  30 
else
  31 
   outclass = 'double';  
  0.001 
  18254 
  32
end 
  33 

  5.275 
  18254 
  34
if any(cellfun(@issparse,varargin)); 
  35 
    % optimized MEX implementation for sparse double
  0.214 
   4062 
  36
    y = blkdiagmex(varargin{:}); 
  0.001 
  14192 
  37
else 
  4.614 
  14192 
  38
    [p2,m2] = cellfun(@size,varargin); 
  39 
    %Precompute cumulative matrix sizes
  0.192 
  14192 
  40
    p1 = [0, cumsum(p2)]; 
  0.049 
  14192 
  41
    m1 = [0, cumsum(m2)]; 
  42 
    
  0.604 
  14192 
  43
    y = zeros(p1(end),m1(end),outclass); %Preallocate 
  0.005 
  14192 
  44
    for k=1:nargin 
 25.650 
2809428 
  45
        y(p1(k)+1:p1(k+1),m1(k)+1:m1(k+1)) = varargin{k}; 
  0.132 
2809428 
  46
    end 
  0.181 
  18254 
  47
end 

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