For example,

f = Compile[{{x, _Real}}, x];

has this output:

CompiledFunction[List[10, 10.`, 5468], List[Blank[Real]], 
 List[List[3, 0, 0], List[3, 0, 0]], List[], List[0, 0, 1, 0, 0], 
 List[List[1]], Function[List[x], x], Evaluate]

What are these lists for and what do the numbers in them mean?

  • 2
    $\begingroup$ Effectively opcodes/allocations/value definitions. Search site for compiler tools, do a compile print, connect the dots... $\endgroup$ – ciao Apr 17 '15 at 9:26
  • $\begingroup$ I know about CompilePrint, but none of its output seems to correlate with these lists. $\endgroup$ – rhennigan Apr 17 '15 at 9:33

The thing to do is to compare lots of different options and see what comes out. Ultimately what you're doing is taking the FullForm of this object:

enter image description here

(* 10.1.0  for Linux x86 (64-bit) (March 24, 2015) *)

FullForm[Compile[{{x, #}}, x]] & /@ {_Real, _Integer, _Complex}

This returns List[10, 10.1, 5468] for all 3 cases, so I would guess at 10 and 10.1 signifying the Mathematica version number.

The first difference in the FullForm is List[Blank[Real]], and the corresponding result for _Integer and _Complex. This should be self-explanatory - it tells you the argument types.

Then we get something of the form: List[List[i, j, k]...] for the function arguments, where in this case:

  • i is 2 for _Integer, 3 for _Real and 4 for _Complex
  • j is the rank of the argument (e.g. j = 2 for {x, _Real, 2} to pass a matrix).
  • k I'm not sure yet.

The rest will be left to explore in your own time, e.g. by trying more variables, variables of different types and ranks, and also returning different things (e.g. a scalar or vector output).

The last points to make are:

  • The number 5468 appears to change depending on values of CompilationOptions, RuntimeOptions and RuntimeAttributes
  • Compiling to C will also show the location of the compiled object
  • 1
    $\begingroup$ +1. English colloquialism police here. You would hazard a guess, not hesitate a guess. $\endgroup$ – bobthechemist Apr 28 '15 at 12:55
  • $\begingroup$ @bobthechemist good spot, thanks! $\endgroup$ – dr.blochwave Apr 28 '15 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.