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


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

Re: Mapping tag-value lists to a third

From Sseziwa Mukasa <mukasa@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Mapping tag-value lists to a third
Date 2014-03-18 05:28 +0000
Message-ID <lg8lht$ndh$1@smc.vnet.net> (permalink)
References <20140317062731.30FA06A09@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


Pick[val,tag,1]

Experimenting, it looks like this scales roughly linearly, although at large list sizes memory management may become an issue:

timePick[n_]:=With[{val=Array[f[#]&,{n}],tab=RandomInteger[1,{n}]},Print["Time to pick ",Count[tab,1]," elements out of list of length ",n," is  ",First[Timing[Pick[val,tab,1]]],"s"]]
timePick[10^6]
timePick[2 10^6]
timePick[3 10^6]
Time to pick 500199 elements out of list of length 1000000 is  0.101878s
Time to pick 999630 elements out of list of length 2000000 is  0.204906s
Time to pick 1499923 elements out of list of length 3000000 is  0.385943s

On Mar 17, 2014, at 2:27 AM, carlos.felippa%colorado.edu@gtempaccount.com wrote:

> Hi,
>
> I have 2 lists of equal length such as
>
> tag={0, 1, 0, 0, 0, 1, 0, 1};  val={f1,f2,f3,f4,f5,f6,f7,f8}
>
> and want to produce a third:
>
> tagval={f2,f6,f8}
>
> with length Count[tag,1] containing the entries of val marked by 1-tags. Should be
> something efficient, since the source lists may be large (10^6 to 10^7).  Thanks.
>

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


Thread

Re: Mapping tag-value lists to a third Sseziwa Mukasa <mukasa@gmail.com> - 2014-03-18 05:28 +0000

csiph-web