Problem 904. Unique: Faster 'rows' for large array of uint8
Challenge: Execute unique(a,'rows') Faster for 'a' being uint8.
The "unique" function for the 'rows' options may be performed 10X more quickly for arrays of large rows, few columns, and of type uint8 (or values <256).
Input: c=randi(4,6000000,16,'uint8')-1;
Output: unique(c,'rows') or equivalent
Scoring: Time in milli-seconds
Hints:
- unique can sort a single column >10X faster than an array of rows
- 10X improvement is applicable to arrays where rows can be represented as a uint32 value
- 5X improvement occurs where arrays require uint64 representation
Solution Stats
Problem Comments
-
1 Comment
If your purpose is to compare the efficiency, I recommend you to use tic/toc or timeit instead of clock/etime. The clock function measures the operating system time which is less reliable as compared to tic/toc measurements.
Solution Comments
Show commentsProblem Recent Solvers22
Suggested Problems
-
Return the largest number that is adjacent to a zero
5343 Solvers
-
Selecting books on MATLAB for experts and beginners (blindfolded)
75 Solvers
-
Vectorizing, too easy or too hard?
144 Solvers
-
Convert from Base 10 to base 5
259 Solvers
-
58 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!