Tag Info

Hot answers tagged

6

It happens because Compile cannot infer the types returned by the subsidiary functions enn and fF. In the second approach, you partially solved this by specifying it manually for enn. In principle you could have done that in the first approach as well if you had specified it for fF too, but in practice getting the type inference to work out correctly is not ...


6

While I'm not sure why the error you see is generated, you can fix your sumT function by taking the fF call out of the Map form: sumT = Compile[ {{tab, _Real, 2}}, Total[fF /@ Map[enn[#[[1]], #[[2]]] &, tab]], CompilationTarget -> "C"]; This worked fine for me in version 10.1 of Mathematica: sumT[tab] // AbsoluteTiming (* ==> {0.000667, ...


6

Updated An arbitrary density plot for the example: den = DensityPlot[Sin[x] Sin[y], {x, -180, 180}, {y, -90, 90}] : Extract the graphics primitives from the density plot: prim = First @ Cases[den, Graphics[a_, ___] :> a, {0, -1}, 1]; Plot them directly with GeoGraphics while setting the desired GeoStyling for the GeoBackground: GeoGraphics[ ...


4

args = {{m1, n1}, {m2, n2}, {m3, n3}, {m4, n4}}; f @@@ args {f[m1, n1], f[m2, n2], f[m3, n3], f[m4, n4]} Apply[f, args, {1}] {f[m1, n1], f[m2, n2], f[m3, n3], f[m4, n4]} f @@ # & /@ args {f[m1, n1], f[m2, n2], f[m3, n3], f[m4, n4]} f[Sequence @@ #] & /@ args {f[m1, n1], f[m2, n2], f[m3, n3], f[m4, n4]} % == %% == %%% == ...


2

This ran fine on a beat-up old loungebook with k=100... (BTW - this does not directly answer the "How do I fix this problem doing things this way..." aspect - sometimes the answer is just "...don't do it that way..." when there's a more direct path to the desired results.) k = 100; size = 4; start = 1; end = 300; howmany = 1; If[howmany =!= All, ...


1

Yes, for this you can use Map (as operator /@) which is one of the most often used functions when doing the same job for several inputs. For instance creating 3 data sets {g1, g2, g3} = Range /@ {10, 20, 30} and then creating your interpolations {i1, i2, i3} = Interpolation[#, InterpolationOrder -> 1] & /@ {g1, g2, g3} If you don't know what the ...



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