I know that arrays are column based in julia but maybe I’m missing something.
Want to subtract the column minimum from each column in a matrix and then the same with rows.
Currently doing this:
# subtract col minimum for c=1:ncols @views mat[:,c] .-= minimum(mat[:,c]) end # subtract row minimum row_minima = findmin(mat, dims=2) for r=1:nrows @views mat[r,:] .-= row_minima[r] end
which takes about 6s for a 16000*16000 UInt16 matrix.
The first part (col minimum) takes about 0.3s so is way faster than the second one.
First I used:
for r=1:nrows @views mat[r,:] .-= minimum(mat[r,:]) end
which takes 10s so mine is at least faster but maybe there is something I’m missing out. Thanks in advance.