Cody

# Problem 955. ismember: Enhanced Time Performance for 'rows' - Speed Scoring (90% savings)

Solution 480393

Submitted on 30 Jul 2014 by rifat ahmed
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
%% feval(@assignin,'caller','score',40000);

``` ```

2   Pass
%% % Functionality Tests L=128; a=randi(4,L,16,'uint8')-1; b=randi(4,L,16,'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,16,'uint8')-1; b=randi(4,L,16,'uint8')-1; a(16:32,:)=b(32:48,:); assert(isequal(ismember(a,b,'rows'),ismember_fast_rows(a,b)))

``` ```

3   Pass
%% L=4000000; % ismember 40 fast 5.2 % 34 sec 4M tic a=randi(4,L,16,'uint8')-1; b=randi(4,L,16,'uint8')-1; 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(40000,t1); % ismember scores 40000 msec feval(@assignin,'caller','score',floor(t2));

```Elapsed time is 2.666968 seconds. Elapsed time = 21095 msec ```