I am attempting to import my stan functions to R for testing. I used one of the C++ functions from stan/math library log_modified_bessel_first_kind and the code fails to compile successfully. Is there a way to expose my functions for testing? Below is my code:

model_code <-
"
functions {
real log_modified_bessel_first_kind(real y, real z);
real calclogC_up2const(real tau, int K) {
real res;
res = (K / 2.0 - 1) * log(tau) - log_modified_bessel_first_kind(K / 2.0 - 1, tau);
return res;
}
real my_vMF_lpdf(vector y, real tau, vector mu, int K) {
real res = calclogC_up2const(tau, K) + y' * mu * tau;
return res;
}
}
"
expose_stan_functions(stanc(model_code = model_code, allow_undefined = TRUE))

So you want to test the Stan-math internal function log_modified_bessel_first_kind in R? If so, then you must define a user-defined function for just that. So defined

exposeme_log_modified_bessel_first_kind

which just calls the log_modified_bessel_first_kind and then you are good to go and expose it as usual.

The log_modified_bessel_first_kind exists in Stan Math but was never exposed to the Stan language. So, that won’t work. It was intended that expose_stan_functions would work with user-defined functions that are declared in the functions block but defined in external C++ files, but that does not actually work either.