New answers tagged

1

I have been encountering this problem a lot recently. Since many related questions are linked to this post and I will share my solution here. Advantages Can return multiple results (not necessarily have the same shape) Can return ragged lists Does not call MainEvaluate Basic idea Flatten all the tensors into one single list, and include enough ...


7

This is a proof of concept of the idea of parsing the Compile expression, extracting Symbols, finding dependent definitions, and inserting them back into Compile. First a HoldFirst variation of heldCases: makeHeld[(L_ -> R_) | (L_ :> R_)] := L :> HoldComplete[R]; makeHeld[pat_] := x : pat :> HoldComplete[x]; Attributes[heldCases] = {HoldFirst};...


1

Just wanted to provide an answer to the OP's question Can anyone understand what am I doing wrong? which I feel hasn't really been addressed. The original error stems from the compiler assuming f[i,j] returns an integer instead of a real (when i and j are positive), because the inputs of the compiled function gC are integers and the type of f[i,j] is ...


3

I know I'm late, but was too curious. The problem really stems from _InterpolationFunction in f2 = Compile[{{t, _Real}}, Evaluate@sol[t], {{_InterpolationFunction, _Complex}}]; from the question not matching s[t]. First, I'm not sure if it's a typo or InterpolationFunction has been renamed as InterpolatingFunction in Mathematica 10. Second, ...



Top 50 recent answers are included