Tag Info

Hot answers tagged

13

Let's start by taking a look at the compiled form of one of our queries: Dataset`CompileQuery[Query @ First @ spans] (* Dataset`WithOverrides@*Checked[Slice[205 ;; 313], Identity] *) We can see that the operation is not implemented directly in terms of part. Indeed, there are three components: Dataset`WithOverrides, GeneralUtilities`Checked and ...


8

This is not an answer. It is just a very long comment. Both a simple manually operated drill press and a computer-controlled five-axis omni-mill can drill a hole through a piece of bar stock. And both will do the actual drilling in about the same amount of time. If one hole in one bar is all you want, then you will accomplish the job much faster with the ...


6

You need to select a new data structure. As Leonid Shifrin has written Append[list, element] has a complexity proportional to Length[list] while Append[association, key -> value] is roughly constant time. Another data structure with this same property is linked lists: {newImage, {prevImage, {prevPrevImage,{}}} Any of these two could be used for ...


5

1. Optimising the code given First of all I set up your exact example, with functions a, b, c, d and main defined by you, and ran the following code. Do[main[10], {1000}]; // AbsoluteTiming (* 10.22 seconds *) Next, I tried the code below. Here I've removed the Listable and Parallelization options, and instead I have inlined the functions. a2 = ...


4

Here's how I'd approach it. Basically, use DownValues and DumpSave: frame[1] = (*picture1*); frame[2] = (*picture2*); DumpSave["filepath.mx",frame] With a fresh Kernel: Get[filepath.mx]; Length@DownValues@frame 2 Also, Obligatory warning about DumpSave: It's platform and version specific.


3

It's your inner while loop that is causing the trouble. I refactored your code a bit also. Basically your value of k decreases after the first run. So you only have to do this whole run (over k) once. This is much faster: θ = 0.3; v = 0.05; α = 1; r = 1; k = 1; q = InverseCDF[GammaDistribution[α, 1], 1 - θ]; Lfun[kr_] := Exp[kr q]/(kr + 1)^α CDF[ ...


3

Timing under 20 seconds on my computer now. Ok, your original program took about 60 seconds on my computer meaning that my computer is faster. The dramatical gain of time is due to halfing the MaxRecursion option value. The plot still shows no visible difference. I replaced Pi-Symbol by Pi for increasing readability in forum. I tested some scenarios, and ...


2

If you're using Mathematica 10, you can also use the new Association feature: frame = Association[]; frame[1] = (*picture1*); frame[2] = (*picture2*); In some ways, associations behave more like lists than downvalues: for example, functions like Map and Select work on them directly. If you assign a different variable to an association, you'll get a copy ...


1

After some further experimentation it turns out that the sluggishness of the locators in the LocatorPane can be overcome by eliminating the explicit Return statement from the PlotLabelerFunction. I changed the code as follows: (* updated Dynamic Overlay Code *) Dynamic[ Which[ (* this Which statement is used for responding to toggling of label ...


1

Sorry, this is too long for a comment, but I thought it might help! Update I also tried, interestingly, c = Table[Exp[-t (1 + 256 I Pi )], {t, 0, 1, 1/30000}]; // AbsoluteTiming (* 0.109373 seconds *) d = Table[Exp[t (-1 - 256 I Pi )], {t, 0, 1, 1/30000}]; // AbsoluteTiming (* 0.140624 seconds *) Though this method in fact produces a slightly different ...


1

Way 1: As Stephen Luttrell said in comment: conv1[t_] := Evaluate@Integrate[twopulse[s]*imp[t - s], {s, 0, t}, Assumptions -> t \[Element] Reals] now conv1 is: then plot it: Plot[conv1[t], {t, 0.09, 0.18}, PlotRange -> All, PlotStyle -> Green, Exclusions -> None] Way 2: conv2[t_] := NIntegrate[twopulse[s]*imp[t - s], {s, 0, t}]; ...



Only top voted, non community-wiki answers of a minimum length are eligible