Only `vmin = v` and `vmax = v` need to move. Otherwise the function returns NaN if the first element of the array is NaN, because the loop below only touches `v` and not `vmin`/`vmax`.