Hi Daniel,
thanks for the reply. Here is what I get:
#### If I use ####
"""
template <typename T>
inline
Eigen::Matrix<T,2,1>
c_one(const T& y) {
Eigen::Matrix<T,2,1> res;
res(0,0) = 1.0;
res(1,0) = 0.0;
return res;
}
"""
I get
"""
In file included from <built-in>:167:
In file included from <command line>:5:
In file included from model.cpp:3:
In file included from stan/src/stan/model/model_header.hpp:16:
In file included from stan/src/stan/agrad/rev.hpp:7:
In file included from stan/src/stan/agrad/rev/var.hpp:5:
In file included from stan/src/stan/math/matrix/Eigen.hpp:4:
In file included from stan/lib/eigen_3.2.0/Eigen/Dense:1:
In file included from stan/lib/eigen_3.2.0/Eigen/Core:284:
stan/lib/eigen_3.2.0/Eigen/src/Core/Assign.h:493:32: error: no member named
'YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY'
in 'Eigen::internal::static_assertion<false>'
EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NE...
stan/lib/eigen_3.2.0/Eigen/src/Core/util/StaticAssert.h:112:65: note: expanded
from macro 'EIGEN_STATIC_ASSERT'
if (Eigen::internal::static_assertion<bool(CONDITION)>::MSG) {}
^
stan/lib/eigen_3.2.0/Eigen/src/Core/PlainObjectBase.h:411:20: note: in
instantiation of function template specialization
'Eigen::DenseBase<Eigen::Matrix<stan::agrad::var, -1, 1, 0, -1, 1>
>::lazyAssign<Eigen::Matrix<double, 2, 1, 0, 2, 1> >' requested here
return Base::lazyAssign(other.derived());
^
stan/lib/eigen_3.2.0/Eigen/src/Core/Assign.h:520:97: note: in instantiation of
function template specialization
'Eigen::PlainObjectBase<Eigen::Matrix<stan::agrad::var, -1, 1, 0, -1, 1>
>::lazyAssign<Eigen::Matrix<double, 2, 1, 0, 2, 1> >' requested here
...run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(oth...
^
stan/lib/eigen_3.2.0/Eigen/src/Core/PlainObjectBase.h:618:69: note: in
instantiation of member function
'Eigen::internal::assign_selector<Eigen::Matrix<stan::agrad::var, -1, 1,
0, -1, 1>, Eigen::Matrix<double, 2, 1, 0, 2, 1>, false, false>::run'
requested here
return internal::assign_selector<Derived,OtherDerived,false>::run(...
^
stan/lib/eigen_3.2.0/Eigen/src/Core/PlainObjectBase.h:603:102: note: in
instantiation of function template specialization
'Eigen::PlainObjectBase<Eigen::Matrix<stan::agrad::var, -1, 1, 0, -1, 1>
>::_set_noalias<Eigen::Matrix<double, 2, 1, 0, 2, 1> >' requested here
...OtherDerived& other, const internal::false_type&) { _set_noalias(other); }
^
stan/lib/eigen_3.2.0/Eigen/src/Core/PlainObjectBase.h:595:7: note: in
instantiation of function template specialization
'Eigen::PlainObjectBase<Eigen::Matrix<stan::agrad::var, -1, 1, 0, -1, 1>
>::_set_selector<Eigen::Matrix<double, 2, 1, 0, 2, 1> >' requested here
_set_selector(other.derived(), typename internal::conditional<stat...
^
stan/lib/eigen_3.2.0/Eigen/src/Core/Matrix.h:172:20: note: (skipping 2 contexts
in backtrace; use -ftemplate-backtrace-limit=0 to see all)
return Base::_set(other);
^
model.cpp:154:43: note: in instantiation of function template specialization
'stan::math::A_1<stan::agrad::var>' requested here
stan_print(pstream__,dims(A_1(v)));
^
stan/src/stan/model/util.hpp:99:21: note: in instantiation of function template
specialization 'model_model_namespace::model_model::log_prob<true, true,
stan::agrad::var>' requested here
.template log_prob<propto,
^
stan/src/stan/model/util.hpp:277:24: note: in instantiation of function template
specialization 'stan::model::log_prob_grad<true, true,
model_model_namespace::model_model>' requested here
= stan::model::log_prob_grad<propto,
^
stan/src/stan/common/command.hpp:208:28: note: in instantiation of function
template specialization 'stan::model::test_gradients<true, true,
model_model_namespace::model_model>' requested here
= stan::model::test_gradients<true,true>(model,cont_vector, ...
^
src/cmdstan/main.cpp:7:26: note: in instantiation of function template
specialization 'stan::common::command<model_model_namespace::model_model>'
requested here
return stan::common::command<stan_model>(argc,argv);
^
1 error generated.
make: *** [model] Error 1
"""
####
I think, the problem is that I am trying to define an Eigen matrix of type
stan::agrad::var, and I do not suppose that Eigen is fine with it.
I can try to use another approach - technically, I can implement all the functions
I need in STAN language, but I still need those functions in some sort of callable form.
I could write a script that extracts the necessary functions from the 'model.cpp' file
produced by STAN, but then I do not know what to do with the pstream__ variable...
Or would it be simpler to write a script that makes C-functions from STAN?