Updating the cpp now compiles but when I try to sample I get
Error in processx::run(command = stanc_cmd(), args = c(stan_file, "--info", :
System command 'stanc' failed, exit status: 1, stderr:
E> Semantic error in '/Users/tanpi.stan', line 2, column 2 to column 21:
E> -------------------------------------------------
E> 1: functions {
E> 2: real tanpi(real x);
E> ^
E> 3: }
E> 4:
E> -------------------------------------------------
E>
E> Some function is declared without specifying a definition.
namespace tanpi_model_namespace {
#include <stan/math/prim.hpp>
#include <stan/math/rev/core.hpp>
#include <iostream>
#include <boost/math/special_functions/sin_pi.hpp>
#include <boost/math/special_functions/cos_pi.hpp>
inline double tanpi(const double& x, std::ostream* pstream__) {
return boost::math::sin_pi(x) / boost::math::cos_pi(x);
}
}
and calling in R as
fp <- "tanpi.stan"
hpp_file <- "tanpi.cpp"
mod <- cmdstan_model(fp, include_paths = getwd(),
cpp_options = list(USER_HEADER = file.path(getwd(), hpp_file)),
stanc_options = list("allow-undefined")
)
mod$sample(
data = list(y = 2)
)
This seems like a bug b/c I get the same error using your code in Custom c++ using cmdstanr? - #9 by rok_cesnovar