From: Josep i T. <jm...@pu...> - 2004-08-10 22:18:18
|
Hello! I attach another version of padarray.m which indexes A smartly to produce directly the padded array (trick suggested by Paul) and which improves speed on circular, replicate and symmetric paddings. I've left padding with scalar values as it was in the second version because, although in my intel box that was slower, as Paul sent yesterday, that probably makes a real difference on MacOs X. Note that tests in file only test 2D arrays and, although if tried some 3D arrays, I haven't tested exhaustively if results are correct on high-dimensional arrays. So, the times are now: octave:2> A=ones(30,30,30,30); tic; for i=1:10; B=padarray(A,[2,2,2,2]); endfor; toc ans = 32.460 octave:3> A=ones(30,30,30,30); tic; for i=1:10; B=padarray(A,[2,2,2,2],10); endfor; toc ans = 35.358 octave:4> A=ones(30,30,30,30); tic; for i=1:10; B=padarray(A,[2,2,2,2],'circular'); endfor; toc ans = 53.527 octave:5> A=ones(30,30,30,30); tic; for i=1:10; B=padarray(A,[2,2,2,2],'replicate'); endfor; toc ans = 53.589 octave:6> A=ones(30,30,30,30); tic; for i=1:10; B=padarray(A,[2,2,2,2],'symmetric'); endfor; toc ans = 53.358 Yes... yes... my P2 is veeery slow :) -- Josep Monés i Teixidor Clau GnuPG: gpg --recv-keys 80E85CC4 |