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.