Created
February 26, 2016 01:17
-
-
Save una-dinosauria/96b0f4f58bc86a864141 to your computer and use it in GitHub Desktop.
findmin in julia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fm() | |
n::Int32 = 1000000 | |
h::Int32 = 256 | |
trials::Int32 = 15*4 | |
@time begin | |
matrix = rand(Float32, h,n) | |
mins = zeros( Int32, n ) | |
end | |
min::Float32 = 0; | |
minidx::Int32 = 1; | |
@time begin | |
@inbounds for k = 1:trials | |
for i = 1:n | |
minidx = 1; | |
min = matrix[1, i] | |
for j = 2:h | |
if matrix[j, i] < min | |
min = matrix[j, i] | |
minidx = j | |
end | |
end | |
mins[i] = minidx | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment