Closed charlesm93 closed 8 years ago
There isn't a limit. You're just need to use this signature:
void function_signatures::add(const std::string& name,
const expr_type& result_type,
const std::vector<expr_type>& arg_types);
P.S. This was a stan-dev/stan issue, because the function signatures are defined there, not in stan-dev/math. Sorry that's not clear coming from StanHeaders, which is presumably the RStan packaged version.
Hi Bob,
Thank you for your quick response and apologies for not posting this under stan-dev/stan.
I'm under the impression the signature you posted is the function I used: name for the first argument, return type for the second argument, and then argument types. (I didn't make this clear in the original post and did a quick edit to clarify).
Your description has this:
add("PKModelTwoCpt", MATRIX_T, MATRIX_T, VECTOR_T, VECTOR_T, VECTOR_T, VECTOR_T, VECTOR_T, VECTOR_T, VECTOR_T, VECTOR_T);
What I'm suggesting is:
std::vector<expr_type> arg_types;
arg_types.push_back(expr_type(MATRIX_T, 0U));
arg_types.push_back(expr_type(VECTOR_T, 0U);
...
arg_types.push_back(expr_type(VECTOR_T, 0U));
add("PKModelTwoCpt", MATRIX_T, arg_types);
I think you may be able to get away without the expr_type wrappers and just (MATRIX_T)
, etc., because there's a unary implicit constructor taking the basic type.
Thank you for the clarification ! I was able to install RStan both with and without the expr_type wrappers.
Feature Request
Increase the maximum number of arguments for C++ functions that can be added to the Stan/math library.
Version 2.7.0
Description I am writing a function that computes dosing events for compartmental models used in pharmacometrics. Using a .hpp file, I created a function that takes in 9 arguments, but it seems the limit is set to 7. The add() function used in functions_signatures.hpp seems to take between 2 and 9 arguments, the first argument being the name of the function and the second one the return type.
Is there a reason why this limit exists? And if not, would editing the add() function be the best approach?
Steps The line in function_signatures.hpp that returns an error is:
add("PKModelTwoCpt", MATRIX_T, MATRIX_T, VECTOR_T, VECTOR_T, VECTOR_T, VECTOR_T, VECTOR_T, VECTOR_T, VECTOR_T, VECTOR_T);
The following error message appears when I try to install RStan using the edited StanHeaders directory:
~/StanHeaders/include/src/stan/lang/function_signatures.h:960:1: error: no matching member function for call to 'add' add("PKModelTwoCpt", MATRIX_T, MATRIX_T, VECTOR_T, VECTOR_T, VECTOR_T, VECTOR_T, ^~~ ~/StanHeaders/include/src/stan/lang/ast_def.cpp:259:31: note: candidate function not viable: requires 9 arguments, but 11 were provided void function_signatures::add(const std::string& name, ^ ~/StanHeaders/include/src/stan/lang/ast_def.cpp:242:31: note: candidate function not viable: requires 8 arguments, but 11 were provided
The error message repeats itself until the required number of arguments is 2.