Tag Info

New answers tagged


To get you started here are two examples that do work m = Table[i*j, {i, 1, 2}, {j, 1, 2}]; res = {{{1}, {2}}, {{3}, {4}}}; Note that res must have the correct rank. Needs["CompiledFunctionTools`"] Example 1: cfun2 = Compile[{{x, _Real, 2}}, If[Total@Flatten[x] > 5, {{1}, {2}}, m.x], CompilationOptions -> {"InlineExternalDefinitions" -> ...


Your first example could be just as easily achieved with Table[i*i, {i, 1, iter}], which compiles. test1[int_] := Module[{m}, m = Table[i, {i, 1, int}]; Do[m[[i]] = i*i, {i, 1, int}]; Return[m] ] test2[int_] := Table[i*i, {i, 1, int}]; test3 = Compile[{{iter, _Integer}}, Table[i*i, {i, 1, iter}], CompilationTarget -> "C"]; Note how I've ...


Compile does not support arbitrary precision calculations. It uses the CPU's native support for floating point arithmetic, which allows it to run fast, but also limits it to $MachinePrecision effective decimal digits (about 16 digits).


test3 = Compile @@ (Hold[{{iter, _Integer}}, test[iter]] /. DownValues@test)


I would solve that problem adding a function with a pattern in the argument. Try: realRegion1a[x_Real] := realRegion1[x] And the try your Manipulate using that new function. It will behave as expected.


As mentioned by blochwave, your code can't benefit from compilation. To speed up your code, take Rolf Mertig's advise may be the best. Making use of the Listable attribute of those arithmetical function will also help a little: (* Tested under n = 1000, dual-core laptop *) pk1 = Table[ Sum[Binomial[a, i]*StirlingS2[i, r]*(n - c)^(-i), {i, r, a}], {r, 1, ...


Mathematica has a very large number of builtin functions, most of which would be part of libraries in other languages. Many of these functions are next to impossible to implement in a compatible way, think e.g. Integrate. Mathematica is also very different from most other languages: it is based on term rewriting and operates with symbols (concepts not ...


Use this: f = Compile[{{lst, _Real, 2}, {val, _Real, 1}}, First@First@Position[lst, val]]; f[samplelist, {1, 3}] (*3*)


ITS CRAZY I linked WolframRTL_Minimal.dll instead of WolframRTL.dll and then I put WolframRTL_Minimal.dll in the path where Visual Studio creates the executable :) Now it works and display 416.16 :)

Top 50 recent answers are included