1 #ifndef STAN_LANG_GRAMMARS_SEMANTIC_ACTIONS_DEF_CPP 2 #define STAN_LANG_GRAMMARS_SEMANTIC_ACTIONS_DEF_CPP 7 #include <boost/format.hpp> 8 #include <boost/spirit/include/qi.hpp> 9 #include <boost/variant/apply_visitor.hpp> 10 #include <boost/variant/recursive_variant.hpp> 46 if (f.
args_.size() > 0)
return;
49 || f.
name_ ==
"not_a_number" || f.
name_ ==
"positive_infinity" 50 || f.
name_ ==
"negative_infinity" || f.
name_ ==
"machine_precision")
64 if (f.
args_.size() == 1
71 else if (f.
args_.size() == 2
73 || f.
name_ ==
"hypot"))
75 else if (f.
args_.size() == 3 && f.
name_ ==
"fma")
85 const std::string& new_suffix,
fun& f) {
92 bool deprecate_fun(
const std::string& old_name,
const std::string& new_name,
93 fun& f, std::ostream& msgs) {
94 if (f.
name_ != old_name)
return false;
97 msgs <<
"Warning: Function name '" << old_name <<
"' is deprecated" 98 <<
" and will be removed in a later release; please replace" 99 <<
" with '" << new_name <<
"'" << std::endl;
104 const std::string& replacement,
fun& f,
105 std::ostream& msgs) {
107 msgs <<
"Warning: Deprecated function '" << f.
name_ <<
"';" 108 <<
" please replace suffix '" << deprecated_suffix
109 <<
"' with " << replacement << std::endl;
115 std::stringstream& error_msgs)
119 error_msgs <<
"expression denoting real required; found type=" 129 std::vector<expr_type> arg_types;
130 for (
size_t i = 0; i < fun.
args_.size(); ++i)
131 arg_types.push_back(fun.
args_[i].expression_type());
136 int num_dimss(std::vector<std::vector<stan::lang::expression> >& dimss) {
138 for (
size_t i = 0; i < dimss.size(); ++i)
139 sum += dimss[i].size();
143 template <
typename L,
typename R>
162 const std::vector<var_decl>&)
const;
164 const std::vector<idx>&)
const;
166 std::vector<std::vector<expression> >&,
167 const std::vector<std::vector<expression> >&)
const;
172 std::ostream& error_msgs)
const {
175 error_msgs <<
"expression is ill formed" << std::endl;
186 std::ostream& error_msgs)
const {
192 std::vector<expression> args;
193 args.push_back(expr1);
194 args.push_back(expr2);
203 std::ostream& error_msgs)
const {
209 std::vector<expression> args;
210 args.push_back(expr1);
211 args.push_back(expr2);
212 fun f(
"subtract", args);
228 std::ostream& error_msgs)
const {
231 error_msgs <<
"condition in ternary expression must be" 232 <<
" primitive int or real;" 233 <<
" found type=" << cond_type
243 bool types_compatible
244 = (true_val_type == false_val_type)
246 && (true_val_base_type == false_val_base_type
248 && false_val_base_type ==
INT_T)
249 || (true_val_base_type ==
INT_T 250 && false_val_base_type ==
DOUBLE_T)));
252 if (!types_compatible) {
253 error_msgs <<
"base type mismatch in ternary expression," 254 <<
" expression when true is: ";
256 error_msgs <<
"; expression when false is: ";
258 error_msgs << std::endl;
265 = (true_val_base_type == false_val_base_type)
269 conditional_op.
type_ = true_val_type;
275 boost::phoenix::function<validate_conditional_op>
279 const std::string& op,
280 const std::string& fun_name,
281 std::ostream& error_msgs)
const {
284 error_msgs <<
"binary infix operator " << op
285 <<
" with functional interpretation " << fun_name
286 <<
" requires arguments or primitive type (int or real)" 292 std::vector<expression> args;
293 args.push_back(expr1);
294 args.push_back(expr2);
295 fun f(fun_name, args);
303 std::ostream& error_msgs)
const {
306 error_msgs <<
"Functions cannot contain void argument types; " 307 <<
"found void argument." 310 boost::phoenix::function<validate_non_void_arg_function>
315 std::ostream& error_msgs)
const {
317 error_msgs <<
"Void return type may not have dimensions declared." 330 bool& allow_sampling,
332 bool is_void_function_origin
335 allow_sampling =
true;
336 origin = is_void_function_origin
339 }
else if (
ends_with(
"_rng", identifier)) {
340 allow_sampling =
false;
341 origin = is_void_function_origin
345 allow_sampling =
false;
346 origin = is_void_function_origin
351 boost::phoenix::function<set_allows_sampling_origin>
355 std::set<std::pair<std::string,
357 std::set<std::pair<std::string,
359 std::ostream& error_msgs,
360 bool allow_undefined)
const {
364 typedef set<pair<string, function_signature_t> >::iterator iterator_t;
365 if (!allow_undefined) {
366 for (iterator_t it = declared.begin(); it != declared.end(); ++it) {
367 if (defined.find(*it) == defined.end()) {
368 error_msgs <<
"Function declared, but not defined." 369 <<
" Function name=" << (*it).first
383 const std::pair<std::string,
385 bool name_only =
true) {
386 for (std::set<std::pair<std::string,
389 it != existing.end();
391 if (name_sig.first == (*it).first
393 || name_sig.second.second == (*it).second.second))
399 std::ostream& error_msgs)
const {
406 error_msgs <<
"Parse Error. Probability function already defined" 407 <<
" for " << dist_name << std::endl;
416 error_msgs <<
" Parse Error. CDF already defined for " 417 << dist_name << std::endl;
426 error_msgs <<
" Parse Error. CCDF already defined for " 427 << dist_name << std::endl;
437 std::set<std::pair<std::string, function_signature_t> >&
439 std::set<std::pair<std::string, function_signature_t> >&
441 std::ostream& error_msgs)
const {
445 std::vector<expr_type> arg_types;
446 for (
size_t i = 0; i < decl.
arg_decls_.size(); ++i)
451 std::pair<std::string, function_signature_t> name_sig(decl.
name_, sig);
454 &&
fun_exists(functions_declared, name_sig)) {
455 error_msgs <<
"Parse Error. Function already declared, name=" 462 if (
fun_exists(functions_defined, name_sig)) {
463 error_msgs <<
"Parse Error. Function already defined, name=" 472 error_msgs <<
"Parse Error. Function system defined, name=" 480 error_msgs <<
"Parse Error. Probability density functions require" 481 <<
" real variates (first argument)." 482 <<
" Found type = " << arg_types[0] << std::endl;
487 error_msgs <<
"Parse Error. Probability mass functions require" 488 <<
" integer variates (first argument)." 489 <<
" Found type = " << arg_types[0] << std::endl;
495 if (functions_declared.find(name_sig) == functions_declared.end()) {
496 functions_declared.insert(name_sig);
498 .
add(decl.
name_, result_type, arg_types);
504 functions_defined.insert(name_sig);
512 std::ostream& error_msgs)
517 error_msgs <<
"Parse Error. Probability functions require" 518 <<
" at least one argument." << std::endl;
524 error_msgs <<
"Parse Error. Probability density functions require" 525 <<
" real variates (first argument)." 526 <<
" Found type = " << variate_type << std::endl;
531 error_msgs <<
"Parse Error. Probability mass functions require" 532 <<
" integer variates (first argument)." 533 <<
" Found type = " << variate_type << std::endl;
538 boost::phoenix::function<validate_pmf_pdf_variate>
543 std::ostream& error_msgs)
const {
548 error_msgs <<
"Improper return in body of function." << std::endl;
559 error_msgs <<
"Require real return type for probability functions" 560 <<
" ending in _log, _lpdf, _lpmf, _lcdf, or _lccdf." 576 for (
size_t i = 0; i < decl.
arg_decls_.size(); ++i)
582 std::ostream& error_msgs)
const {
586 error_msgs <<
"duplicate declaration of variable, name=" 588 <<
"; attempt to redeclare as function argument" 589 <<
"; original declaration as ";
591 error_msgs << std::endl;
610 boost::phoenix::function<validate_int_expr_silent>
615 std::ostream& error_msgs)
618 error_msgs <<
"ERROR: Indexes must be expressions of integer type." 621 error_msgs <<
'.' << std::endl;
625 boost::phoenix::function<validate_int_expression_warn>
630 std::ostream& error_msgs)
const {
632 error_msgs <<
"ERROR: Container index must be integer; found type=";
634 error_msgs << std::endl;
641 error_msgs <<
"index must be integer or 1D integer array;" 642 <<
" found number of dimensions=" 655 boost::phoenix::function<validate_ints_expression>
677 std::stringstream& error_msgs)
const {
678 using boost::spirit::get_line;
682 size_t idx_errline = get_line(_where);
684 error_msgs << std::endl;
686 if (idx_errline > 0) {
687 error_msgs <<
"ERROR at line " << idx_errline
688 << std::endl << std::endl;
690 std::basic_stringstream<char> sprogram;
691 sprogram << boost::make_iterator_range(_begin, _end);
694 size_t idx_errcol = 0;
695 idx_errcol = get_column(_begin, _where) - 1;
697 std::string lineno =
"";
698 format fmt_lineno(
"% 3d: ");
700 std::string line_2before =
"";
701 std::string line_before =
"";
702 std::string line_err =
"";
703 std::string line_after =
"";
706 size_t idx_before = idx_errline - 1;
707 if (idx_before > 0) {
709 while (idx_before > idx_line) {
710 line_2before = line_before;
711 std::getline(sprogram, line_before);
714 if (line_2before.length() > 0) {
715 lineno = str(fmt_lineno % (idx_before - 1) );
716 error_msgs << lineno << line_2before << std::endl;
718 lineno = str(fmt_lineno % idx_before);
719 error_msgs << lineno << line_before << std::endl;
722 std::getline(sprogram, line_err);
723 lineno = str(fmt_lineno % idx_errline);
724 error_msgs << lineno << line_err << std::endl
725 << setw(idx_errcol + lineno.length()) <<
"^" << std::endl;
727 if (!sprogram.eof()) {
728 std::getline(sprogram, line_after);
729 lineno = str(fmt_lineno % (idx_errline+1));
730 error_msgs << lineno << line_after << std::endl;
733 error_msgs << std::endl;
740 std::stringstream& error_msgs)
743 error_msgs <<
"conditions in if-else statement must be" 744 <<
" primitive int or real;" 754 boost::phoenix::function<add_conditional_condition>
765 error_msgs <<
"Warning (non-fatal): assignment operator <- deprecated" 766 <<
" in the Stan language;" 770 boost::phoenix::function<deprecate_old_assignment_op>
774 std::ostream& error_msgs)
const {
778 error_msgs <<
"Returns only allowed from function bodies." 789 std::ostream& error_msgs)
794 error_msgs <<
"Void returns only allowed from function" 795 <<
" bodies of void return type." 802 boost::phoenix::function<validate_void_return_allowed>
809 std::ostream& error_msgs)
const {
818 && lhs_origin != origin_allowed) {
839 std::ostream& error_msgs)
const {
845 error_msgs <<
"Left-hand side indexing incompatible with variable." 855 bool types_compatible
856 = lhs_base_type == rhs_base_type
858 if (!types_compatible) {
859 error_msgs <<
"base type mismatch in assignment" 860 <<
"; variable name=" 864 error_msgs <<
"; right-hand side type=";
866 error_msgs << std::endl;
872 error_msgs <<
"dimension mismatch in assignment" 873 <<
"; variable name=" 875 <<
", num dimensions given=" 877 <<
"; right-hand side dimensions=" 886 error_msgs <<
"WARNING: left-hand side variable" 887 <<
" (name=" << name <<
")" 888 <<
" occurs on right-hand side of assignment, causing" 889 <<
" inefficient deep copy to avoid aliasing." 900 std::ostream& error_msgs)
const {
904 error_msgs <<
"unknown variable in assignment" 915 && lhs_origin != origin_allowed) {
916 error_msgs <<
"attempt to assign variable in wrong block." 917 <<
" left-hand-side variable origin=";
919 error_msgs << std::endl;
931 error_msgs <<
"Illegal to assign to function argument variables." 933 <<
"Use local variables instead." 949 error_msgs <<
"too many indexes for variable " 950 <<
"; variable name = " << name
951 <<
"; num dimensions given = " << num_index_dims
952 <<
"; variable array dimensions = " << lhs_var_num_dims
961 bool types_compatible
962 = lhs_base_type == rhs_base_type
964 if (!types_compatible) {
965 error_msgs <<
"base type mismatch in assignment" 966 <<
"; variable name = " 970 error_msgs <<
"; right-hand side type=";
972 error_msgs << std::endl;
978 error_msgs <<
"dimension mismatch in assignment" 979 <<
"; variable name = " 981 <<
", num dimensions given = " 983 <<
"; right-hand side dimensions = " 995 const std::vector<expr_type>& arg_types) {
1002 const std::vector<expr_type>& arg_types,
1003 std::ostream& error_msgs) {
1017 std::ostream& error_msgs)
const {
1018 static const bool user_facing =
true;
1019 std::vector<expr_type> arg_types;
1021 for (
size_t i = 0; i < s.
dist_.
args_.size(); ++i)
1022 arg_types.push_back(s.
dist_.
args_[i].expression_type());
1024 std::string internal_function_name =
get_prob_fun(function_name);
1028 if (internal_function_name.size() == 0) {
1030 error_msgs <<
"Error: couldn't find distribution named " 1031 << function_name << std::endl;
1035 if ((internal_function_name.find(
"multiply_log") != std::string::npos)
1036 || (internal_function_name.find(
"binomial_coefficient_log")
1037 != std::string::npos)) {
1038 error_msgs <<
"Only distribution names can be used with" 1039 <<
" sampling (~) notation; found non-distribution" 1040 <<
" function: " << function_name
1046 if (internal_function_name.find(
"cdf_log") != std::string::npos) {
1047 error_msgs <<
"CDF and CCDF functions may not be used with" 1048 <<
" sampling notation." 1049 <<
" Use increment_log_prob(" 1050 << internal_function_name <<
"(...)) instead." 1056 if (internal_function_name ==
"lkj_cov_log") {
1057 error_msgs <<
"Warning: the lkj_cov_log() sampling distribution" 1058 <<
" is deprecated. It will be removed in Stan 3." 1060 <<
"Code LKJ covariance in terms of an lkj_corr()" 1061 <<
" distribution on a correlation matrix" 1062 <<
" and independent lognormals on the scales." 1063 << std::endl << std::endl;
1067 error_msgs <<
"require real scalar return type for" 1068 <<
" probability function." << std::endl;
1074 error_msgs <<
"Warning (non-fatal):" 1076 <<
"Left-hand side of sampling statement (~) may contain a" 1077 <<
" non-linear transform of a parameter or local variable." 1079 <<
"If it does, you need to include a target += statement" 1080 <<
" with the log absolute determinant of the Jacobian of" 1081 <<
" the transform." 1083 <<
"Left-hand-side of sampling statement:" 1087 error_msgs <<
" ~ " << function_name <<
"(...)" 1093 error_msgs <<
"Outcomes in truncated distributions" 1094 <<
" must be univariate." 1096 <<
" Found outcome expression: ";
1098 error_msgs << std::endl
1099 <<
" with non-univariate type: " 1105 for (
size_t i = 0; i < s.
dist_.
args_.size(); ++i)
1107 error_msgs <<
"Parameters in truncated distributions" 1108 <<
" must be univariate." 1110 <<
" Found parameter expression: ";
1112 error_msgs << std::endl
1113 <<
" with non-univariate type: " 1122 error_msgs <<
"Lower bounds in truncated distributions" 1123 <<
" must be univariate." 1125 <<
" Found lower bound expression: ";
1127 error_msgs << std::endl
1128 <<
" with non-univariate type: " 1136 error_msgs <<
"Upper bounds in truncated distributions" 1137 <<
" must be univariate." 1139 <<
" Found upper bound expression: ";
1141 error_msgs << std::endl
1142 <<
" with non-univariate type: " 1152 std::vector<expr_type> arg_types_trunc(arg_types);
1158 error_msgs <<
"lower truncation not defined for specified" 1165 error_msgs <<
"lower bound in truncation type does not match" 1166 <<
" sampled variate in distribution's type" 1174 std::vector<expr_type> arg_types_trunc(arg_types);
1180 error_msgs <<
"upper truncation not defined for" 1181 <<
" specified arguments to " 1188 error_msgs <<
"upper bound in truncation type does not match" 1189 <<
" sampled variate in distribution's type" 1197 std::vector<expr_type> arg_types_trunc(arg_types);
1203 error_msgs <<
"lower truncation not defined for specified" 1210 error_msgs <<
"lower bound in truncation type does not match" 1211 <<
" sampled variate in distribution's type" 1224 std::stringstream& error_msgs)
const {
1225 static const bool user_facing =
true;
1227 error_msgs <<
"Illegal statement beginning with non-void" 1228 <<
" expression parsed as" 1229 << std::endl <<
" ";
1231 error_msgs << std::endl
1232 <<
"Not a legal assignment, sampling, or function" 1233 <<
" statement. Note that" 1235 <<
" * Assignment statements only allow variables" 1236 <<
" (with optional indexes) on the left;" 1238 <<
" if you see an outer function logical_lt (<)" 1239 <<
" with negated (-) second argument," 1241 <<
" it indicates an assignment statement A <- B" 1242 <<
" with illegal left" 1244 <<
" side A parsed as expression (A < (-B))." 1246 <<
" * Sampling statements allow arbitrary" 1247 <<
" value-denoting expressions on the left." 1249 <<
" * Functions used as statements must be" 1250 <<
" declared to have void returns" 1251 << std::endl << std::endl;
1261 for (
size_t i = 0; i < var_decls.size(); ++i)
1262 vm.
remove(var_decls[i].name());
1268 std::stringstream& error_msgs)
const {
1271 error_msgs <<
"conditions in while statement must be primitive" 1287 std::string& name_local,
1289 std::stringstream& error_msgs)
const {
1293 error_msgs <<
"ERROR: loop variable already declared." 1294 <<
" variable name=\"" << name <<
"\"" << std::endl;
1309 std::stringstream& error_msgs)
1312 error_msgs <<
"expression denoting integer required; found type=" 1322 std::stringstream& error_msgs)
const {
1323 error_msgs <<
"Warning (non-fatal): increment_log_prob(...);" 1324 <<
" is deprecated and will be removed in the future." 1326 <<
" Use target += ...; instead." 1329 boost::phoenix::function<deprecate_increment_log_prob>
1334 std::stringstream& error_msgs)
1336 pass = allow_sample;
1338 error_msgs <<
"Sampling statements (~) and increment_log_prob() are" 1340 <<
"only allowed in the model block." 1347 std::ostream& error_msgs)
1351 error_msgs <<
"attempt to increment log prob with void expression" 1354 boost::phoenix::function<validate_non_void_expression>
1379 error_msgs <<
"Warning: the integrate_ode() function is deprecated" 1380 <<
" in the Stan language; use integrate_ode_rk45() [non-stiff]" 1381 <<
" or integrate_ode_bdf() [stiff] instead." 1384 boost::phoenix::function<deprecated_integrate_ode>
1391 std::ostream& error_msgs) {
1395 std::vector<expr_type> sys_arg_types;
1403 .
is_defined(ode_fun.system_function_name_, system_signature)) {
1404 error_msgs <<
"first argument to " 1405 << ode_fun.integration_function_name_
1406 <<
" must be the name of a function with signature" 1407 <<
" (real, real[], real[], real[], int[]) : real[] ";
1413 error_msgs <<
"second argument to " 1414 << ode_fun.integration_function_name_
1415 <<
" must have type real[] for intial system state;" 1417 << ode_fun.y0_.expression_type()
1421 if (!ode_fun.t0_.expression_type().is_primitive()) {
1422 error_msgs <<
"third argument to " 1423 << ode_fun.integration_function_name_
1424 <<
" must have type real or int for initial time;" 1426 << ode_fun.t0_.expression_type()
1431 error_msgs <<
"fourth argument to " 1432 << ode_fun.integration_function_name_
1433 <<
" must have type real[]" 1434 <<
" for requested solution times; found type=" 1435 << ode_fun.ts_.expression_type()
1440 error_msgs <<
"fifth argument to " 1441 << ode_fun.integration_function_name_
1442 <<
" must have type real[] for parameters; found type=" 1443 << ode_fun.theta_.expression_type()
1448 error_msgs <<
"sixth argument to " 1449 << ode_fun.integration_function_name_
1450 <<
" must have type real[] for real data; found type=" 1451 << ode_fun.x_.expression_type()
1456 error_msgs <<
"seventh argument to " 1457 << ode_fun.integration_function_name_
1458 <<
" must have type int[] for integer data; found type=" 1459 << ode_fun.x_int_.expression_type()
1465 if (
has_var(ode_fun.t0_, var_map)) {
1466 error_msgs <<
"third argument to " 1467 << ode_fun.integration_function_name_
1468 <<
" (initial times)" 1469 <<
" must be data only and not reference parameters";
1472 if (
has_var(ode_fun.ts_, var_map)) {
1473 error_msgs <<
"fourth argument to " 1474 << ode_fun.integration_function_name_
1475 <<
" (solution times)" 1476 <<
" must be data only and not reference parameters";
1479 if (
has_var(ode_fun.x_, var_map)) {
1480 error_msgs <<
"sixth argument to " 1481 << ode_fun.integration_function_name_
1483 <<
" must be data only and not reference parameters";
1491 std::ostream& error_msgs)
const {
1500 std::ostream& error_msgs)
const {
1504 error_msgs <<
"eighth argument to " 1506 <<
" (relative tolerance) must have type real or int;" 1513 error_msgs <<
"ninth argument to " 1515 <<
" (absolute tolerance) must have type real or int;" 1522 error_msgs <<
"tenth argument to " 1524 <<
" (max steps) must have type real or int;" 1533 error_msgs <<
"eight argument to " 1535 <<
" (relative tolerance) must be data only" 1536 <<
" and not depend on parameters";
1540 error_msgs <<
"ninth argument to " 1542 <<
" (absolute tolerance ) must be data only" 1543 <<
" and not depend parameters";
1547 error_msgs <<
"tenth argument to " 1549 <<
" (max steps) must be data only" 1550 <<
" and not depend on parameters";
1554 boost::phoenix::function<validate_integrate_ode_control>
1560 std::ostream& error_msgs)
const {
1561 if (fun.
name_ ==
"get_lp")
1562 error_msgs <<
"Warning (non-fatal): get_lp() function deprecated." 1564 <<
" It will be removed in a future release." 1566 <<
" Use target() instead." 1568 if (fun.
name_ ==
"target")
1569 fun.
name_ =
"get_lp";
1571 std::vector<expr_type> arg_types;
1572 for (
size_t i = 0; i < fun.
args_.size(); ++i)
1573 arg_types.push_back(fun.
args_[i].expression_type());
1583 deprecate_fun(
"binomial_coefficient_log",
"lchoose", fun, error_msgs)
1584 ||
deprecate_fun(
"multiply_log",
"lmultiply", fun, error_msgs)
1588 "'_lpdf' for density functions or '_lpmf' for mass functions",
1610 error_msgs <<
"ERROR: random number generators only allowed in" 1611 <<
" transformed data block, generated quantities block" 1612 <<
" or user-defined functions with names ending in _rng" 1613 <<
"; found function=" << fun.
name_ <<
" in block=";
1615 error_msgs << std::endl;
1628 error_msgs <<
"Function target() or functions suffixed with _lp only" 1629 <<
" allowed in transformed parameter block, model block" 1631 <<
"or the body of a function with suffix _lp." 1633 <<
"Found function = " 1634 << (fun.
name_ ==
"get_lp" ?
"target or get_lp" : fun.
name_)
1637 error_msgs << std::endl;
1643 if (fun.
name_ ==
"max" || fun.
name_ ==
"min") {
1644 if (fun.
args_.size() == 2) {
1645 if (fun.
args_[0].expression_type().is_primitive_int()
1646 && fun.
args_[1].expression_type().is_primitive_int()) {
1652 if (fun.
name_ ==
"abs" 1653 && fun.
args_.size() > 0
1654 && fun.
args_[0].expression_type().is_primitive_double()) {
1655 error_msgs <<
"Warning: Function abs(real) is deprecated" 1656 <<
" in the Stan language." 1658 <<
" It will be removed in a future release." 1660 <<
" Use fabs(real) instead." 1661 << std::endl << std::endl;
1664 if (fun.
name_ ==
"lkj_cov_log") {
1665 error_msgs <<
"Warning: the lkj_cov_log() function" 1666 <<
" is deprecated. It will be removed in Stan 3." 1668 <<
"Code LKJ covariance in terms of an lkj_corr()" 1669 <<
" distribution on a correlation matrix" 1670 <<
" and independent lognormals on the scales." 1671 << std::endl << std::endl;
1674 if (fun.
name_ ==
"if_else") {
1675 error_msgs <<
"Warning (non-fatal): the if_else() function" 1676 <<
" is deprecated. " 1677 <<
"Use the conditional operator '?:' instead." 1690 std::ostream& error_msgs)
const {
1693 error_msgs <<
"arguments to ^ must be primitive (real or int)" 1694 <<
"; cannot exponentiate " 1700 error_msgs << std::endl;
1704 std::vector<expression> args;
1705 args.push_back(expr1);
1706 args.push_back(expr2);
1715 std::ostream& error_msgs)
const {
1721 std::vector<expression> args;
1722 args.push_back(expr1);
1723 args.push_back(expr2);
1724 fun f(
"multiply", args);
1732 std::ostream& error_msgs)
const {
1733 static const bool user_facing =
true;
1741 std::vector<expression> args;
1742 args.push_back(expr1);
1743 args.push_back(expr2);
1747 error_msgs <<
"Warning: integer division" 1748 <<
" implicitly rounds to integer." 1749 <<
" Found int division: ";
1751 error_msgs <<
" / ";
1753 error_msgs << std::endl
1754 <<
" Positive values rounded down," 1755 <<
" negative values rounded up or down" 1756 <<
" in platform-dependent way." 1759 fun f(
"divide", args);
1767 fun f(
"mdivide_right", args);
1772 fun f(
"divide", args);
1780 bool& pass, std::ostream& error_msgs)
const {
1783 error_msgs <<
"both operands of % must be int" 1784 <<
"; cannot modulo " 1788 error_msgs << std::endl;
1792 std::vector<expression> args;
1793 args.push_back(expr1);
1794 args.push_back(expr2);
1795 fun f(
"modulus", args);
1803 std::ostream& error_msgs)
const {
1804 std::vector<expression> args;
1805 args.push_back(expr1);
1806 args.push_back(expr2);
1810 fun f(
"mdivide_left", args);
1816 fun f(
"mdivide_left", args);
1825 std::ostream& error_msgs)
const {
1831 std::vector<expression> args;
1832 args.push_back(expr1);
1833 args.push_back(expr2);
1834 fun f(
"elt_multiply", args);
1842 std::ostream& error_msgs)
const {
1848 std::vector<expression> args;
1849 args.push_back(expr1);
1850 args.push_back(expr2);
1851 fun f(
"elt_divide", args);
1859 std::ostream& error_msgs)
const {
1864 std::vector<expression> args;
1865 args.push_back(expr);
1866 fun f(
"minus", args);
1874 std::ostream& error_msgs)
const {
1876 error_msgs <<
"logical negation operator !" 1877 <<
" only applies to int or real types; ";
1880 std::vector<expression> args;
1881 args.push_back(expr);
1882 fun f(
"logical_negation", args);
1889 std::ostream& error_msgs)
const {
1892 std::vector<expression> args;
1893 args.push_back(expr);
1894 fun f(
"transpose", args);
1902 bool& pass, std::ostream& error_msgs)
const {
1906 error_msgs <<
"Indexed expression must have at least as many" 1907 <<
" dimensions as number of indexes supplied:" 1909 <<
" indexed expression dims=" 1911 <<
"; num indexes=" << idxs.size()
1917 std::vector<std::vector<stan::lang::expression> >& dimss,
1918 bool& pass, std::ostream& error_msgs)
const {
1922 if (expr_dims < index_dims) {
1923 error_msgs <<
"Indexed expression must have at least as many" 1924 <<
" dimensions as number of indexes supplied: " 1926 <<
" indexed expression dimensionality = " << expr_dims
1927 <<
"; indexes supplied = " << dimss.size()
1934 error_msgs <<
"Indexed expression must have at least as many" 1935 <<
" dimensions as number of indexes supplied." 1947 std::ostream& error_msgs,
bool& pass)
const {
1948 std::string name = var_expr.
name_;
1949 if (name == std::string(
"lp__")) {
1950 error_msgs << std::endl
1951 <<
"ERROR (fatal): Use of lp__ is no longer supported." 1953 <<
" Use target += ... statement to increment log density." 1955 <<
" Use target() function to get log density." 1959 }
else if (name == std::string(
"params_r__")) {
1960 error_msgs << std::endl <<
"WARNING:" << std::endl
1961 <<
" Direct access to params_r__ yields an inconsistent" 1962 <<
" statistical model in isolation and no guarantee is" 1963 <<
" made that this model will yield valid inferences." 1965 <<
" Moreover, access to params_r__ is unsupported" 1966 <<
" and the variable may be removed without notice." 1973 error_msgs <<
"variable \"" << name <<
'"' <<
" does not exist." 1983 error_msgs <<
"Probabilty functions with suffixes _lpdf, _lpmf," 1984 <<
" _lcdf, and _lccdf," << std::endl
1985 <<
"require a vertical bar (|) between the first two" 1986 <<
" arguments." << std::endl;
1993 std::stringstream& error_msgs)
1994 : error_msgs_(error_msgs) { }
2003 <<
" found range constraint." << std::endl;
2012 <<
" found range constraint." << std::endl;
2021 <<
" found range constraint." << std::endl;
2030 <<
" found range constraint." << std::endl;
2039 <<
" found range constraint." << std::endl;
2046 error_msgs_ <<
"require unconstrained variable declaration." 2047 <<
" found unit_vector." << std::endl;
2052 error_msgs_ <<
"require unconstrained variable declaration." 2053 <<
" found simplex." << std::endl;
2058 error_msgs_ <<
"require unconstrained variable declaration." 2059 <<
" found ordered." << std::endl;
2064 error_msgs_ <<
"require unconstrained variable declaration." 2065 <<
" found positive_ordered." << std::endl;
2070 error_msgs_ <<
"require unconstrained variable declaration." 2071 <<
" found cholesky_factor." << std::endl;
2076 error_msgs_ <<
"require unconstrained variable declaration." 2077 <<
" found cholesky_factor_corr." << std::endl;
2082 error_msgs_ <<
"require unconstrained variable declaration." 2083 <<
" found cov_matrix." << std::endl;
2088 error_msgs_ <<
"require unconstrained variable declaration." 2089 <<
" found corr_matrix." << std::endl;
2109 for (
size_t i = 0; i < x.
args_.size(); ++i)
2110 if (!boost::apply_visitor(*
this, x.
args_[i].expr_))
2121 <<
" in dimension declarations." 2123 <<
" found variable=" << x.
name_ 2124 <<
"; declared in block=";
2131 return boost::apply_visitor(*
this, x.
y0_.
expr_)
2136 return boost::apply_visitor(*
this, x.
y0_.
expr_)
2140 for (
size_t i = 0; i < x.
args_.size(); ++i)
2141 if (!boost::apply_visitor(*
this, x.
args_[i].expr_))
2146 if (!boost::apply_visitor(*
this, x.
expr_.
expr_))
2148 for (
size_t i = 0; i < x.
dimss_.size(); ++i)
2149 for (
size_t j = 0; j < x.
dimss_[i].size(); ++j)
2150 if (!boost::apply_visitor(*
this, x.
dimss_[i][j].expr_))
2155 return boost::apply_visitor(*
this, x.
expr_.
expr_);
2158 return boost::apply_visitor(*
this, x.
cond_.
expr_)
2163 return boost::apply_visitor(*
this, x.
left.
expr_)
2164 && boost::apply_visitor(*
this, x.
right.
expr_);
2171 const bool& declaration_ok,
2174 std::stringstream& error_msgs)
2176 if (!declaration_ok) {
2177 error_msgs <<
"Problem with declaration." << std::endl;
2181 if (allow_constraints) {
2186 pass = boost::apply_visitor(vis, var_decl.
decl_);
2188 boost::phoenix::function<validate_decl_constraints>
2194 std::stringstream& error_msgs)
2196 if (!var_decl.
has_def())
return;
2201 error_msgs <<
"variable definition not possible in this block" 2208 var_decl.
dims().size());
2211 bool types_compatible
2212 = (decl_type.is_primitive()
2213 && def_type.is_primitive()
2214 && (decl_type.type() == def_type.type()
2216 && def_type.type() ==
INT_T)))
2217 || (decl_type.type() == def_type.type());
2218 if (!types_compatible) {
2219 error_msgs <<
"variable definition base type mismatch," 2220 <<
" variable declared as base type: ";
2222 error_msgs <<
"variable definition has base: ";
2227 if (decl_type.num_dims() != def_type.num_dims()) {
2228 error_msgs <<
"variable definition dimensions mismatch," 2229 <<
" definition specifies " 2230 << decl_type.num_dims()
2231 <<
", declaration specifies " 2232 << def_type.num_dims();
2237 boost::phoenix::function<validate_definition>
2242 reserved_word_set_.insert(w);
2245 const std::string& x)
const {
2246 return s.find(x) != s.end();
2250 return contains(reserved_word_set_, identifier)
2252 && !contains(const_fun_name_set_, identifier));
2257 const_fun_name_set_.insert(
"pi");
2258 const_fun_name_set_.insert(
"e");
2259 const_fun_name_set_.insert(
"sqrt2");
2260 const_fun_name_set_.insert(
"log2");
2261 const_fun_name_set_.insert(
"log10");
2262 const_fun_name_set_.insert(
"not_a_number");
2263 const_fun_name_set_.insert(
"positive_infinity");
2264 const_fun_name_set_.insert(
"negative_infinity");
2265 const_fun_name_set_.insert(
"epsilon");
2266 const_fun_name_set_.insert(
"negative_epsilon");
2267 const_fun_name_set_.insert(
"machine_precision");
2284 reserve(
"unit_vector");
2287 reserve(
"positive_ordered");
2288 reserve(
"row_vector");
2290 reserve(
"cholesky_factor_cov");
2291 reserve(
"cholesky_factor_corr");
2292 reserve(
"cov_matrix");
2293 reserve(
"corr_matrix");
2299 reserve(
"parameters");
2300 reserve(
"quantities");
2301 reserve(
"transformed");
2302 reserve(
"generated");
2306 reserve(
"STAN_MAJOR");
2307 reserve(
"STAN_MINOR");
2308 reserve(
"STAN_PATCH");
2309 reserve(
"STAN_MATH_MAJOR");
2310 reserve(
"STAN_MATH_MINOR");
2311 reserve(
"STAN_MATH_PATCH");
2326 reserve(
"char16_t");
2327 reserve(
"char32_t");
2331 reserve(
"constexpr");
2332 reserve(
"const_cast");
2333 reserve(
"continue");
2334 reserve(
"decltype");
2339 reserve(
"dynamic_cast");
2342 reserve(
"explicit");
2355 reserve(
"namespace");
2357 reserve(
"noexcept");
2361 reserve(
"operator");
2365 reserve(
"protected");
2367 reserve(
"register");
2368 reserve(
"reinterpret_cast");
2374 reserve(
"static_assert");
2375 reserve(
"static_cast");
2378 reserve(
"template");
2380 reserve(
"thread_local");
2386 reserve(
"typename");
2388 reserve(
"unsigned");
2392 reserve(
"volatile");
2404 set<string> fun_names = sigs.
key_set();
2405 for (set<string>::iterator it = fun_names.begin();
2406 it != fun_names.end();
2408 if (!contains(const_fun_name_set_, *it))
2414 std::stringstream& error_msgs)
const {
2415 int len = identifier.size();
2417 && identifier[len-1] ==
'_' 2418 && identifier[len-2] ==
'_') {
2419 error_msgs <<
"variable identifier (name) may" 2420 <<
" not end in double underscore (__)" 2422 <<
" found identifer=" << identifier << std::endl;
2426 size_t period_position = identifier.find(
'.');
2427 if (period_position != std::string::npos) {
2428 error_msgs <<
"variable identifier may not contain a period (.)" 2430 <<
" found period at position (indexed from 0)=" 2433 <<
" found identifier=" << identifier
2438 if (identifier_exists(identifier)) {
2439 error_msgs <<
"variable identifier (name) may not be reserved word" 2441 <<
" found identifier=" << identifier
2454 var_decl.
N_ = var_decl.
M_;
2456 boost::phoenix::function<copy_square_cholesky_dimension_if_necessary>
2460 std::stringstream& )
const {
2468 std::stringstream& error_msgs)
const {
2471 validator(expr, pass, error_msgs);
2478 std::stringstream& error_msgs)
const {
2481 validator(expr, pass, error_msgs);
2488 std::stringstream& error_msgs)
2491 error_msgs <<
"dimension declaration requires expression" 2492 <<
" denoting integer; found type=" 2501 bool only_data_dimensions = boost::apply_visitor(vis, expr.
expr_);
2502 pass = only_data_dimensions;
2515 std::stringstream& error_msgs)
2519 validator(expr, pass, error_msgs);
2526 std::stringstream& error_msgs)
2530 validator(expr, pass, error_msgs);
2534 template <
typename T>
2537 std::ostream& error_msgs)
const {
2538 if (vm.
exists(var_decl.name_)) {
2540 error_msgs <<
"duplicate declaration of variable, name=" 2543 error_msgs <<
"; attempt to redeclare as ";
2546 error_msgs <<
"; original declaration as ";
2549 error_msgs << std::endl;
2550 var_decl_result = var_decl;
2554 && var_decl.base_type_ ==
INT_T) {
2556 error_msgs <<
"integer parameters or transformed parameters" 2557 <<
" are not allowed; " 2558 <<
" found declared type int, parameter name=" 2561 var_decl_result = var_decl;
2565 vm.
add(var_decl.name_, var_decl, vo);
2566 var_decl_result = var_decl;
2572 std::ostream&)
const;
2575 std::ostream&)
const;
2578 std::ostream&)
const;
2581 std::ostream&)
const;
2584 std::ostream&)
const;
2587 std::ostream&)
const;
2590 std::ostream&)
const;
2593 std::ostream&)
const;
2597 std::ostream&)
const;
2601 std::ostream&)
const;
2604 std::ostream&)
const;
2607 std::ostream&)
const;
2610 std::ostream&)
const;
2613 std::ostream& error_msgs)
const {
2616 error_msgs <<
"ERROR: break and continue statements are only allowed" 2617 <<
" in the body of a for-loop or while-loop." void operator()(while_statement &ws, const statement &s) const
expr_type get_result_type(const std::string &name, const std::vector< expr_type > &args, std::ostream &error_msgs, bool sampling_error_style=false)
void operator()(conditional_statement &cs, const expression &e, bool &pass, std::stringstream &error_msgs) const
boost::phoenix::function< validate_return_allowed > validate_return_allowed_f
boost::phoenix::function< require_vbar > require_vbar_f
void operator()(var_decl &var_decl_result, const T &var_decl, variable_map &vm, bool &pass, const var_origin &vo, std::ostream &error_msgs) const
bool is_primitive_int() const
bool fun_exists(const std::set< std::pair< std::string, function_signature_t > > &existing, const std::pair< std::string, function_signature_t > &name_sig, bool name_only=true)
std::string strip_ccdf_suffix(const std::string &dist_fun)
boost::phoenix::function< set_void_function > set_void_function_f
void operator()(function_decl_def &decl, bool &pass, std::ostream &error_msgs) const
bool is_ill_formed() const
void operator()(conditional_statement &cs, const statement &s) const
void add(const std::string &name, const expr_type &result_type, const std::vector< expr_type > &arg_types)
boost::phoenix::function< add_while_body > add_while_body_f
void operator()(variable &var_expr, expression &val, variable_map &vm, std::ostream &error_msgs, bool &pass) const
const int function_argument_origin
boost::phoenix::function< set_int_range_upper > set_int_range_upper_f
bool is_no_op_statement() const
void operator()(return_statement &s) const
void operator()(variable_map &vm) const
bool operator()(const nil &) const
void operator()(range &range, const expression &expr, bool &pass, std::stringstream &error_msgs) const
boost::phoenix::function< validate_assgn > validate_assgn_f
boost::phoenix::function< set_var_type > set_var_type_f
bool has_lp_suffix(const std::string &s)
void set_fun_type(fun &fun, std::ostream &error_msgs)
void operator()(expression &expr1, const expression &expr2, std::ostream &error_msgs) const
void operator()(const std::string &identifier, bool &pass, std::stringstream &error_msgs) const
std::vector< expression > dims_
void operator()(variable_map &vm) const
boost::phoenix::function< set_int_range_lower > set_int_range_lower_f
std::string original_name_
void operator()(expression &expr1, const expression &expr2, std::ostream &error_msgs) const
boost::phoenix::function< binary_op_expr > binary_op_f
std::string strip_cdf_suffix(const std::string &dist_fun)
boost::phoenix::function< validate_expr_type3 > validate_expr_type3_f
void operator()(const bool &allow_constraints, const bool &declaration_ok, const var_decl &var_decl, bool &pass, std::stringstream &error_msgs) const
void operator()(range &range, const expression &expr, bool &pass, std::stringstream &error_msgs) const
boost::phoenix::function< deprecated_integrate_ode > deprecated_integrate_ode_f
void operator()(const expression &expr, bool &pass, std::ostream &error_msgs) const
int num_dimss(std::vector< std::vector< stan::lang::expression > > &dimss)
const int parameter_origin
void operator()(var_origin origin, bool &pass, std::ostream &error_msgs) const
boost::phoenix::function< set_fun_type_named > set_fun_type_named_f
bool has_cdf_suffix(const std::string &name)
boost::phoenix::function< set_no_op > set_no_op_f
boost::phoenix::function< validate_conditional_op > validate_conditional_op_f
const int function_argument_origin_rng
void qualify_builtins(fun &f)
Add qualifier "stan::math::" to nullary functions defined in the Stan language.
Probability, optimization and sampling library.
bool deprecate_fun(const std::string &old_name, const std::string &new_name, fun &f, std::ostream &msgs)
void operator()(range &range, const expression &expr, bool &pass, std::stringstream &error_msgs) const
std::string get_prob_fun(const std::string &dist_name)
void operator()(const function_decl_def &decl, bool &pass, std::set< std::pair< std::string, function_signature_t > > &functions_declared, std::set< std::pair< std::string, function_signature_t > > &functions_defined, std::ostream &error_msgs) const
static function_signatures & instance()
boost::phoenix::function< deprecate_increment_log_prob > deprecate_increment_log_prob_f
void operator()(expression &expr, bool &pass, std::ostream &error_msgs) const
boost::phoenix::function< program_error > program_error_f
std::vector< expression > args_
validate_no_constraints_vis(std::stringstream &error_msgs)
void operator()(const std::string &s, bool &pass) const
void add(const std::string &name, const base_var_decl &base_decl, const var_origin &vo)
void operator()(std::ostream &error_msgs) const
bool has_prob_fun_suffix(const std::string &name)
std::string get_cdf(const std::string &dist_name)
bool is_double_return(const std::string &function_name, const std::vector< expr_type > &arg_types, std::ostream &error_msgs)
std::vector< statement > bodies_
void operator()(expression &expr1, const expression &expr2, std::ostream &error_msgs) const
bool has_rng_suffix(const std::string &s)
void operator()(pos_iterator_t _begin, pos_iterator_t _end, pos_iterator_t _where, variable_map &vm, std::stringstream &error_msgs) const
bool is_primitive_double() const
const int transformed_parameter_origin
bool has_prob_suffix(const std::string &s)
void operator()(expression &expr_result, const expression &expr, std::ostream &error_msgs) const
void operator()(sample &s, const variable_map &var_map, bool &pass, std::ostream &error_msgs) const
void operator()(expression &expr1, bool &pass, const expression &expr2, std::ostream &error_msgs) const
boost::spirit::line_pos_iterator< input_iterator_t > pos_iterator_t
boost::phoenix::function< validate_ints_expression > validate_ints_expression_f
boost::phoenix::function< add_conditional_condition > add_conditional_condition_f
boost::phoenix::function< empty_range > empty_range_f
void operator()(const std::string &name, variable_map &vm) const
boost::phoenix::function< subtraction_expr3 > subtraction3_f
boost::phoenix::function< addition_expr3 > addition3_f
void operator()(const std::string &name, const var_origin &origin_allowed, variable &v, bool &pass, const variable_map &vm, std::ostream &error_msgs) const
void operator()(const expression &expr, bool &pass, std::stringstream &error_msgs) const
void validate_integrate_ode_non_control_args(const T &ode_fun, const variable_map &var_map, bool &pass, std::ostream &error_msgs)
void replace_suffix(const std::string &old_suffix, const std::string &new_suffix, fun &f)
void operator()(const expr_type &arg_type, bool &pass, std::ostream &error_msgs) const
expression max_num_steps_
boost::phoenix::function< add_var > add_var_f
expr_type expression_type() const
void operator()(const expression &expr, int var_origin, bool &pass, variable_map &var_map, std::stringstream &error_msgs) const
boost::phoenix::function< remove_lp_var > remove_lp_var_f
void operator()(statement &stmt, const pos_iterator_t &begin, const pos_iterator_t &end) const
void operator()(std::stringstream &error_msgs) const
void set_type(const base_expr_type &base_type, size_t num_dims)
boost::phoenix::function< exponentiation_expr > exponentiation_f
boost::phoenix::function< add_loop_identifier > add_loop_identifier_f
std::string get_ccdf(const std::string &dist_name)
boost::phoenix::function< set_double_range_lower > set_double_range_lower_f
boost::phoenix::function< validate_void_return_allowed > validate_void_return_allowed_f
void operator()(const expression &e, bool &pass, std::ostream &error_msgs) const
const int function_argument_origin_lp
void operator()(bool &pass, const stan::lang::expression &expr, std::stringstream &error_msgs) const
boost::phoenix::function< validate_non_void_arg_function > validate_non_void_arg_f
bool identifier_exists(const std::string &identifier) const
void operator()(var_origin origin, bool &pass, std::ostream &error_msgs) const
void print_var_origin(std::ostream &o, const var_origin &vo)
void operator()(expression &e, std::vector< idx > &idxs, bool &pass, std::ostream &error_msgs) const
void reserve(const std::string &w)
boost::phoenix::function< remove_loop_identifier > remove_loop_identifier_f
boost::phoenix::function< add_conditional_body > add_conditional_body_f
boost::phoenix::function< transpose_expr > transpose_f
boost::phoenix::function< validate_definition > validate_definition_f
void operator()(std::string &fname, bool &pass, std::ostream &error_msgs) const
boost::phoenix::function< multiplication_expr > multiplication_f
bool is_nil(const expression &e)
void operator()(expression &fun_result, fun &fun, const var_origin &var_origin, bool &pass, std::ostream &error_msgs) const
void operator()(conditional_op &cond_expr, const var_origin &var_origin, bool &pass, const variable_map &var_map, std::ostream &error_msgs) const
boost::phoenix::function< validate_identifier > validate_identifier_f
void operator()(expression &expr_result, const expression &expr, bool &pass, std::ostream &error_msgs) const
boost::phoenix::function< validate_int_expression_warn > validate_int_expression_warn_f
void operator()(const bool &allow_sample, bool &pass, std::stringstream &error_msgs) const
void remove(const std::string &name)
base_var_decl base_decl() const
void operator()(expression &expr1, const expression &expr2, std::ostream &error_msgs) const
const int void_function_argument_origin_rng
boost::phoenix::function< validate_int_expr > validate_int_expr_f
bool discrete_first_arg(const std::string &name) const
bool fun_name_exists(const std::string &name)
void operator()(expression &expr1, const expression &expr2, const var_origin &var_origin, bool &pass, std::ostream &error_msgs) const
boost::phoenix::function< validate_decl_constraints > validate_decl_constraints_f
void operator()(range &r, std::stringstream &) const
void operator()(while_statement &ws, const expression &e, bool &pass, std::stringstream &error_msgs) const
bool exists(const std::string &name) const
void operator()(no_op_statement &s) const
size_t get_num_dims(const std::string &name) const
bool ends_with(const std::string &suffix, const std::string &s)
bool returns_type(const expr_type &return_type, const statement &statement, std::ostream &error_msgs)
boost::phoenix::function< add_expression_dimss > add_expression_dimss_f
void operator()(function_decl_def &decl, bool &pass, std::ostream &error_msgs) const
boost::phoenix::function< validate_prob_fun > validate_prob_fun_f
boost::phoenix::function< add_line_number > add_line_number_f
bool is_defined(const std::string &name, const function_signature_t &sig)
bool lhs_var_occurs_on_rhs() const
void operator()(const integrate_ode_control &ode_fun, const variable_map &var_map, bool &pass, std::ostream &error_msgs) const
void operator()(const expression &expr, bool &pass, std::stringstream &error_msgs) const
base_expr_type type() const
boost::phoenix::function< validate_int_data_expr > validate_int_data_expr_f
void operator()(omni_idx &val) const
std::vector< expression > args_
boost::phoenix::function< validate_int_expr_silent > validate_int_expr_silent_f
void operator()(assignment &a, const var_origin &origin_allowed, bool &pass, variable_map &vm, std::ostream &error_msgs) const
var_origin get_origin(const std::string &name) const
expr_type indexed_type(const expression &e, const std::vector< idx > &idxs)
Return the type of the expression indexed by the generalized index sequence.
std::stringstream & error_msgs_
void operator()(expression &expr1, const expression &expr2, bool &pass, std::ostream &error_msgs) const
boost::phoenix::function< is_prob_fun > is_prob_fun_f
const int void_function_argument_origin
boost::phoenix::function< set_omni_idx > set_omni_idx_f
void generate_expression(const expression &e, std::ostream &o)
base_expr_type base_type_
std::pair< expr_type, std::vector< expr_type > > function_signature_t
bool has_non_param_var(const expression &e, const variable_map &var_map)
Returns true if the specified expression contains a variable that is defined as a transformed paramet...
void operator()(function_decl_def &decl, variable_map &vm) const
void operator()(const integrate_ode &ode_fun, const variable_map &var_map, bool &pass, std::ostream &error_msgs) const
boost::phoenix::function< validate_allow_sample > validate_allow_sample_f
boost::phoenix::function< assign_lhs > assign_lhs_f
boost::phoenix::function< validate_integrate_ode > validate_integrate_ode_f
void operator()(variable_map &vm) const
const int void_function_argument_origin_lp
boost::phoenix::function< validate_double_expr > validate_double_expr_f
base_expr_type base_type_
boost::phoenix::function< expression_as_statement > expression_as_statement_f
expr_type infer_type_indexing(const base_expr_type &expr_base_type, size_t num_expr_dims, size_t num_index_dims)
std::string integration_function_name_
boost::phoenix::function< validate_pmf_pdf_variate > validate_pmf_pdf_variate_f
std::vector< expression > conditions_
bool contains(const std::set< std::string > &s, const std::string &x) const
void operator()(size_t &lhs) const
void operator()(const expression &e, bool &pass, std::ostream &error_msgs) const
std::vector< arg_decl > arg_decls_
void qualify(fun &f)
Set original name of specified function to name and add "stan::math::" namespace qualifier to name...
boost::phoenix::function< add_lp_var > add_lp_var_f
bool has_var(const expression &e, const variable_map &var_map)
Returns true if the specified expression contains a variable that is defined as a parameter...
boost::phoenix::function< elt_multiplication_expr > elt_multiplication_f
bool is_univariate(const expr_type &et)
void operator()(const std::vector< var_decl > &var_decls, variable_map &vm) const
void operator()(L &lhs, const R &rhs) const
void operator()(const expression &e, bool &pass, std::ostream &error_msgs) const
bool is_primitive() const
std::vector< expression > dims_
bool has_ccdf_suffix(const std::string &name)
void operator()(const assgn &a, bool &pass, std::ostream &error_msgs) const
base_var_decl base_variable_declaration()
void operator()(range &range, const expression &expr, bool &pass, std::stringstream &error_msgs) const
boost::phoenix::function< set_allows_sampling_origin > set_allows_sampling_origin_f
boost::phoenix::function< logical_negate_expr > logical_negate_expr_f
boost::phoenix::function< validate_sample > validate_sample_f
boost::phoenix::function< increment_size_t > increment_size_t_f
std::set< std::string > key_set() const
boost::phoenix::function< add_function_signature > add_function_signature_f
void operator()(std::ostream &error_msgs) const
void operator()(expression &expr1, const expression &expr2, std::ostream &error_msgs) const
bool is_defined(const std::string &function_name, const std::vector< expr_type > &arg_types)
boost::phoenix::function< set_double_range_upper > set_double_range_upper_f
boost::phoenix::function< add_idxs > add_idxs_f
std::string strip_prob_fun_suffix(const std::string &dist_fun)
void operator()(const std::string &identifier, bool &allow_sampling, int &origin) const
std::stringstream & error_msgs_
std::vector< expression > args_
boost::phoenix::function< unscope_locals > unscope_locals_f
std::ostream & write_base_expr_type(std::ostream &o, base_expr_type type)
void set_user_defined(const std::pair< std::string, function_signature_t > &name_sig)
boost::phoenix::function< division_expr > division_f
void operator()(const std::string &name, std::string &name_local, bool &pass, variable_map &vm, std::stringstream &error_msgs) const
boost::phoenix::function< unscope_variables > unscope_variables_f
boost::phoenix::function< elt_division_expr > elt_division_f
void operator()(bool &pass, std::set< std::pair< std::string, function_signature_t > > &declared, std::set< std::pair< std::string, function_signature_t > > &defined, std::ostream &error_msgs, bool allow_undefined) const
void operator()(const expr_type &return_type, var_origin &origin, bool &pass, std::ostream &error_msgs) const
boost::phoenix::function< identifier_to_var > identifier_to_var_f
void operator()(cholesky_factor_var_decl &var_decl) const
boost::phoenix::function< validate_in_loop > validate_in_loop_f
boost::phoenix::function< negate_expr > negate_expr_f
boost::phoenix::function< copy_square_cholesky_dimension_if_necessary > copy_square_cholesky_dimension_if_necessary_f
bool operator()(const nil &) const
boost::phoenix::function< validate_return_type > validate_return_type_f
void operator()(bool &pass, std::ostream &error_msgs) const
boost::phoenix::function< add_fun_var > add_fun_var_f
void operator()(const expression &e, bool &pass) const
std::vector< std::vector< expression > > dimss_
boost::phoenix::function< add_while_condition > add_while_condition_f
boost::phoenix::function< validate_assignment > validate_assignment_f
bool deprecate_suffix(const std::string &deprecated_suffix, const std::string &replacement, fun &f, std::ostream &msgs)
boost::phoenix::function< validate_integrate_ode_control > validate_integrate_ode_control_f
Placeholder struct for boost::variant default ctors.
boost::phoenix::function< validate_declarations > validate_declarations_f
boost::phoenix::function< left_division_expr > left_division_f
boost::phoenix::function< set_void_return > set_void_return_f
boost::phoenix::function< modulus_expr > modulus_f
base_expr_type get_base_type(const std::string &name) const
data_only_expression(std::stringstream &error_msgs, variable_map &var_map)
boost::phoenix::function< scope_lp > scope_lp_f
const int transformed_data_origin
boost::phoenix::function< deprecate_old_assignment_op > deprecate_old_assignment_op_f
void operator()(arg_decl &decl, bool &pass, variable_map &vm, std::ostream &error_msgs) const
void operator()(bool in_loop, bool &pass, std::ostream &error_msgs) const
void operator()(expression &expr1, const expression &expr2, std::ostream &error_msgs) const
base_var_decl get(const std::string &name) const
void operator()(expression &expression, std::vector< std::vector< stan::lang::expression > > &dimss, bool &pass, std::ostream &error_msgs) const
std::vector< expression > dims() const
boost::phoenix::function< validate_non_void_expression > validate_non_void_expression_f
void qualify_cpp11_builtins(fun &f)
Add namespace qualifier stan::math:: to specify Stan versions of functions to avoid ambiguities with ...
void operator()(const var_origin &origin, const var_decl &var_decl, bool &pass, std::stringstream &error_msgs) const
void operator()(expression &expr1, const expression &expr2, const std::string &op, const std::string &fun_name, std::ostream &error_msgs) const