[Numpy-discussion] arg matrix max question

Paul F. Dubois paul at pfdubois.com
Sun Apr 1 22:24:24 CDT 2001


>>> 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 at lists.sourceforge.net
[mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of Eric
Hagemann
  Sent: Tuesday, May 01, 2001 5:26 PM
  To: Numpy-discussion at 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 ?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20010401/d4ed4cde/attachment-0001.html 


More information about the Numpy-discussion mailing list