function addElements(A) s = 0.0 for i in eachindex(A) s = s + A[i] end return s end function addElements(A) s = 0.0 for i in axes(A,1) for j in axes(A,2) s = s + A[i,j] end end return s end function addElements(A) s = 0.0 nx,ny = size(A) for i in 1:nx for j in 1:ny s = s + A[i,j] end end return s end """ Here three different ways are provided, the last one is the typical one, the first one abuses the fact that in Julia matrices and vectors are just different names of Array and thus can be indexed the same way. The second way uses the axes function which provides the range of the indices of an iterable along the dimension requested axes(Matrix,dimension), dim = 1 means rows, dim = 2 means columns. """