Tag Info

New answers tagged

0

Why don't you use SQLExecute? From the databaselink guide (just a synopsis below - please work through the guide example): table = SQLTable["BATCH"]; cols = {SQLColumn["X", "DataTypeName" -> "Integer"], SQLColumn["Y", "DataTypeName" -> "Integer"]}; SQLCreateTable[conn, table, cols]; data1 = {table, SQLArgument @@ cols, SQLArgument[#, #^2]} & ...


6

Firstly, a bit about SQLite insert performances: http://stackoverflow.com/questions/1711631/how-do-i-improve-insert-per-second-performance-of-sqlite http://stackoverflow.com/questions/3852068/sqlite-insert-very-slow Both of these state the fact that SQLite wraps every insert statement with a transaction and that the run times can be up to 270x faster ...


9

Update Almost ten times faster again, or about 90 times faster than the OP's way (0.069 sec v. 5.46 sec): For the second integral, we can find its derivative with respect to x and then integrate with NDSolve. The derivative of the integral has two components, one from differentiating under the integral sign dxdz1 and one from plugging in the limit of ...


0

Depending on your intended use, Convolve could provide a more useable representation of the solution than Integrate. Please note this comes at some performance expense, however the main delay was the unevaluated use inside of Plot, which has been solved by @Chenminqi. Your issue with only being able to work with infinite intervals can be resolved when you ...


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}]; ...


3

A variation on @MrW's answer using a combination of Outer, Coefficient, Variables and GatherBy: func = Function[{state}, Coefficient[state, #] &@ Outer[Times, ## & @@ (Sort /@ GatherBy[Variables[state], Head])]]; Test: xx1 = FF[1, 1] GG[1, 1] + FF[1, 1] GG[2, 2] + FF[2, 2] GG[2, 2]; xx2 = 2*FF[1, 2] GG[1, 1] + FF[1, 1] GG[1, 2] + FF[2, 2] ...


7

Your code is like a Rube Goldberg machine! Try this instead: fn[state_] := Outer[Coefficient[state, #*#2] &, ##] & @@ (Union @ Cases[state, #, -2] & /@ {_FF, _GG}) Test: test = 7 FF[1, 1] GG[1, 1] + 2 FF[1, 1] GG[2, 2] + 4 FF[2, 2] GG[2, 2] + 11 FF[2, 1] GG[2, 4]; fn[test] // MatrixForm $\left( \begin{array}{ccc} 7 & 2 & 0 ...


2

For the example you gave FF[___] and GG[___] are the only non-number terms, therefore by polynomial sort order you could use simply: mtx1[[All, All, 1]] {{24, 24, 24}, {24, 24, 24}, {24, 24, 24}} I shall now look at your newer question where I anticipate a more representative example.


1

Given the structure of your SQUARE example matrix this should be fast: dim = First @ Dimensions @ mtx1 3 tup = Join [#, {1}] & /@ Tuples[Range@dim, 2] {{1, 1, 1}, {1, 2, 1}, {1, 3, 1}, {2, 1, 1}, {2, 2, 1}, {2, 3, 1}, {3,1, 1}, {3, 2, 1}, {3, 3, 1}} Partition[mtx1[[#1, #2, #3]] & @@@ tup, dim] {{24, 24, 24}, {24, 24, 24}, {24, ...


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 ...


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

In this instance, compiling your triply nested For loops is unlikely to be the most effective way to speed up your code. I may have misunderstood what you are trying to do, being allergic to nested loops. However, two obvious speedups occur to me: Define your starting value in a more efficient way Use functional programming (specifically NestList) to build ...


17

@Simon Woods points out in a comment that: In fact the delay on the initial run is caused by compiling code to provide the Poisson distribution :-) You can look at ImageColorOperationsDumpiImageEffectPoissonNoise to see how it works internally. Now, although PoissonDistribution can't be compiled, there's nothing stopping the use of my own C++ ...



Top 50 recent answers are included