The function sim is supposed to return an array of vectors. It works fine when exposed to R with expose_stan_functions. But doesn’t compile when the function is called in the model or transformed parameters block. The error message is very long, but starts with “ERROR(s) during compilation: source code errors or compiler configuration errors!”.
Is it possible to return an array of vectors from a function or do i need to convert to something else first, like a matrix?
I can do array of vectors assignments of the type array_of_vectors = {v1, v2, ...} in the model block. But that seems not to be allowed in the function block?
Calling sim1 or sim2 from the model block in the example code above result in compiling error on my computer. While sim3 works fine. This is a bit unexpected behaviour or maybe a bug.
I’m not exactly sure what’s broken in that program in the current RStan 2.17.3 (presumably it’s also broken in the latest CmdStan as their stanc should be the same). But it works on the CmdStan develop branch, so presumably our next release will fix the issue.
So I couldn’t find a bug in how things work now with several variants of this.