I would like to use the function multi_normal_log in my C++ code.
The following simple program does not compile for me,
#include <stan/math.hpp>
#include <iostream>
int main() {
Eigen::Matrix<double, Eigen::Dynamic, 1> y(3, 1);
y << 2.0, -2.0, 11.0;
Eigen::Matrix<double, Eigen::Dynamic, 1> mu(3, 1);
mu << 1.0, -1.0, 3.0;
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> Sigma(3, 3);
Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0;
std::cout << stan::math::multi_normal_log(y, mu, Sigma);
return 0;
}
I have tried compiling from the command-line with,
icl -I[...include dirs...] stan-multi_normal_log-test.cpp
which gives the following error message,
error LNK2019: unresolved external symbol "void __cdecl boost::throw_exception(class std::exception const &)" (?throw_exception@boost@@YAXAEBVexception@std@@@Z) referenced in function "double __cdecl stan::math::multi_normal_lpdf<0,class Eigen::Matrix<double,-1,1,0,-1,1>,class Eigen::Matrix<double,-1,1,0,-1,1>,class Eigen::Matrix<double,-1,-1,0,-1,-1> >(class Eigen::Matrix<double,-1,1,0,-1,1> const &,class Eigen::Matrix<double,-1,1,0,-1,1> const &,class Eigen::Matrix<double,-1,-1,0,-1,-1> const &)" (??$multi_normal_lpdf@$0A@V?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@V12@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@2@@math@stan@@YANAEBV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@0AEBV?$Matrix@N$0?0$0?0$0A@$0?0$0?0@3@@Z)
stan-multi_normal_log-test.exe : fatal error LNK1120: 1 unresolved externals
And from Visual Studio, which gives the following error messages,
Error C2672 'trace_inv_quad_form_ldlt': no matching overloaded function found npm-inference c:\cygwin64\home\philip\stan-dev\math\stan\math\prim\mat\prob\multi_normal_lpdf.hpp 107
Error C2782 'boost::enable_if_c<stan::is_var<T>::value||stan::is_var<T3>::value,stan::math::var>::type stan::math::trace_inv_quad_form_ldlt(const stan::math::LDLT_factor<T,R,C> &,const Eigen::Matrix<T2,R2,C2,|_Rows==&&_Cols!=?:_Cols==&&_Rows!=?:,_Rows,_Cols> &)': template parameter '_Cols' is ambiguous npm-inference c:\cygwin64\home\philip\stan-dev\math\stan\math\prim\mat\prob\multi_normal_lpdf.hpp 107
Error C2784 'boost::enable_if_c<stan::is_var<T>::value||stan::is_var<T3>::value,stan::math::var>::type stan::math::trace_inv_quad_form_ldlt(const stan::math::LDLT_factor<T,R,C> &,const Eigen::Matrix<T2,R2,C2,|_Rows==&&_Cols!=?:_Cols==&&_Rows!=?:,_Rows,_Cols> &)': could not deduce template argument for 'const Eigen::Matrix<T2,R2,C2,|_Rows==&&_Cols!=?:_Cols==&&_Rows!=?:,_Rows,_Cols> &' from 'Eigen::Matrix<double,-1,1,0,-1,1>' npm-inference c:\cygwin64\home\philip\stan-dev\math\stan\math\prim\mat\prob\multi_normal_lpdf.hpp 107
Error C2784 'boost::enable_if_c<!stan::is_var<T>::value&&!stan::is_var<T2>::value,boost::math::tools::promote_args<RT1,RT2,float,float,float,float>::type>::type stan::math::trace_inv_quad_form_ldlt(const stan::math::LDLT_factor<T1,R2,C2> &,const Eigen::Matrix<T2,R2,C2,|_Rows==&&_Cols!=?:_Cols==&&_Rows!=?:,_Rows,_Cols> &)': could not deduce template argument for 'const Eigen::Matrix<T2,R2,C2,|_Rows==&&_Cols!=?:_Cols==&&_Rows!=?:,_Rows,_Cols> &' from 'Eigen::Matrix<double,-1,1,0,-1,1>' npm-inference c:\cygwin64\home\philip\stan-dev\math\stan\math\prim\mat\prob\multi_normal_lpdf.hpp 107