Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #14856

Re: Position

From Ray Koopman <koopman@sfu.ca>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Position
Date 2013-06-14 08:52 +0000
Message-ID <kpelk3$hsl$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


Length[t = RandomReal[{0, 5}, 10^6]]
1000000

AbsoluteTiming@Length[p = Position[t, _?(# > 2 &)]]
{4.348019, 599993}

AbsoluteTiming@Length[q = Pick[Range@Length@t, UnitStep[t - 2], 1]]
{0.716786, 599993}

Flatten@p === q
True

----- Costa Bravo <q13a27tt@aol.com> wrote:
> How can I find the indices  of all  elements greaters than e.g. 2 of a vector.
> 
> t=RandomReal[{0,5},100]
> Position[t,??]
> 
> --
>   Costa

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Position Ray Koopman <koopman@sfu.ca> - 2013-06-14 08:52 +0000

csiph-web