Open
Description
Description
The algebra_solver
function does not compile when given a generalized lambda function. @charlesm93
Example
library(Rcpp)
sourceCpp(code =
'
// [[Rcpp::depends(BH)]]
// [[Rcpp::depends(RcppEigen)]]
// [[Rcpp::depends(StanHeaders)]]
#include <stan/math.hpp>
#include <Rcpp.h>
#include <RcppEigen.h>
// [[Rcpp::plugins(cpp14)]]
// [[Rcpp::export]]
auto eigenvector(Eigen::MatrixXd S, Eigen::VectorXd y_guess) {
Eigen::VectorXd theta;
auto y = stan::math::algebra_solver([&S](auto y, auto theta,
auto x_r, auto x_i, std::ostream *msgs) {
auto v = S * y - y; // eigenvalue assumed to be 1.0
return v.eval();
}, y_guess, theta, {}, {});
return y;
}
')
yields
In file included from file331a1065fadb.cpp:5:
In file included from /home/ben/r-devel/library/StanHeaders/include/stan/math.hpp:4:
In file included from /home/ben/r-devel/library/StanHeaders/include/stan/math/rev/mat.hpp:63:
In file included from /home/ben/r-devel/library/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:4:
/home/ben/r-devel/library/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:38:3: error: constructor for 'stan::math::system_functor<(lambda at file331a1065fadb.cpp:14:39),
double, double, true>' must explicitly initialize the member 'f_' which does not have a default constructor
system_functor() {}
^
/home/ben/r-devel/library/StanHeaders/include/stan/math/rev/mat/functor/algebra_solver.hpp:155:9: note: in instantiation of member function 'stan::math::system_functor<(lambda at
file331a1065fadb.cpp:14:39), double, double, true>::system_functor' requested here
Fx fx(Fs(), f, value_of(x), y, dat, dat_int, msgs);
^
file331a1065fadb.cpp:14:24: note: in instantiation of function template specialization 'stan::math::algebra_solver<(lambda at file331a1065fadb.cpp:14:39), double>' requested here
auto y = stan::math::algebra_solver([&S](auto y, auto theta,
^
/home/ben/r-devel/library/StanHeaders/include/stan/math/rev/mat/functor/algebra_system.hpp:26:5: note: member is declared here
F f_;
^
file331a1065fadb.cpp:14:39: note: '(lambda at file331a1065fadb.cpp:14:39)' declared here
auto y = stan::math::algebra_solver([&S](auto y, auto theta,
^
1 warning and 1 error generated.
make: *** [file331a1065fadb.o] Error 1
Expected Output
A compiled object
Current Version:
v2.18.1