Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #16687
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Mapping tag-value lists to a third |
| Date | 2014-03-23 09:00 +0000 |
| Message-ID | <lgm7s9$25$1@smc.vnet.net> (permalink) |
| Organization | Time-Warner Telecom |
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
Re: Mapping tag-value lists to a third Bill Rowe <readnews@sbcglobal.net> - 2014-03-23 09:00 +0000
csiph-web