New answers tagged

0

May be, this code does what you are trying to get: g = Compile[{{x, _Real}}, x + 1] g[1] g2[x_] := 1 + g[x] g2[1] Please, note that NumericQ[2 + I] gives True. For examples about compiling, don't take them for shining gold, but here are some snippets I have retrieved from an old notebook: Quiet[Remove[compileFunction]]; compileFunction = Compile[{{x, ...


7

I think this is because a in your code represents a rank 10 tensor. If you want to use a as a vector, then I think it would be safeConv =Compile[{{a, _Complex, 1}, {b, _Real}}, If[b > 1, a[[1]], 0]] Otherwise, if a is a rank 10 tensor, then something like this safeConv = Compile[{{a, _Complex, 10}, {b, _Real}}, If[b > 1, a[[1, 1, 1, 1, 1, 1, 1, ...



Top 50 recent answers are included