This is a static copy of a profile report

Home

ismember>ismemberR2012a (9 calls, 0.000 sec)
Generated 14-Nov-2016 07:47:24 using cpu time.
subfunction in file /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/matlab/ops/ismember.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
ismemberfunction9
Lines where the most time was spent
No measurable time spent in this function

Line NumberCodeCallsTotal Time% TimeTime Plot
235
end
90 s0%
159
end
90 s0%
158
lia = ismemberBuiltinTypes(a,b...
90 s0%
157
else
90 s0%
155
if nargout > 1
90 s0%
All other lines  0 s0%
Totals  0 s0% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
ismember>ismemberBuiltinTypessubfunction90 s0%
Self time (built-ins, overhead, etc.)  0 s0%
Totals  0 s0% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function112
Non-code lines (comments, blank lines)25
Code lines (lines that can run)87
Code lines that did run13
Code lines that did not run74
Coverage (did run/can run)14.94 %
Function listing
time 
calls 
 line
 124 
function [lia,locb] = ismemberR2012a(a,b,options)
 125 
% 'R2012a' flag implementation
 126 

 127 
% Error check flag
      9 
 128 
if nargin == 2 
      9 
 129 
    byrow = false; 
 130 
else
 131 
    byrow = options > 0;
 132 
end
 133 

      9 
 134 
doBuiltinTypes = true; 
 135 
% Check that one of A and B is double if A and B are non-homogeneous. Do a
 136 
% separate check if A is a heterogeneous object and only allow a B
 137 
% that is of the same root class.
      9 
 138 
if ~(isa(a,'handle.handle') || isa(b,'handle.handle')) 
      9 
 139 
    if ~strcmpi(class(a),class(b)) 
 140 
        if isa(a,'matlab.mixin.Heterogeneous') && isa(b,'matlab.mixin.Heterogeneous')
 141 
            rootClassA = meta.internal.findHeterogeneousRootClass(a);
 142 
            if isempty(rootClassA) || ~isa(b,rootClassA.Name)
 143 
                error(message('MATLAB:ISMEMBER:InvalidInputsDataType',class(a),class(b)));
 144 
            end
 145 
            doBuiltinTypes = false;
 146 
        elseif ~(strcmpi(class(a),'double') || strcmpi(class(b),'double'))
 147 
            error(message('MATLAB:ISMEMBER:InvalidInputsDataType',class(a),class(b)));
 148 
        end
 149 
    end
      9 
 150 
end 
 151 

      9 
 152 
if ~byrow 
      9 
 153 
    if ~(isa(a,'opaque') || isa(b,'opaque')) && doBuiltinTypes 
 154 
        % Builtin types
      9 
 155 
        if nargout > 1 
 156 
            [lia,locb] = ismemberBuiltinTypes(a,b);
      9 
 157 
        else 
      9 
 158 
            lia = ismemberBuiltinTypes(a,b); 
      9 
 159 
        end 
 160 
    else
 161 
        % Handle objects
 162 
        if nargout > 1
 163 
            [lia,locb] = ismemberClassTypes(a,b);
 164 
        else
 165 
            lia = ismemberClassTypes(a,b);
 166 
        end
 167 
    end
 168 
else    % 'rows' case
 169 
    if ~(ismatrix(a) && ismatrix(b))
 170 
        error(message('MATLAB:ISMEMBER:NotAMatrix'));
 171 
    end
 172 
    
 173 
    [rowsA,colsA] = size(a);
 174 
    [rowsB,colsB] = size(b);
 175 
    
 176 
    % Automatically pad strings with spaces
 177 
    if ischar(a) && ischar(b),
 178 
        b = [b repmat(' ',rowsB,colsA-colsB)];
 179 
        a = [a repmat(' ',rowsA,colsB-colsA)];
 180 
    elseif colsA ~= colsB
 181 
        error(message('MATLAB:ISMEMBER:AandBColnumAgree'));
 182 
    end
 183 
    
 184 
    % Empty check for 'rows'.
 185 
    if rowsA == 0 || rowsB == 0
 186 
        lia = false(rowsA,1);
 187 
        locb = zeros(rowsA,1);
 188 
        return
 189 
    end
 190 
    
 191 
    % General handling for 'rows'.
 192 
    
 193 
    % Duplicates within the sets are eliminated
 194 
    if (rowsA == 1)
 195 
        uA = repmat(a,rowsB,1);
 196 
        d = uA(1:end,:)==b(1:end,:);
 197 
        d = all(d,2);
 198 
        lia = any(d);
 199 
        if nargout > 1
 200 
            if lia
 201 
                locb = find(d, 1, 'first');
 202 
            else
 203 
                locb = 0;
 204 
            end
 205 
        end
 206 
        return;
 207 
    else
 208 
        [uA,~,icA] = unique(a,'rows','sorted');
 209 
    end
 210 
    if nargout <= 1
 211 
        uB = unique(b,'rows','sorted');
 212 
    else
 213 
        [uB,ib] = unique(b,'rows','sorted');
 214 
    end
 215 
    
 216 
    % Sort the unique elements of A and B, duplicate entries are adjacent
 217 
    [sortuAuB,IndSortuAuB] = sortrows([uA;uB]);
 218 
    
 219 
    % Find matching entries
 220 
    d = sortuAuB(1:end-1,:)==sortuAuB(2:end,:);     % d indicates matching entries
 221 
    d = all(d,2);                                   % Finds the index of matching entries
 222 
    ndx1 = IndSortuAuB(d);                          % NDX1 are locations of repeats in C
 223 
    
 224 
    if nargout <= 1
 225 
        lia = ismemberBuiltinTypes(icA,ndx1);           % Find repeats among original list
 226 
    else
 227 
        szuA = size(uA,1);
 228 
        [lia,locb] = ismemberBuiltinTypes(icA,ndx1);    % Find locb by using given indices
 229 
        d = find(d);
 230 
        newd = d(locb(lia));                    % NEWD is D for non-unique A
 231 
        where = ib(IndSortuAuB(newd+1)-szuA);   % Index values of uB through UNIQUE
 232 
        locb(lia) = where;                      % Return first or last occurrence of A within B
 233 
    end
 234 
end
      9 
 235 
end 

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