title: Indexes of min/max elements in 4D array
body: <p>I need to change min/max values of a 4D array along specific axis. The coordinates of min/max along a particular axis are retuned by <code>armax</code>, so for 4D array a have a 3D array.</p>
  
  <p>Now from this 3D array I need to recover the full index of min/max values. I understand the most efficient way to do it is combining results of <code>mgrid</code> and <code>argmin</code> using something like (for min along 1st axis):</p>
  
  <pre><code>mg = np.mgrid[0:Array.shape[0], 0:Array.shape[1], 0:Array.shape[2], 0:Array.shape[3]]
  
  Array[mg[0], np.argmin(Array, axis=1), mg[2], mg[3]] = np.min(Array)
  </code></pre>
  
  <p>however, this does not seem to work correctly.</p>
  
  <p>Could someone please advise on how to correct the code above to replace the min values of Array along 1st axis with absolute min of Array?</p>
  
  <p>Alternatively, if this is not the fastest way to do it, what is the optimal solution?</p>