The Challenge is to modify repmat.m to maintain all of its normal functionality and enhance its performance for large row replication for both N=1 and N>1 cases, B=repmat(A,M,N). The size of A for enhancement cases is [1,n].
For cases of M> 12,288,000 and n<128 or N*n<256 it is possible to perform an enhanced repmat in 40% of the time of repmat. The standard repmat takes 150% longer than repmatLV in certain cases on Cody (2.5 sec / 1 sec).
Input: [A,M,N] standard input for repmat
Output: B, Array of size [M*m,N*n] where [m,n]=size(A)
Score: Performance is based upon time(msec) to execute four large row replications
Test Cases include normal arrays for which the function must still maintain repmat capability and also the large test cases:
I suggest replicating repmat.m to a local folder and name it repmatLV.m. Create a shell that calls repmatLV as if it was repmat. Implement calls of the stressing test cases from the shell. Use the Profiler Tool to analyze where time is being consumed and devise alternative speed enhancements.
Note: The above cases assume a 3GB system or better. Reduce M as necessary.
The overall goal of this challenge is to show that matlab built-in functions are excellent resources for methods, optimization of functions is possible depending on individual needs, and profiling is fun.
A follow-up Challenge will demonstrate an optimization of ismember, for the 'sortrows' option with many rows, when both arrays have many rows vs columns and have low commonality(< 10%). Processing time can be reduced by more than 90% for these large row dominant arrays compared to the standard ismember time.