Yes, thanks Steve.
Here’s my test functor. It just takes an Eigen::Matrix
then creates an std::vector<Eigen::Matrix<scalar, -1, 1>>
view and pipes it into a covariance function. It’s untested, but this isn’t the issue.
struct cov_exp_quad_functor {
template <typename T0__, typename T1__, typename T2__>
Eigen::Matrix<typename boost::math::tools::promote_args<T0__, T1__, T2__>::type,
Eigen::Dynamic,Eigen::Dynamic>
operator()(const Eigen::Matrix<T0__, -1, -1>& x,
const T1__& sigma,
const T2__& length_scale) const {
typedef typename boost::math::tools::promote_args<T0__, T1__>::type scalar;
std::vector<Eigen::Matrix<T0__, -1, 1>> x_in(x.cols());
for (size_t i = 0; i < x.cols(); ++i) {
x_in.resize(x.rows(), 1);
x_in[i] = x.col(i);
}
Eigen::Matrix<scalar, -1, -1> cov =
stan::math::gp_exp_quad_cov(x_in, sigma, length_scale);
return cov;
}
};
Then, the class I’m building:
template <bool propto, typename F, typename T_y, typename T_X, typename T_theta>
class gp_lpdf {
public:
const F& f_(const Eigen::Matrix<T_X, Eigen::Dynamic, Eigen::Dynamic>, T_theta...);
const Eigen::Matrix<T_X, Eigen::Dynamic, Eigen::Dynamic>& X_;
gp_lpdf(const F& f_(const Eigen::Matrix<T_X, Eigen::Dynamic, Eigen::Dynamic>, T_theta...),
const Eigen::Matrix<T_X, Eigen::Dynamic, Eigen::Dynamic>& X_)
{
// do some things
};
};
And this is one of the ways I’ve tried to instantiate the class:
Eigen::Matrix<double, -1, -1> x; x.resize(3, 3);
x << 1, 2, 3, 4, 5, 6, 7, 8, 9;
stan::math::gp_lpdf <false, cov_exp_quad_functor,
double, double, stan::math::var>
gp_lpdf(cov_exp_quad_functor(), x);
It works fine with no x
data matrix.
This is all on my stan/math
fork, under feature/issue-1011-gp-cov-fun