@Mr.Wizard It seems that in compiled functions, this idiom like result[[pos]] = newValues; where pos is a list, is significantly slower than a stupid Do loop setting the values manually.
@Mr.Wizard Although, the vector set compiles down to only one call:
OK. At the top level that operation is very fast I believe. Would it be practical for you to make an external call for that part of your code?
(I cannot recall how much copying overhead that would imply.)
@halirutan Does your application call for a list of new values or a single new value? If the latter have you tried e.g. ReplacePart[{1, 2, 3, 4}, 0, {{3}, {4}, {2}}]?
@halirutan In version 7 your first (smart) function is three times faster than your second one. Of course in v7 there is no compile-to-C so I am using the versions you posted here in Chat.
For reference, with the first function as cf1 and the second as cf2:
a = Range[1*^7];
b = RandomSample[a];
cf1[a, b] // AbsoluteTiming // First
cf2[a, b] // AbsoluteTiming // First
@Kuba Additionally, I (personally) hate to fiddle around with those details. To me, all the dynamic stuff is completely different than the core language. Where the core is really intuitive, even more complicated paradigms, the dynamic stuff often leaves one without a clue.
@halirutan There are multiple of exceptions which make Dynamic programming horrible in terms of logical approach :/ But I can agree that those exceptions are a must, the problem is, those are silent, sometimes found in tutorials, sometimes not but mentioned in possible issues etc.
I think there is a lack of good tutorial about creating DM in context of dynamic gui. And I don't mean "this is how you should do this" but rather "this is the way and take a look at deviations you can make and at thos you can't and why"
Putting value=1 doesn't make it work. Then both plots go to 1 instead of one plot going to 0 and the other going to 1. f is owned by the kernel so it can't get the new value for value when it changes. When you put f in the DynamicModule then it can switch the plot range.
The documentation suggests it for which situations? It depends on what you want. In the first f is updated each time the toggler is clicked, and in the second f is only updated once.
@JacobAkkerboom I think so but I've chosen theoretical way, I was ambitious... I should've start from simulations and focus on that. This is what I want to learn anyway :)
@JacobAkkerboom and now I decided to do the simulations but it is quite late :) I'm going to try anyway :)
@j
@JacobAkkerboom and what's the problem with yours?
@Kuba I did some simulations, but the models I used were very ad hoc. Now I am looking at some more theoretical stuff. Quite the other way around I suppose :)
Let me tell you: Steve Jobs is really dead. Really. He must be dead, otherwise such things would never happen.
Today my MacPro arrived and you know what? The 4K display doesn't fit into the MacPro. The Apple Online Store sells it this way although there is one tiny sentence in the display description:
It says something like "HDMI Input is not available for the European market" and yes (!!) I have seen it and asked my reseller whether this means that I cannot use the 4K here. He told me that it is fine.
Now I'm left here with the wrong HDMI cable and something like this wouldn't have happen in former times. And this for the price of a car.
@halirutan There is some relevant discussion here, I believe. In short, my guess is that the slow-down is due to a massive allocation of small arrays on the heap.
@halirutan When you do assignments in place, element-by-element, there aren't CopyTensor instructions in the loop, rather the modifications are done in-place - thus much faster.
@LeonidShifrin I did some tests in the meantime and it seems setting of (all) elements in a vector is faster with a loop if the vector-length is smaller than about 30. For larger vectors, the v[[{p1,p2,...}]]=... method is faster.
@halirutan Yep. If you read my answer there, I tried to speculate why is that. Basically, at some point, the cost of massive assignment becomes larger than the const of heap allocation.
@LeonidShifrin At the moment tired because I'm up since aehmm 19.5 hours. Pissed of because I really wanted to try my new Mac. But otherwise very well as usual :-)
@halirutan Sounds good! I planned to write to you myself. So, looking forward! And, good luck with your Mac, I really hope this problem will somehow be resolved.
@halirutan I am myself using MacBook Pro, and like it a lot - it would be a shame is their standards of quality will get lower and lower. Such a great technology, would be a shame if it gets wasted.
@halirutan Hmmmh. I'd say a cable, rather than a separate adapter... at those bitrates, I wouldn't use adapter. Interesting if they don't ship compatible cable, though!
Yep. We have a famous skating tour along 11 cities in the northern part of the country. It's about 200 km, and a rather grueling event. Last century, weather allowed for only about 15 of those tours
@SjoerdC.deVries Certainly not. I have a back condition that limits me; I try to keep things to five miles round trip. Fortunately there are a lot of beautiful options nevertheless. And I think I'll push myself to do this one this year.
Is it possible to get a max K-coverage problem solution(s) and/or number of possible solutions in Mathematica?
Additionally ...When items of subset to be must cover is given
Its NP-Hard problem, but a approximation solution ll be a great
@SjoerdC.deVries If make it to the Columbia Gorge area I can help you put together a list things that should be possible. If she can push for one hike I can't think of a better one than the one I did no Sunday: Wahclella Falls Hike. It has limited elevation and none of it too steep, and it's two miles total.
You've got my email I believe. Let me know if/when I can help.
@CoolEulerProject It's probably because you don't show much effort yourself. There is neither a good starter in code, nor a good exposé of the question itself.
@Mr.Wizard @SjoerdC.deVries I agree that hiking in the NW US is great. I went to the Columbia Gorge a lot. One of my favorites was in Washington on the Olympic Peninsula, there was a hike that had an old airplane crash from the 50s at the top of a mountain you could go see.
Yeah. I thought it looked like Dagobah from The Empire Strikes Back.
I only did two hikes on the OP, but they were both great. I just used the Washington Trails Association site to find things and make sure the conditions were good.
@Cool I see that your question has also picked up three close votes. Though I don't agree with the close reason myself I do think at present it is too broad. While isn't not unreasonable to wonder if there is some built-in function to address the problem, if there is not you're asking for too much and without focus. Perhaps you could pick a specific algorithm you wish to implement, then ask for help with that?
@SjoerdC.deVries We have enough people already out here so, sure, "It's nothing but rain and drizzle." (Unofficially it's amazing from May through September... shhhh.)
@Mr.Wizard It was. We made a grand tour of the SW then. SF - Yosemity - Sequioia - Snow Canyon - Death Valley - Vegas - Bryce Canyon - Grand Canyon - Tucson - LA
Yeah, but I think the population density in NW US and Canada is much lower than Europe, so it is easier to get the feeling of being away from everything. I haven't actually been though. The Alps do look great in pictures.
@Mr.Wizard Indeed. With the NW done, we would have rounded up (sic) the four corners of the US. We won't be seeing the great plains, but that's just Holland, only hotter and bigger.