Hi -
I have a question regarding metaprogramming.
How to re-create the problem:
If you run git clone -b feature/issue-758-add-dot-product-coviariance-function
on my fork, you can clone the branch and run as is… I changed the compiler to g++ in make/default_compiler_options
i.e. CC = g++
running ./runTests.py test/unit/math/prim/mat/fun/gp_dot_prod_cov_test.cpp
will work fine, as prim is implemented fine.
running ./runTests.py test/unit/math/prim/mat/fun/gp_dot_prod_cov_test.cpp
will work fine initially, but there are only two dummy tests that make sure the proper function is being called. if you uncomment line 46 you will see the “routing” issue in the form of a compiler error.
This function call is calling the wrong implementation in ‘prim’
The rev functions need to have two separate versions (following the datatypes @syclik added for gp_cov_exp_quad.hpp):
( c++
-> stan
)
- calls prim with
dot_product.hpp
(forstd::vector<Eigen::Matrix<stan::math::var, -1, 1> >
->row_vector[N]
) - calls prim without
dot_product.hpp
(forstd::vector<stan::math::var>
->real x[N]
)
Currently, both rev versions are both calling the prim version that uses dot_product.hpp (template <typename T_x, typename T_sigma>
). This is probably because one of the gp_dot_prod_cov.hpp is not templated.
So the question is this how do I use metaprogamming, either a template, or enable_if, to make sure that rev is calling the correct prim? I have tried various enable_if
statements and different templates.
As one attempt to remedy the problem, I tried the templating strategy in dot_product.cpp
. Why do dot_product.cpp
tests not compile with the template <int R1, ...>
etc arguments?