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


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

Re: Mapping tag-value lists to a third

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!newspump.sol.net!post2.nntp.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail
From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Mapping tag-value lists to a third
Date Sun, 23 Mar 2014 09:00:57 +0000 (UTC)
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <lgm7s9$25$1@smc.vnet.net> (permalink)
Lines 34
Organization Time-Warner Telecom
NNTP-Posting-Date 23 Mar 2014 09:06:43 GMT
NNTP-Posting-Host ea8270cb.news.twtelecom.net
X-Trace DXC=MnL6O5?f:bgm_i:024=]AkC_A=>8kQj6m;[h;PUXBgbdR?JXX0GleinEFiONJ7[GofQGn]TQjOYJh
X-Complaints-To abuse@twtelecom.net
Xref csiph.com comp.soft-sys.math.mathematica:16687

Show key headers only | View raw


On 3/22/14 at 12:06 AM, koopman@sfu.ca (Ray Koopman) wrote:

>For v5+ users,

>val[[ SparseArray[tag] /. SparseArray[_,_,_,d_] :> Flatten@d[[2,2]]
>]]

>may be faster than Pick[val,tag,1].

For what it is worth

In[1]:= n = 10^7;
val = RandomReal[1, n];
tag = RandomInteger[1, n];

In[4]:= Timing[c = Pick[val, tag, 1];]

Out[4]= {0.137875,Null}

In[5]:= Timing[
 b = val[[SparseArray[tag] /.
      SparseArray[_, _, _, d_] :> Flatten@d[[2, 2]]]];]

Out[5]= {0.255513,Null}

In[6]:= b == c

Out[6]= True

In[7]:= $Version

Out[7]= 9.0 for Mac OS X x86 (64-bit) (January 24, 2013)

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


Thread

Re: Mapping tag-value lists to a third Bill Rowe <readnews@sbcglobal.net> - 2014-03-23 09:00 +0000

csiph-web