-
-
Couldn't load subscription status.
- Fork 5.7k
Closed
Labels
performanceMust go fasterMust go faster
Description
2d array indexing is significantly slower than matlab for us.
*** MATLAB ***
function t = mytranspose(x)
[m, n] = size(x);
t = zeros(n, m);
for i=1:n
for j=1:m
t(i,j) = x(j,i);
end
end
end
a = ones(2000,2000);
tic; mytranspose(a); toc
Elapsed time is 0.132217 seconds.
*** Julia ***
function transpose(a::Matrix)
m,n = size(a)
b = similar(a, n, m)
for i=1:m, j=1:n
b[j,i] = a[i,j]
end
return b
end
julia> x = ones(2000,2000);
julia> tic(); y = x'; toc();
elapsed time: 2.17426395416259766 sec
Metadata
Metadata
Assignees
Labels
performanceMust go fasterMust go faster