On 6-Oct-2010, Fotios Kasolis wrote:
| So I did not manage to reproduce the example which was like 3 times
faster
| but here is another example (not that bad)
|
| Windows 7 with binaries Octave 3.2.4 and Scilab 5.2.2 on intel i7 720
|
| octave.exe:1> xmpl
| 32.430
|
| ->exec('C:\Users\fotios\Desktop\xmpl.sce', -1)
| 22.411
|
| where xmpl contains the very intelligent code shown below
| N = 2000
| A = zeros(N,N);
| tic();
| for i = 1:N
| for j = 1:N
| A(i,j) = i^2 + j^2;
| end
| end
| time = toc();
| disp(time)
On my system with the most recent Octave snapshot (3.3.52) I see
31.422 seconds for Octave and 32.9 seconds for Scilab. And for the
more intelligent
tic ();
N = 2000;
tmp = (1:N).^2;
A = repmat (tmp, N, 1) + repmat (tmp', 1, N);
toc ();
I get about .2 seconds for Octave and and error about repmat being
undefined in Scilab. Using kron instead:
tic ();
N = 2000;
t1 = (1:N).^2;
t2 = ones (N, 1);
A = kron (t1, t2) + repmat (t1'; t2');
toc ();
I get approximately the same results from Octave and
!--error 17
: stack size exceeded (Use stacksize function to increase it).
from Scilab the first time I tried it, then it crashed with a segfault
on the second attempt (not that I thought the stack size problem would
go away, I just wanted to see what would happen).
jwe