repmat() is slow compared to .* or .*. Its code can be simplified a lot using kron().
@sgougeon)
Reported by Samuel GOUGEON (BUG DESCRIPTION:
----------------
The slowness of repmat() compared to .* has been pointed out there:
https://www.mail-archive.com/users@lists.scilab.org/msg07285.html
A careful analysis shows that .*. is even faster than .*
In addition, the code of repmat() looks rather complicated, and do not use .*.
Another implementation shall be written.
Here are the results of a comparative benchmark, including an alternative repmat()
implementation based on kron():
timePoints_V = rand(1,10000);
sample=3000;
n = 10;
t = 0;
for i = 1:n
tic;
repmat(timePoints_V, 2*sample,1); // 6.31 s
t = t+toc();
end
disp(t/n);
t = 0;
for i = 1:n
tic;
ones(2*sample,1) * timePoints_V; // 1.063 s
t = t+toc();
end
disp(t/n);
t = 0;
for i = 1:n
tic;
timePoints_V .*. ones(2*sample,1); // 0.733 s
t = t+toc();
end
disp(t/n);
t = 0;
n=100;
for i = 1:n
tic;
repmat_new(timePoints_V, 2*sample,1); // 0.859 s
t = t+toc();
end
disp(t/n);
repmat_new is 7.3 faster than the current repmat()
ERROR LOG:
----------
none.
HOW TO REPRODUCE THE BUG:
-------------------------
Run the benchmark here above. The code of repmap_new() will be proposed on review.
OTHER INFORMATION:
------------------
Test done on Scilab 6.0.1.
Edited by Vincent COUVERT