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