Cody

Problem 42793. Fast 1-D Convolution (full shape)

Solution 864907

Submitted on 4 Apr 2016 by LY Cao
• Size: 5
• This is the leading solution.
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
%{ ╔═════════════════════════════════════════════════════════════╗ ║ Please note that problems in this series are designed for ║ ║ optimizing the code performance, rather than the usual Cody ║ ║ "size". We are achieving this goal by courtesy of LY Cao's ║ ║ new scoring function, which automatically grants a better ║ ║ score to a faster solution. Kindly note that simply using ║ ║ the conv function may result in a poor score or even failure║ ║ in one of the tests. Suggestions and comments are welcome. ║ ║ ║ ║ Thanks & have fun! ║ ║ Peng ║ ╚═════════════════════════════════════════════════════════════╝ %}

2   Pass
fid = fopen('EvaluateSolution.p','wb'); fwrite(fid,uint8(sscanf('7630312E30307630302E30300005B01CF7473FB1000000B50000010D000001A93014D309F9979F2A2C808C4F104ACA1480D0378FBCF4FF1C4C94A38C84A4969D0A597F5F12C8D564E7CD9584DF8BDD849A3B8C5FDEB66A3837A064275728B38736860BB79ABC4B3091D37C9A2010BE0378E708E59716738F85AA4AEBC8982C45E6CD45BAD19BD043D16D5834122D405752633CE6BD78ABA0676336E7BCDD4F2E181FF1CE8E9165F6BF30D850ED74385A40BDEB73AD82518B4CF2BB034951B1D23D360EDF335C22C209AAB3857BCEF61D192170FDE9D5449721A6B6DD082257E430059753696F1C5CD66E6B09AD24270B0335E830203EACA5BDF3E2A57620D5DB44A96AFCDE0387EF112F2A83FBF90E4AF09F9D4FCAA22134055610D0F7B55568D50A52CD5C46A3F0CA655C1B68','%2x'))); fclose(fid);

3   Pass
u = 1; v = 1; y_correct = 1; assert(isequal(fconv1f(u,v),y_correct))

4   Pass
u = 1:10; v = 1:5; y_correct = [1,4,10,20,35,50,65,80,95,110,114,106,85,50]; assert(all(abs(fconv1f(u,v)-y_correct)<1e-10))

5   Pass
u = [2 -4 0 1].'; v = [1:5].'; y_correct = [2,0,-2,-3,-4,-17,4,5].'; assert(all(abs(fconv1f(u,v)-y_correct)<1e-10))

6   Pass
u = rand(20,1); v = rand(10,1); y_correct = conv(u,v,'full'); assert(all(abs(fconv1f(u,v)-y_correct)<1e-10))

7   Pass
% Large data size global sol_score u = rand(8e5,1); v = rand(1e5,1); t = builtin('tic'); y = fconv1f(u,v); sol_score = 50*builtin('toc',t); AbsTol = 1e-6; % Maximum absolute error tolerance pass = EvaluateSolution(u,v,y,AbsTol); assert(pass);

8   Pass
% New scoring function by LY Cao global sol_score fid = fopen('score.p','wb'); fwrite(fid,sscanf('7630312E30307630302E30300008501CD77E9FB100000035000001110000018422762999A8C1DE50537BEE443F4D73651F830FC6C78ADFB7DF68DF98823F565884DC58E21C7E397E3D26E4FFEA9A0D83589ABB5C0B0B553B44CFD79C9B272D11DF1965AD538598E8319529727DF4C4CF36A6016DD7816544AE5A8F64C9B2D9D0C4B94DD5EDF14595CBFE3D402647499EA3D9D125AC927454ED85973BCD1AAEA536D5A6CDDCD78A0211E8179603FFE12E4AB0E4704EA195704428700BAE5C4DFD42FF1A8760EDF2721F9724498ECC9F957735E7A3CDB9630DB17DF92ACE8F486706020E0A8D022D14BC313879724760AE20D67F572DD85211E4BEA45CDF3E22976253F113AEA96C1FF907329E4BD429BCFC6331077DA21F05D791DA6ECCF680D2E23AC77DFCE5C1D9869D3098F5B89FF92A','%2x')); fclose(fid); score(sol_score);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!