Using previously defined function as an argument


#1

Is it possible to use an user defined function as an argument for another function? I know that base stan functions such as integrate_ode_rk45 take the user defined ODE function as an argument. Not sure how to write similar function in Stan.


#2

Edit: No (I misunderstood what you were asking at first).


#3

That’s a shame. It would make lives easier if such functionality was available in stan.


#4

You can do more or less the same thing if you #include your own C++ file in a Stan program. Just define your user-defined function in C++ and call it from your C++ function that you declare but don’t defined in your Stan program.


#5

Yes, it would. We take pull requests if you’d like to add it. But I have to warn you that the parser is a beast to deal with due to the Boost Spirit Qi parser.

Otherwise, you’re going to have to wait until we get around to it. It’s on the roadmap after tuple types and ragged arrays.