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: 11, Time: 0.028 s)
Generated 28-Jun-2020 10:10:20 using performance time.
subfunction in file /Applications/MATLAB_R2018a.app/toolbox/matlab/ops/ismember.m
Copy to new window for comparing multiple runs

Parents (calling functions)

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

Line NumberCodeCallsTotal Time% TimeTime Plot
399
[uA,~,icA] = unique(a(:),'sort...
100.014 s49.4%
401
uB = unique(b(:),'sorted');
100.006 s20.7%
414
lia = ismemberBuiltinTypes(icA...
100.002 s6.5%
381
if isscalar(a) || isscalar(b)
110.001 s2.9%
407
[sortuAuB,IndSortuAuB] = sort(...
100.001 s2.9%
All other lines  0.005 s17.7%
Totals  0.028 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
uniquefunction200.018 s62.7%
ismember>ismemberBuiltinTypessubfunction100.001 s4.8%
Self time (built-ins, overhead, etc.)  0.009 s32.5%
Totals  0.028 s100% 
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 run25
Code lines that did not run23
Coverage (did run/can run)52.08 %
Function listing
time 
Calls 
 line
 373 
function [lia,locb] = ismemberClassTypes(a,b)
< 0.001 
     11 
 374
if issparse(a) 
 375 
    a = full(a);
 376 
end
< 0.001 
     11 
 377
if issparse(b) 
 378 
    b = full(b);
 379 
end
 380 
% Duplicates within the sets are eliminated
< 0.001 
     11 
 381
if isscalar(a) || isscalar(b) 
< 0.001 
      1 
 382
    ab = [a(:);b(:)]; 
< 0.001 
      1 
 383
    numa = numel(a); 
< 0.001 
      1 
 384
    lia = ab(1:numa)==ab(1+numa:end); 
< 0.001 
      1 
 385
    if ~any(lia) 
< 0.001 
      1 
 386
        lia  = false(size(a)); 
< 0.001 
      1 
 387
        locb = zeros(size(a)); 
< 0.001 
      1 
 388
        return 
 389 
    end
 390 
    if ~isscalar(b)
 391 
        locb = find(lia);
 392 
        locb = locb(1);
 393 
        lia = any(lia);
 394 
    else
 395 
        locb = double(lia);
 396 
    end
< 0.001 
     10 
 397
else 
 398 
    % Duplicates within the sets are eliminated
  0.014 
     10 
 399
    [uA,~,icA] = unique(a(:),'sorted'); 
< 0.001 
     10 
 400
    if nargout <= 1 
  0.006 
     10 
 401
        uB = unique(b(:),'sorted'); 
 402 
    else
 403 
        [uB,ib] = unique(b(:),'sorted');
< 0.001 
     10 
 404
    end 
 405 
    
 406 
    % Sort the unique elements of A and B, duplicate entries are adjacent
< 0.001 
     10 
 407
    [sortuAuB,IndSortuAuB] = sort([uA;uB]); 
 408 
    
 409 
    % Find matching entries
< 0.001 
     10 
 410
    d = sortuAuB(1:end-1)==sortuAuB(2:end);         % d indicates the indices matching entries 
< 0.001 
     10 
 411
    ndx1 = IndSortuAuB(d);                          % NDX1 are locations of repeats in C 
 412 
    
< 0.001 
     10 
 413
    if nargout <= 1 
  0.002 
     10 
 414
        lia = ismemberBuiltinTypes(icA,ndx1);       % Find repeats among original list 
 415 
    else
 416 
        szuA = size(uA,1);
 417 
        d = find(d);
 418 
        [lia,locb] = ismemberBuiltinTypes(icA,ndx1);% Find locb by using given indices
 419 
        newd = d(locb(lia));                        % NEWD is D for non-unique A
 420 
        where = ib(IndSortuAuB(newd+1)-szuA);       % Index values of uB through UNIQUE
 421 
        locb(lia) = where;                          % Return first or last occurrence of A within B
< 0.001 
     10 
 422
    end 
< 0.001 
     10 
 423
end 
< 0.001 
     10 
 424
lia = reshape(lia,size(a)); 
< 0.001 
     10 
 425
if nargout > 1 
 426 
    locb = reshape(locb,size(a));
 427 
end
< 0.001 
     10 
 428
end 

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