x array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [ 12, 13, 14, 15, 1000, 17], [ 18, 19, 20, 21, 22, 23]]) n = argmax(ravel(x)) divmod(n, x.shape[1]) (2, 4) x[2,4] 1000
divmod is a builtin -- the rest are from Numeric. -----Original Message----- From: numpy-discussion-admin@lists.sourceforge.net [mailto:numpy-discussion-admin@lists.sourceforge.net]On Behalf Of Eric Hagemann Sent: Tuesday, May 01, 2001 5:26 PM To: Numpy-discussion@lists.sourceforge.net Subject: [Numpy-discussion] arg matrix max question
I need to find the location of the maximum value in a two dimensional Numeric array The best I have come up with uses a couple of calls to argmax and then cross checking the results I know there must be a better way and that I am not the only one who needs to do such a thing Anybody got a code snippet to share ?