Problem 958. ismember: Enhanced Performance for 'rows' and width - Speed Scoring (66% savings)

Solution 2525409

Submitted on 12 Jun 2020 by Can Tekin
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass

2   Pass
% Functionality Tests L=128; a=randi(4,L,48,'uint8')-1; b=randi(4,L,48,'uint8')-1; assert(isequal(ismember(a,b,'rows'),ismember_fast_rows(a,b))) b=a; assert(isequal(ismember(a,b,'rows'),ismember_fast_rows(a,b))) L=256; a=randi(4,L,48,'uint8')-1; b=randi(4,L,48,'uint8')-1; a(16:32,:)=b(32:48,:); assert(isequal(ismember(a,b,'rows'),ismember_fast_rows(a,b)))

3   Pass
% 2M has a crash for 2x ismember L=1900000; % ismember 19.6 fast C 8.3 2M tic a=randi(4,L,48,'uint8')-1; b=randi(4,L,48,'uint8')-1; a(100:200,:)=b(400:500,:); % Put in some matching data toc ta=clock; idx = ismember_fast_rows(a,b); t1=etime(clock,ta)*1000; fprintf('Elapsed time = %.0f msec\n',t1) assert(isequal(ismember(a,b,'rows'),idx)) t2=min(20000,t1); % ismember 1.9M x 48 scores 19000 msec feval(@assignin,'caller','score',floor(t2));

Elapsed time is 2.765538 seconds. Elapsed time = 5172 msec