« first day (1891 days earlier)      last day (2583 days later) » 

1:28 AM
Is there a reason why sometimes, when using commands to open a notebook, instead of actually opening the notebook, it sometimes just returns "NotebookObject" followed by a number like 27 in a box?
and then it doesn't open
 
 
9 hours later…
10:31 AM
A song I heard recently has somewhere a bit similar to mma's beep[]. But before I realized that, I was heavily looking for FrontEnd errors and checking messages settings :)
 
 
1 hour later…
12:01 PM
@numbermaniac What is the InputForm of the output? Can you compare it with $ParentLink and see if the LinkObjects are the same?
 
 
3 hours later…
3:20 PM
Is there a commonly known fastest way to remove an item from an unordered list? It appears that Complement[list, {val}] is a lot faster than DeleteCases[list, val], even though the former does an implicit sort.
actually, that's only true for long lists
for short lists, DeleteCases seems to be faster
but only marginally
 
3:53 PM
@MartinEnder And are you interested in long lists or in short ones?
 
Short ones at the moment.
But I think it's an interesting question in general.
 
4:26 PM
@MartinEnder OK, here we go:
Deleting a numeric element from a list doesn't require sorting. If the list is represented by a real C-Array, you need to copy the list into a new list which doesn't contain the element you want to delete.
The approach I would suggest is to just go through the list and insert each element that is not equal to the one you want to delete into a new dynamically growing list. I have a compiled version here that beats both, DeleteCases and Complement on large unordered real lists.
 
5:14 PM
@halirutan Isn't that what Select would do internally?
FirstPosition together with Drop is also algorithmically sound I think.
 
@C.E. I'm not sure. In highlevel Mathematica, a list is a list of expressions which internally are pointers. So I believe they need to take more cases under consideration. What I have for an unordered list of Reals is the following:
list = RandomSample[#, Length[#]] &@Table[i, {i, 0, 1, 1.0/(10^7 - 1)}];

In[8]:= Sort[list]; // AbsoluteTiming

Out[8]= {1.83469, Null}

In[10]:= DeleteCases[list, 0.01]; // AbsoluteTiming

Out[10]= {0.972597, Null}

In[11]:= Complement[list, {0.01}]; // AbsoluteTiming

Out[11]= {1.88978, Null}
Writing down the simple algorithm I proposed in compiled code:
deleteElement = Compile[{{l, _Real, 1}, {elm, _Real, 0}},
  Module[{b = Internal`Bag[Most[{0.0}]]},
   Do[
    If[e != elm,
     Internal`StuffBag[b, e]
     ],
    {e, l}
    ];
   Internal`BagPart[b, All]
   ], CompilationTarget -> "C", RuntimeOptions -> "Speed"
  ]
gives
In[9]:= deleteElement[list, 0.01]; // AbsoluteTiming

Out[9]= {0.250829, Null}
 
@halirutan Select[list, # != 0.01 &]; // AbsoluteTiming takes 4.91732 seconds for me, compared with 0.21 for your method. That's actually very surprising to me.
Pick[Unitize[list - 0.01], 1]; // AbsoluteTiming is faster though, taking only 0.17 seconds.
 
@C.E. Yep, i guess the high-level overhead is too large for Select.
But I think I have another simple solution that could be fast.. one sec
 
Drop[list, Position[list, 0.01]]; // AbsoluteTiming takes 1.26 seconds, so not so bad.
 
test = Compile[{{e1, _Real, 0}, {eTest, _Real, 0}},
  Boole[e1 != eTest],
  CompilationTarget -> "C", Parallelization -> True,
  RuntimeAttributes -> {Listable}, RuntimeOptions -> "Speed"];

Pick[list, test[list, 0.01]]; // AbsoluteTiming
Needs 0.4 seconds.
But it always contains some compiled code. One might think the highlevel version would be fast as well:
Pick[list, Thread[list == 0.01]]; // AbsoluteTiming
needs 2.5 seconds
 
5:33 PM
@C.E. What if you use Delete[]?
 
@J.M. Then I get 1.28873 seconds, so about the same.
@halirutan So to sum it up: deleteElement is the algorithmically best way to do it, but Pick[Unitize[list - val], 1] uses the hardware better? Could it be different with a better compiler?
Sow/Reap use bags internally, so Reap[Sow[#, # == 0.01] & /@ list, False]; // AbsoluteTiming should work similarly to deleteElement: Wrong. 10 seconds.
 
 
2 hours later…
7:34 PM
Can you reproduce this slowdown in 11.1 (versus 11.0) on Windows or Linux?
Code:
(triples = IntegerPartitions[1000, {3}]) // Length
{a, b, c} = Transpose[triples]; // RepeatedTiming
Timing is 2x higher in 11.1, compared to 11.0 (or 10.4)
 
@Szabolcs same here, win7 V10.4/V11.1 ~ .5
 
I just tested 9.0.1 and 10.0.2. Version 9 is 2.5 times faster than 10.0-11.0 on this!
 
 
1 hour later…
9:02 PM
@Kuba This syntax colour scheme is wrong in this post: mathematica.stackexchange.com/questions/140870/…
Can you find out what's going on?
 
 
1 hour later…
10:10 PM
@Szabolcs I've fixed it with <!-- language: lang-mma --> but don't know what is going wrong
 

« first day (1891 days earlier)      last day (2583 days later) »