time | Calls | line |
---|
| | 406 | function [lia,locb] = ismemberClassTypes(a,b)
|
< 0.001 | 170 | 407 | if issparse(a)
|
| | 408 | a = full(a);
|
< 0.001 | 170 | 409 | end
|
< 0.001 | 170 | 410 | if issparse(b)
|
| | 411 | b = full(b);
|
< 0.001 | 170 | 412 | end
|
| | 413 | % Duplicates within the sets are eliminated
|
0.003 | 170 | 414 | if isscalar(a) || isscalar(b)
|
0.005 | 62 | 415 | ab = [a(:);b(:)];
|
< 0.001 | 62 | 416 | numa = numel(a);
|
0.006 | 62 | 417 | lia = ab(1:numa)==ab(1+numa:end);
|
< 0.001 | 62 | 418 | if ~any(lia)
|
< 0.001 | 16 | 419 | lia = false(size(a));
|
< 0.001 | 16 | 420 | locb = zeros(size(a));
|
< 0.001 | 16 | 421 | return
|
< 0.001 | 46 | 422 | end
|
0.001 | 46 | 423 | if ~isscalar(b)
|
< 0.001 | 46 | 424 | locb = find(lia);
|
< 0.001 | 46 | 425 | locb = locb(1);
|
< 0.001 | 46 | 426 | lia = any(lia);
|
| | 427 | else
|
| | 428 | locb = double(lia);
|
< 0.001 | 46 | 429 | end
|
< 0.001 | 108 | 430 | else
|
| | 431 | % Duplicates within the sets are eliminated
|
0.038 | 108 | 432 | [uA,~,icA] = unique(a(:),'sorted');
|
< 0.001 | 108 | 433 | if nargout <= 1
|
0.023 | 108 | 434 | uB = unique(b(:),'sorted');
|
| | 435 | else
|
| | 436 | [uB,ib] = unique(b(:),'sorted');
|
< 0.001 | 108 | 437 | end
|
| | 438 |
|
| | 439 | % Sort the unique elements of A and B, duplicate entries are adjacent
|
0.006 | 108 | 440 | [sortuAuB,IndSortuAuB] = sort([uA;uB]);
|
| | 441 |
|
| | 442 | % Find matching entries
|
0.004 | 108 | 443 | d = sortuAuB(1:end-1)==sortuAuB(2:end); % d indicates the indices matching entries
|
< 0.001 | 108 | 444 | ndx1 = IndSortuAuB(d); % NDX1 are locations of repeats in C
|
| | 445 |
|
< 0.001 | 108 | 446 | if nargout <= 1
|
0.003 | 108 | 447 | lia = ismemberBuiltinTypes(icA,ndx1); % Find repeats among original list
|
| | 448 | else
|
| | 449 | szuA = size(uA,1);
|
| | 450 | d = find(d);
|
| | 451 | [lia,locb] = ismemberBuiltinTypes(icA,ndx1);% Find locb by using given indices
|
| | 452 | newd = d(locb(lia)); % NEWD is D for non-unique A
|
| | 453 | where = ib(IndSortuAuB(newd+1)-szuA); % Index values of uB through UNIQUE
|
| | 454 | locb(lia) = where; % Return first or last occurrence of A within B
|
< 0.001 | 108 | 455 | end
|
< 0.001 | 154 | 456 | end
|
0.001 | 154 | 457 | lia = reshape(lia,size(a));
|
< 0.001 | 154 | 458 | if nargout > 1
|
| | 459 | locb = reshape(locb,size(a));
|
< 0.001 | 154 | 460 | end
|
0.001 | 154 | 461 | end
|
Other subfunctions in this file are not included in this listing.