Finding the local minimum of a matrix in c