MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Find index of maximal element in multi-dimensional array

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73539] Re: Find index of maximal element in multi-dimensional array
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 21 Feb 2007 01:51:33 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <erelbt$7h4$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

Position[z, Max[Flatten[z]]]

??
Andrew Moylan wrote:
> Hi all,
> 
> Here's a two-dimensional array of numbers:
> 
> z = Table[Random[], {5}, {6}]
> 
> What's an efficient way of finding the index of the maximal element of
> z? Here's one way:
> 
> Last[Sort[Flatten[MapIndexed[{#2, #1} & , z, {2}], 1],
>    OrderedQ[{#1[[2]], #2[[2]]}] & ]]
> 
> The output is like this:
> 
> {{5, 4}, 0.921344}
> 
> But it's so untidy. Any better ideas?
> 
> Cheers,
> 
> Andrew
> 
> 


  • Prev by Date: Re: Precision of a number raised to a power
  • Next by Date: Re: Showing that ArcSinh[2]/ArcCsch[2] is 3?
  • Previous by thread: Re: Find index of maximal element in multi-dimensional array
  • Next by thread: Re: Find index of maximal element in multi-dimensional array