I am not very experienced with Compile, I tried to use it for a Meijer-G function

mTest = Compile[{{k, _Integer}, {b, _Real}}, MeijerG[{{1/2, 1/2}, {}}, {{0, 1/2, k}, {-k}}, b^2], {{MeijerG[_, _, _], _Real}}]

but it returns the error

CompiledFunction::cflist: Nontensor object generated; proceeding with uncompiled evaluation.

Does it mean that I can't Compile MeijerG or is there a trick to it. Eventually I would like to Compile a long calculation that contains a few Meijer-G functions.

  • 2
    $\begingroup$ Unfortunately, you can't compile MeijerG. See this for a list of compilable functions. $\endgroup$ – DumpsterDoofus Jan 19 '15 at 23:14
  • $\begingroup$ So Compile can't accelerate the evaluation of MeijerG. However you can precompute it in different points and use Interpolation. $\endgroup$ – ybeltukov Jan 19 '15 at 23:28

The reason you get a message is because Compile cannot handle non tensor arrays, and the first argument to MeijerG is not a tensor (i.e. {{1/2, 1/2}, {}}).

Now DumpsterDoofus is correct in that MeijerG cannot be compiled, but we can get around this error, which will make MeijerG usable in compiled code. What I mean by usable is Compile will call Mathematica's main kernel to evaluate your MeijerG expression, and then jump right back into the compiled code. This is much better than the current behavior, where the non tensor causes Compile to jump out and not return.

Mei[m_, n_, p_, q_, args___, x_] := MeijerG[{{args}[[1;;n]], {args}[[n+1;;p]]}, {{args}[[p+1;;p+m]], {args}[[p+m+1;;-1]]}, x]

mTest = Compile[{{k, _Integer}, {b, _Real}}, Mei[3, 2, 2, 4, 0.5,0.5,0, 0.5,k , -k, b^2]]

mTest[3, 2.3]
  • $\begingroup$ I was just wondering whether it is possible to 'break' the MeijerG function down to a series of elementary calculations that can be compiled. I have no idea how Mathematica computes it, but I got this idea while reading this post $\endgroup$ – ThunderBiggi Jan 28 '15 at 13:55

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