This is a static copy of a profile report

Home

Function details for ismember>ismemberClassTypesThis is a static copy of a profile report

Home

ismember>ismemberClassTypes (Calls: 760, Time: 0.063 s)
Generated 28-Jul-2019 18:14:01 using performance time.
subfunction in file C:\Program Files\MATLAB\R2019a\toolbox\matlab\ops\ismember.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
ismember>ismemberR2012asubfunction760
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
407
ab = [a(:);b(:)];
7600.017 s27.7%
409
lia = ab(1:numa)==ab(1+numa:en...
7600.016 s25.8%
449
lia = reshape(lia,size(a));
7600.007 s11.1%
416
locb = find(lia);
7600.005 s8.0%
406
if isscalar(a) || isscalar(b)
7600.003 s4.4%
All other lines  0.014 s23.1%
Totals  0.063 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function56
Non-code lines (comments, blank lines)8
Code lines (lines that can run)48
Code lines that did run16
Code lines that did not run32
Coverage (did run/can run)33.33 %
Function listing
time 
Calls 
 line
 398 
function [lia,locb] = ismemberClassTypes(a,b)
< 0.001 
    760 
 399
if issparse(a) 
 400 
    a = full(a);
 401 
end
< 0.001 
    760 
 402
if issparse(b) 
 403 
    b = full(b);
 404 
end
 405 
% Duplicates within the sets are eliminated
  0.003 
    760 
 406
if isscalar(a) || isscalar(b) 
  0.017 
    760 
 407
    ab = [a(:);b(:)]; 
  0.002 
    760 
 408
    numa = numel(a); 
  0.016 
    760 
 409
    lia = ab(1:numa)==ab(1+numa:end); 
< 0.001 
    760 
 410
    if ~any(lia) 
 411 
        lia  = false(size(a));
 412 
        locb = zeros(size(a));
 413 
        return
 414 
    end
  0.002 
    760 
 415
    if ~isscalar(b) 
  0.005 
    760 
 416
        locb = find(lia); 
< 0.001 
    760 
 417
        locb = locb(1); 
< 0.001 
    760 
 418
        lia = any(lia); 
 419 
    else
 420 
        locb = double(lia);
< 0.001 
    760 
 421
    end 
 422 
else
 423 
    % Duplicates within the sets are eliminated
 424 
    [uA,~,icA] = unique(a(:),'sorted');
 425 
    if nargout <= 1
 426 
        uB = unique(b(:),'sorted');
 427 
    else
 428 
        [uB,ib] = unique(b(:),'sorted');
 429 
    end
 430 
    
 431 
    % Sort the unique elements of A and B, duplicate entries are adjacent
 432 
    [sortuAuB,IndSortuAuB] = sort([uA;uB]);
 433 
    
 434 
    % Find matching entries
 435 
    d = sortuAuB(1:end-1)==sortuAuB(2:end);         % d indicates the indices matching entries
 436 
    ndx1 = IndSortuAuB(d);                          % NDX1 are locations of repeats in C
 437 
    
 438 
    if nargout <= 1
 439 
        lia = ismemberBuiltinTypes(icA,ndx1);       % Find repeats among original list
 440 
    else
 441 
        szuA = size(uA,1);
 442 
        d = find(d);
 443 
        [lia,locb] = ismemberBuiltinTypes(icA,ndx1);% Find locb by using given indices
 444 
        newd = d(locb(lia));                        % NEWD is D for non-unique A
 445 
        where = ib(IndSortuAuB(newd+1)-szuA);       % Index values of uB through UNIQUE
 446 
        locb(lia) = where;                          % Return first or last occurrence of A within B
 447 
    end
< 0.001 
    760 
 448
end 
  0.007 
    760 
 449
lia = reshape(lia,size(a)); 
< 0.001 
    760 
 450
if nargout > 1 
 451 
    locb = reshape(locb,size(a));
 452 
end
  0.002 
    760 
 453
end 

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