Tag Info

New answers tagged

8

Use pure functions (Function) and "InlineExternalDefinitions" -> True: g = #^2 &; f = # + 1 &; compiledFunction = Compile[{{x, _Real, 0}}, f@g[x], CompilationOptions -> {"InlineExternalDefinitions" -> True}]; CompilePrint[compiledFunction] 1 argument 1 Integer register 4 Real registers Underflow ...


6

Yes there is a way to use functions that use external non compiled functions. It uses the step function of Mr.Wizard defined in the post How do I evaluate only one step of an expression?, in order to recursively expand the code that we want to compile until it uses only functions that Mathematica can compile. The technique discussed in the post How to ...


3

The key to this is what exactly you mean by "compile to C code". If the question is: is it possible to generate a collection of code conforming to the C standard that when compiled and run produces the same result as some general Mathematica function, then the answer is that there is no technical limitation. However this C code will be very large and will ...



Top 50 recent answers are included