I have been trying to make it possible to pass Stan’s reverse mode autodiff type back and forth between R and C++ by stuffing the value and adjoint into the real and imaginary parts of a complex number, which is a hack but the complex number type is native to R and C++. I was trying to follow @coatless’s example in the attached file (4.1 KB) but failed miserably when I Rcpp::sourceCpp
it. That file comments out some stuff that does not compile leaving “one” compiler error, which I do not understand but maybe someone like @Krzysztof_Sakrejda does?
In file included from Rcpp_var.cpp:10:
In file included from /home/ben/r-devel/library/Rcpp/include/RcppCommon.h:166:
/home/ben/r-devel/library/Rcpp/include/Rcpp/internal/export.h:155:4: error: no matching function for call to 'export_indexing__dispatch'
export_indexing__dispatch<T,value_type>(
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ben/r-devel/library/Rcpp/include/Rcpp/internal/Exporter.h:64:35: note: in instantiation of function template specialization
'Rcpp::internal::export_indexing<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1>, stan::math::var>' requested here
::Rcpp::internal::export_indexing<T,value_type>( object, result ) ;
^
/home/ben/r-devel/library/Rcpp/include/Rcpp/as.h:89:29: note: in instantiation of member function 'Rcpp::traits::IndexingExporter<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1>,
stan::math::var>::get' requested here
return exporter.get();
^
/home/ben/r-devel/library/Rcpp/include/Rcpp/as.h:152:26: note: in instantiation of function template specialization 'Rcpp::internal::as<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >'
requested here
return internal::as<T>(x, typename traits::r_type_traits<T>::r_category());
^
Rcpp_var.cpp:138:36: note: in instantiation of function template specialization 'Rcpp::as<Eigen::Matrix<stan::math::var, -1, 1, 0, -1, 1> >' requested here
stan::math::vector_v v_x = Rcpp::as<stan::math::vector_v>(x);
^
/home/ben/r-devel/library/Rcpp/include/Rcpp/internal/export.h:131:8: note: candidate function template not viable: no known conversion from
'typename ::Rcpp::traits::r_type_traits<var>::r_category' (aka 'Rcpp::traits::r_type_generic_tag') to '::Rcpp::traits::r_type_primitive_tag' for 3rd argument
void export_indexing__dispatch( SEXP x, T& res, ::Rcpp::traits::r_type_primitive_tag ) {
^
/home/ben/r-devel/library/Rcpp/include/Rcpp/internal/export.h:140:8: note: candidate function template not viable: no known conversion from
'typename ::Rcpp::traits::r_type_traits<var>::r_category' (aka 'Rcpp::traits::r_type_generic_tag') to '::Rcpp::traits::r_type_string_tag' for 3rd argument
void export_indexing__dispatch( SEXP x, T& res, ::Rcpp::traits::r_type_string_tag ) {
^