Stan  2.14.0
probability, sampling & optimization
is_assignable_def.hpp
Go to the documentation of this file.
1 #ifndef STAN_LANG_AST_FUN_IS_ASSIGNABLE_DEF_HPP
2 #define STAN_LANG_AST_FUN_IS_ASSIGNABLE_DEF_HPP
3 
4 #include <stan/lang/ast.hpp>
5 #include <ostream>
6 #include <string>
7 
8 namespace stan {
9  namespace lang {
10 
11  bool is_assignable(const expr_type& l_type,
12  const expr_type& r_type,
13  const std::string& failure_message,
14  std::ostream& error_msgs) {
15  bool assignable = true;
16  if (l_type.num_dims_ != r_type.num_dims_) {
17  assignable = false;
18  error_msgs << "Mismatched array dimensions.";
19  }
20  if (l_type.base_type_ != r_type.base_type_
21  && (!(l_type.base_type_ == DOUBLE_T
22  && r_type.base_type_ == INT_T))) {
23  assignable = false;
24  error_msgs << "Base type mismatch. ";
25  }
26  if (!assignable)
27  error_msgs << failure_message << std::endl
28  << " LHS type = " << l_type << "; RHS type = " << r_type
29  << std::endl;
30  return assignable;
31  }
32 
33  }
34 }
35 #endif
std::size_t num_dims_
The number of array dimensions.
Definition: expr_type.hpp:23
Probability, optimization and sampling library.
const int DOUBLE_T
Real scalar type.
bool is_assignable(const expr_type &l_type, const expr_type &r_type, const std::string &failure_message, std::ostream &error_msgs)
Return true if an expression of the right-hand side type is assignable to a variable of the left-hand...
Structure of the type of an expression, which consists of a base type and a number of dimensions...
Definition: expr_type.hpp:14
base_expr_type base_type_
The base expression type.
Definition: expr_type.hpp:18
const int INT_T
Integer type.

     [ Stan Home Page ] © 2011–2016, Stan Development Team.