Timeline for Does Mathematica have advanced indexing?
Current License: CC BY-SA 4.0
19 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 25, 2019 at 18:35 | history | edited | Szabolcs | CC BY-SA 4.0 |
deleted 12 characters in body
|
Feb 17, 2017 at 22:00 | comment | added | Wjx | @Szabolcs Yeah, I see. Truely wierd phenomenon. This will lead to a performance drop I suppose? | |
Feb 17, 2017 at 9:26 | comment | added | Wjx |
Yeah, Just a reminder that the selection of Select and UnitStep based solution still depends on one's application~ even in this case where Select "saved" 10000 times of calculation, it's only less than 10 times faster, so it's really inefficient in most cases.
|
|
Feb 17, 2017 at 9:21 | comment | added | Szabolcs |
@Wjx Vectorization is always fast, but the code is hard to read and write (in Mathematica, not e.g. in MATLAB). With this code, and later with BoolEval, I tried to make it easy to read/write as well. Sadly, some bugs prevent me from doing this. Try e.g. arr = RandomReal[1, 100]; On["Packing"] , then evaluate arr > 0.5 . It unpacks. Why does it do that? I don't know. It doesn't even evaluate! Maybe it's a bug. Last time I complained to WRI, the support person did not understand my point and kept saying that arr < 0.5 is not correct syntax. I know, but that's no excuse for unpacking.
|
|
Feb 17, 2017 at 9:14 | comment | added | Szabolcs |
@Wjx There are serious limitations that make this hard to implement well, e.g. Greater taking a long time to "evaluate" when it doesn't in fact evaluate at all. Things change with M versions too. Please check if it's better with the BoolEval package. I don't have time to look into this now.
|
|
Feb 17, 2017 at 9:14 | comment | added | Wjx |
I suppose it's quite hard to solve this problem using UnitStep based solution, it's a cost of vectorization I suppose?
|
|
Feb 17, 2017 at 9:10 | comment | added | Wjx |
Test code: cond1 = Evaluate[And @@ ConstantArray[# > 1, 1*^4]] &; dat = RandomReal[1, 1*^4]; Select[dat, cond1] // AbsoluteTiming returns {11.7397, {}} while cond = And @@ ConstantArray[dat > 1, 1*^5]; dat = RandomReal[1, 1*^4]; pick[dat, cond] // AbsoluteTiming returns {79.1119, {}}
|
|
Feb 17, 2017 at 9:10 | comment | added | Wjx |
There are some condition where Select works better than UnitStep based solution. Notice that Select based solution can utilize the fact that True || a series of stuffs will always be True and False && a series of stuffs will always be False . so there's no need for evaluation of "a series of stuffs". While UnitStep based solution cannot easily use this fact. so when tests are significantly more than elements in list, performance can reverse.
|
|
Jul 11, 2016 at 8:51 | comment | added | Mr.Wizard | By the way this may be relevant to you: (1922) | |
Jul 11, 2016 at 8:47 | comment | added | Szabolcs | @Mr.Wizard Good point, thank you! | |
Jul 11, 2016 at 8:17 | comment | added | Mr.Wizard |
Have you considered using Subtract for performance in the package code?
|
|
Sep 29, 2015 at 8:03 | history | edited | Szabolcs | CC BY-SA 3.0 |
added 27 characters in body
|
May 30, 2014 at 15:29 | history | edited | Szabolcs | CC BY-SA 3.0 |
added 141 characters in body
|
Feb 11, 2014 at 20:14 | history | edited | Szabolcs | CC BY-SA 3.0 |
added 220 characters in body
|
Feb 11, 2014 at 19:50 | history | edited | Szabolcs | CC BY-SA 3.0 |
added 142 characters in body
|
Feb 11, 2014 at 19:37 | history | edited | Szabolcs | CC BY-SA 3.0 |
added 1211 characters in body
|
Mar 12, 2012 at 0:33 | vote | accept | Brian B | ||
Mar 12, 2012 at 18:07 | |||||
Mar 11, 2012 at 21:00 | history | edited | Szabolcs | CC BY-SA 3.0 |
added 1288 characters in body
|
Mar 11, 2012 at 20:26 | history | answered | Szabolcs | CC BY-SA 3.0 |