This is a static copy of a profile report

Home

ismember>ismemberBuiltinTypes (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
ismember>ismemberR2012asubfunction9
Lines where the most time was spent
No measurable time spent in this function

Line NumberCodeCallsTotal Time% TimeTime Plot
347
end
90 s0%
265
end
90 s0%
264
lia(i) = any(a(i)==b(:));   % ...
90 s0%
263
for i=1:numelA
90 s0%
262
if nargout <= 1
90 s0%
All other lines  0 s0%
Totals  0 s0% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function111
Non-code lines (comments, blank lines)21
Code lines (lines that can run)90
Code lines that did run12
Code lines that did not run78
Coverage (did run/can run)13.33 %
Function listing
time 
calls 
 line
 237 
function [lia,locb] = ismemberBuiltinTypes(a,b)
 238 
% General handling.
 239 
% Use FIND method for very small sizes of the input vector to avoid SORT.
      9 
 240 
if nargout > 1 
 241 
    locb = zeros(size(a));
 242 
end
 243 
% Handle empty arrays and scalars.  
      9 
 244 
numelA = numel(a); 
      9 
 245 
numelB = numel(b); 
      9 
 246 
if numelA == 0 || numelB <= 1 
 247 
    if numelA > 0 && numelB == 1
 248 
        lia = (a == b);
 249 
        if nargout > 1
 250 
            % Use DOUBLE to convert logical "1" index to double "1" index.
 251 
            locb = double(lia);
 252 
        end
 253 
    else
 254 
        lia = false(size(a));
 255 
    end
 256 
    return
 257 
end
 258 

      9 
 259 
scalarcut = 5; 
      9 
 260 
if numelA <= scalarcut 
      9 
 261 
    lia = false(size(a)); 
      9 
 262 
    if nargout <= 1 
      9 
 263 
        for i=1:numelA 
      9 
 264 
            lia(i) = any(a(i)==b(:));   % ANY returns logical. 
      9 
 265 
        end 
 266 
    else
 267 
        for i=1:numelA
 268 
            found = a(i)==b(:);  % FIND returns indices for LOCB.
 269 
            if any(found)
 270 
                lia(i) = true;
 271 
                found = find(found);
 272 
                locb(i) = found(1);
 273 
            end
 274 
        end
 275 
    end
 276 
else
 277 
    % Use method which sorts list, then performs binary search.
 278 
    % Convert to full to work in C helper.
 279 
    if issparse(a)
 280 
        a = full(a);
 281 
    end
 282 
    if issparse(b)
 283 
        b = full(b);
 284 
    end
 285 
    
 286 
    if (isreal(b))
 287 
        % Find out whether list is presorted before sort
 288 
        % If the list is short enough, SORT will be faster than ISSORTED
 289 
        % If the list is longer, ISSORTED can potentially save time
 290 
        checksortcut = 1000;
 291 
        if numelB > checksortcut
 292 
            sortedlist = issorted(b(:));
 293 
        else
 294 
            sortedlist = 0;
 295 
        end
 296 
        if nargout > 1
 297 
            if ~sortedlist
 298 
                [b,idx] = sort(b(:));
 299 
            end
 300 
        elseif ~sortedlist
 301 
            b = sort(b(:));
 302 
        end
 303 
    else
 304 
        sortedlist = 0;
 305 
        [~,idx] = sort(real(b(:)));
 306 
        b = b(idx);
 307 
    end
 308 
    
 309 
    % Use builtin helper function ISMEMBERHELPER:
 310 
    % [LIA,LOCB] = ISMEMBERHELPER(A,B) Returns logical array LIA indicating
 311 
    % which elements of A occur in B and a double array LOCB with the
 312 
    % locations of the elements of A occuring in B. If multiple instances
 313 
    % occur, the first occurence is returned. B must be already sorted.
 314 
    
 315 
    if ~isobject(a) && ~isobject(b) && isnumeric(a)
 316 
        if (isnan(b(end)))
 317 
            % If NaNs detected, remove NaNs from B.
 318 
            b = b(~isnan(b(:)));
 319 
        end
 320 
        if nargout <= 1
 321 
            lia = builtin('_ismemberhelper',a,b);
 322 
        else
 323 
            [lia, locb] = builtin('_ismemberhelper',a,b);
 324 
        end
 325 
    else %(a,b, are some other class like gpuArray, syb object)
 326 
        lia = false(size(a));
 327 
        if nargout <= 1
 328 
            for i=1:numelA
 329 
                lia(i) = any(a(i)==b(:));   % ANY returns logical.
 330 
            end
 331 
        else
 332 
            for i=1:numelA
 333 
                found = a(i)==b(:); % FIND returns indices for LOCB.
 334 
                if any(found)
 335 
                    lia(i) = true;
 336 
                    found = find(found);
 337 
                    locb(i) = found(1);
 338 
                end
 339 
            end
 340 
        end
 341 
    end
 342 
    if nargout > 1 && ~sortedlist
 343 
        % Re-reference locb to original list if it was unsorted
 344 
        locb(lia) = idx(locb(lia));
 345 
    end
 346 
end
      9 
 347 
end 

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