Compilation issue after including algebra_solver(system, guess, theta, x_r, x_i); in the code

I am fitting a model that requires a call to algebra_solver. After including the call to algebra_solver(system, guess, theta, x_r, x_i); , the code fails to compile.
In order to test the code, I replaced the value that would be returned by algebra_solver with a constant. With the call to algebra_solver removed, the code compiles and runs (but obviously does not converge to anything).
I am wondering whether I need to write some wrapper for this function in a separate .hpp file? If so, it would be great if you could provide a little guidance.

The error message is as follows:

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! file1f41285cda55.cpp:6:36: warning: ISO C++11 requires whitespace after the macro name
 #define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
In file included from /usr/lib64/R/library/RcppEigen/include/Eigen/Core:392,
                 from /usr/lib64/R/library/RcppEigen/include/Eigen/Dense:1,
                 from /home/grad/hs182/R/x86_64-redhat-linux-gnu-library/3.6/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13,
                 from <command-line>:
/usr/lib64/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:60:39: warning: ignoring attributes on template argument ‘__m128’ {aka ‘__vector(4) float’} [-Wignored-attributes]
 template<> struct is_arithmetic<__m128>  { enum { value = true }; };
/usr/lib64/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:61:40: warning: ignori

Thank you!

We need the part of the error message that contains the word error:.

1 Like

The error message is as follows:

error: no matching function for call to 
‘algebra_solver(model1f41229635a5_external_namespace::system_functor__, Eigen::Matrix<stan::math::var, -1, 1>&, Eigen::Matrix<stan::math::var, -1, 1>&, const std::vector<stan::math::var>&, const std::vector<int>&, std::ostream*&)’

I figured out the issue.

The type of x_r was const std::vector<stan::math::var>& based on the compilation, whereas the type expected by function algebra_solver is const std::vector<double>&. This is caused by the fact that I did not declare x_r or x_i in the data or transformed data section—I simply declared them in the calling function of algebra_solver.

If this is the cause, please report the Stan version. Parser should be able to spot it before sending to linking.

My Stan version is 2.21.0.