From: Josep i T. <jm...@pu...> - 2004-08-10 02:30:40
|
Hello! I've tried to recode padarray.m to preallocate array and then assign padding values instead of using cat everywhere expecting a speed improvement. The recoded version is attached. The results of the tests below (using a 4D test array) show that original version is quicker. I didn't expect that at all, can anybody have a look at the attached code to see if there's something very wrong that could be slowing thing down? Or perhaps cat is quick? Thanks ----->%------------>%-------- Using NEW padarray.m: octave:1> A=3Dones(30,30,30,30); t=3Dtime(); for i=3D1:10; B=3Dpadarray(A,[2,2,2,2]); endfor; time()-t ans =3D 32.391 octave:2> A=3Dones(30,30,30,30); t=3Dtime(); for i=3D1:10; B=3Dpadarray(A,[2,2,2,2],10); endfor; time()-t ans =3D 34.200 octave:3> A=3Dones(30,30,30,30); t=3Dtime(); for i=3D1:10; B=3Dpadarray(A,[2,2,2,2],'circular'); endfor; time()-t ans =3D 74.152 octave:4> A=3Dones(30,30,30,30); t=3Dtime(); for i=3D1:10; B=3Dpadarray(A,[2,2,2,2],'replicate'); endfor; time()-t ans =3D 73.749 octave:5> A=3Dones(30,30,30,30); t=3Dtime(); for i=3D1:10; B=3Dpadarray(A,[2,2,2,2],'symmetric'); endfor; time()-t ans =3D 74.707 Using OLD pararray.m: octave:1> A=3Dones(30,30,30,30); t=3Dtime(); for i=3D1:10; B=3Dpadarray(A,[2,2,2,2]); endfor; time()-t ans =3D 13.106 octave:2> A=3Dones(30,30,30,30); t=3Dtime(); for i=3D1:10; B=3Dpadarray(A,[2,2,2,2],10); endfor; time()-t ans =3D 13.596 octave:3> A=3Dones(30,30,30,30); t=3Dtime(); for i=3D1:10; B=3Dpadarray(A,[2,2,2,2],'circular'); endfor; time()-t ans =3D 44.399 replicate segfaulted (I believe CVS Octave should be able to handle it, I've found problems when using cat on ND arrays). octave:1> A=3Dones(30,30,30,30); t=3Dtime(); for i=3D1:10; B=3Dpadarray(A,[2,2,2,2],'symmetric'); endfor; time()-t ans =3D 44.495 ----->%------------>%-------- --=20 Josep Mon=E9s i Teixidor Clau GnuPG: gpg --recv-keys 80E85CC4 |