Cody

# Problem 1259. It's race time again! Write a function that is at least twice as fast as the test suite call of repmat().

Solution 507830

Submitted on 3 Oct 2014 by rifat
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
%% x = 1.7; m = 197; n = 535; tic y_correct = repmat(x, m, n); t_repmat = toc tic y_myrepmat = my_repmat(x, m, n); t_myrepmat = toc assert(isequal(y_myrepmat,y_correct) && t_myrepmat < t_repmat/2)

[Warning: Function repmat has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function clc has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function diary has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function license has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function mex has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function home has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function keyboard has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function more has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function pause has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function simulink has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] t_repmat = 2.0440 t_myrepmat = 8.5500e-04

2   Pass
%% x = -0.3; m = 1; n = 5350; tic y_correct = repmat(x, m, n); t_repmat = toc tic y_myrepmat = my_repmat(x, m, n); t_myrepmat = toc assert(isequal(y_myrepmat,y_correct) && t_myrepmat < t_repmat/2)

[Warning: Function repmat has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function clc has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function diary has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function license has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function mex has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function home has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function keyboard has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function more has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function pause has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function simulink has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] t_repmat = 2.0188 t_myrepmat = 8.6600e-04

3   Pass
%% x = 0; m = 14; n = 5350; tic y_correct = repmat(x, m, n); t_repmat = toc tic y_myrepmat = my_repmat(x, m, n); t_myrepmat = toc assert(isequal(y_myrepmat,y_correct) && t_myrepmat < t_repmat)

[Warning: Function repmat has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function clc has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function diary has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function license has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function mex has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function home has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function keyboard has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function more has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function pause has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] [Warning: Function simulink has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In repmat at 7 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] t_repmat = 2.0157 t_myrepmat = 8.8600e-04