Is it possible to use C++ vector functions in Stan?
We need more information to answer questions such as this. Technically, any time you declare an array in the Stan language such as
data {
int N;
int J;
int y[N, J]; // uses std::vector<std::vector<int> >
}
it utilizes a std::vector
in C++. Likewise anytime you declare a vector[N]
it uses the Eigen library, which is also C++.
But I would guess your question is actually whether you can call a C++ function (perhaps involving a vector) from the Stan language, in which case the answer is yes. To do so using RStan, see
https://cran.r-project.org/web/packages/rstan/vignettes/external.html
Correct, I’m interested in calling std vector functions like erase() and begin()
Then, yes you need to declare but not define a function the the correct signature in the functions block of your Stan program, define a C++ function that does whatever, and then when you go to compile it, specify the full path to the C++ file as a #include
. All of that is briefly explained in the linked vignette.