Hello, in the following I show a minimal working example of the problem. I want to implement a type stable function that solves an ODE. But I figured out that the solve
function returns Any
type. This is the minimal code:
function prova(A, b, tspan; alg=Tsit5())
prob = ODEProblem{true}(prova_func, b, tspan, (L=A,))
sol = solve(prob, alg)
return prova(sol)
end
function prova(sol)
return sol.u
end
prova_func(du, u, p, t) = mul!(du, p.L, u)
A = rand(5,5)
b = rand(5)
tspan = (0, 1)
res = prova(A, b, tspan)
but when I use Cthulhu to discover type instabilities, I see that the function solve
returns Any
. After that, it is impossible for julia to identify the type of the outcome of the solution.
How to solve it?