This is a static copy of a profile report

Home

ismember>ismemberClassTypes (Calls: 2, Time: 0.004 s)
Generated 18-May-2021 16:05:25 using performance time.
subfunction in file /usr/local/MATLAB/R2021a/toolbox/matlab/ops/ismember.m
Copy to new window for comparing multiple runs

Parents (calling functions)

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

Line NumberCodeCallsTotal Time% TimeTime Plot
421
if any(size(a)==numel(a)) &...
20.001 s18.1%
472
lia = reshape(lia,size(a));
20.001 s16.2%
414
if isempty(a)||isempty(b)
20.000 s9.4%
419
if isscalar(a) || isscalar(b)
20.000 s7.6%
444
end
20.000 s5.8%
All other lines  0.002 s42.9%
Totals  0.004 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function71
Non-code lines (comments, blank lines)10
Code lines (lines that can run)61
Code lines that did run24
Code lines that did not run37
Coverage (did run/can run)39.34 %
Function listing
time 
Calls 
 line
 406 
function [lia,locb] = ismemberClassTypes(a,b)
< 0.001 
      2 
 407
if issparse(a) 
 408 
    a = full(a);
      2 
 409
end 
      2 
 410
if issparse(b) 
 411 
    b = full(b);
      2 
 412
end 
 413 
% Duplicates within the sets are eliminated
< 0.001 
      2 
 414
if isempty(a)||isempty(b) 
 415 
    lia = false(size(a));
 416 
    locb = zeros(size(a));
 417 
    return
      2 
 418
end 
< 0.001 
      2 
 419
if isscalar(a) || isscalar(b) 
< 0.001 
      2 
 420
    if strcmp(class(a),class(b)) 
< 0.001 
      2 
 421
        if any(size(a)==numel(a)) && any(size(b)==numel(b)) 
 422 
            % a and b do not need to be reshaped if they are n-dimensional
 423 
            % vectors
< 0.001 
      2 
 424
            lia = a==b; 
 425 
        else
 426 
            lia = a(:)==b(:);
< 0.001 
      2 
 427
        end 
 428 
    else
 429 
        ab = [a(:);b(:)];
 430 
        numa = numel(a);
 431 
        lia = ab(1:numa)==ab(1+numa:end);
< 0.001 
      2 
 432
    end 
< 0.001 
      2 
 433
    if ~any(lia) 
 434 
        lia  = false(size(a));
 435 
        locb = zeros(size(a));
 436 
        return
< 0.001 
      2 
 437
    end 
< 0.001 
      2 
 438
    if ~isscalar(b) 
< 0.001 
      2 
 439
        locb = find(lia); 
< 0.001 
      2 
 440
        locb = locb(1); 
< 0.001 
      2 
 441
        lia = any(lia); 
 442 
    else
 443 
        locb = double(lia);
< 0.001 
      2 
 444
    end 
 445 
else
 446 
    % Duplicates within the sets are eliminated
 447 
    [uA,~,icA] = unique(a(:),'sorted');
 448 
    if nargout <= 1
 449 
        uB = unique(b(:),'sorted');
 450 
    else
 451 
        [uB,ib] = unique(b(:),'sorted');
 452 
    end
 453 
    
 454 
    % Sort the unique elements of A and B, duplicate entries are adjacent
 455 
    [sortuAuB,IndSortuAuB] = sort([uA;uB]);
 456 
    
 457 
    % Find matching entries
 458 
    d = sortuAuB(1:end-1)==sortuAuB(2:end);         % d indicates the indices matching entries
 459 
    ndx1 = IndSortuAuB(d);                          % NDX1 are locations of repeats in C
 460 
    
 461 
    if nargout <= 1
 462 
        lia = ismemberBuiltinTypes(icA,ndx1);       % Find repeats among original list
 463 
    else
 464 
        szuA = size(uA,1);
 465 
        d = find(d);
 466 
        [lia,locb] = ismemberBuiltinTypes(icA,ndx1);% Find locb by using given indices
 467 
        newd = d(locb(lia));                        % NEWD is D for non-unique A
 468 
        where = ib(IndSortuAuB(newd+1)-szuA);       % Index values of uB through UNIQUE
 469 
        locb(lia) = where;                          % Return first or last occurrence of A within B
 470 
    end
< 0.001 
      2 
 471
end 
< 0.001 
      2 
 472
lia = reshape(lia,size(a)); 
< 0.001 
      2 
 473
if nargout > 1 
 474 
    locb = reshape(locb,size(a));
      2 
 475
end 
< 0.001 
      2 
 476
end 

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