Stan  2.14.0
probability, sampling & optimization
function_signatures.hpp
Go to the documentation of this file.
1 #ifndef STAN_LANG_AST_SIGS_FUNCTION_SIGNATURES_HPP
2 #define STAN_LANG_AST_SIGS_FUNCTION_SIGNATURES_HPP
3 
6 #include <map>
7 #include <ostream>
8 #include <set>
9 #include <string>
10 #include <utility>
11 #include <vector>
12 
13 
14 namespace stan {
15  namespace lang {
16 
23  public:
29  static function_signatures& instance();
30 
34  static void reset_sigs();
35 
42  void set_user_defined(const std::pair<std::string, function_signature_t>&
43  name_sig);
44 
51  bool is_user_defined(const std::pair<std::string, function_signature_t>&
52  name_sig);
53 
62  void add(const std::string& name,
63  const expr_type& result_type,
64  const std::vector<expr_type>& arg_types);
65 
73  void add(const std::string& name,
74  const expr_type& result_type);
75 
84  void add(const std::string& name,
85  const expr_type& result_type,
86  const expr_type& arg_type1);
96  void add(const std::string& name,
97  const expr_type& result_type,
98  const expr_type& arg_type1,
99  const expr_type& arg_type2);
100 
111  void add(const std::string& name,
112  const expr_type& result_type,
113  const expr_type& arg_type1,
114  const expr_type& arg_type2,
115  const expr_type& arg_type3);
116 
128  void add(const std::string& name,
129  const expr_type& result_type,
130  const expr_type& arg_type1,
131  const expr_type& arg_type2,
132  const expr_type& arg_type3,
133  const expr_type& arg_type4);
134 
147  void add(const std::string& name,
148  const expr_type& result_type,
149  const expr_type& arg_type1,
150  const expr_type& arg_type2,
151  const expr_type& arg_type3,
152  const expr_type& arg_type4,
153  const expr_type& arg_type5);
154 
168  void add(const std::string& name,
169  const expr_type& result_type,
170  const expr_type& arg_type1,
171  const expr_type& arg_type2,
172  const expr_type& arg_type3,
173  const expr_type& arg_type4,
174  const expr_type& arg_type5,
175  const expr_type& arg_type6);
176 
191  void add(const std::string& name,
192  const expr_type& result_type,
193  const expr_type& arg_type1,
194  const expr_type& arg_type2,
195  const expr_type& arg_type3,
196  const expr_type& arg_type4,
197  const expr_type& arg_type5,
198  const expr_type& arg_type6,
199  const expr_type& arg_type7);
200 
207  void add_nullary(const::std::string& name);
208 
215  void add_unary(const::std::string& name);
216 
223  void add_unary_vectorized(const::std::string& name);
224 
231  void add_binary(const::std::string& name);
232 
239  void add_ternary(const::std::string& name);
240 
247  void add_quaternary(const::std::string& name);
248 
259  int num_promotions(const std::vector<expr_type>& call_args,
260  const std::vector<expr_type>& sig_args);
261 
276  expr_type get_result_type(const std::string& name,
277  const std::vector<expr_type>& args,
278  std::ostream& error_msgs,
279  bool sampling_error_style = false);
280 
290  int get_signature_matches(const std::string& name,
291  const std::vector<expr_type>& args,
292  function_signature_t& signature);
293 
302  bool is_defined(const std::string& name,
303  const function_signature_t& sig);
304 
313  bool has_user_defined_key(const std::string& name) const;
314 
320  std::set<std::string> key_set() const;
321 
329  bool has_key(const std::string& key) const;
330 
339  bool discrete_first_arg(const std::string& name) const;
340 
341  private:
346 
353 
357  std::map<std::string, std::vector<function_signature_t> > sigs_map_;
358 
362  std::set<std::pair<std::string, function_signature_t> > user_defined_set_;
363 
367  static function_signatures* sigs_; // init below outside of class
368  };
369 
370  }
371 }
372 #endif
expr_type get_result_type(const std::string &name, const std::vector< expr_type > &args, std::ostream &error_msgs, bool sampling_error_style=false)
Return the result expression type resulting from applying a function of the speicified name and argum...
void add(const std::string &name, const expr_type &result_type, const std::vector< expr_type > &arg_types)
Add a built-in function with the specified name, result, type and arguments.
Probability, optimization and sampling library.
static function_signatures & instance()
Return the instance of this singleton.
This class is a singleton used to store the available functions in the Stan object language and their...
int num_promotions(const std::vector< expr_type > &call_args, const std::vector< expr_type > &sig_args)
Return the number of integer to real promotions required to convert the specified call arguments to t...
int get_signature_matches(const std::string &name, const std::vector< expr_type > &args, function_signature_t &signature)
Return the number of declared function signatures match for the specified name, argument types...
Structure of the type of an expression, which consists of a base type and a number of dimensions...
Definition: expr_type.hpp:14
void add_binary(const ::std::string &name)
Add a built-in function with the specified name, a real return type, and two real arguments...
bool has_user_defined_key(const std::string &name) const
Return true if the specified name is the name of a user-defined function.
void add_unary(const ::std::string &name)
Add a built-in function with the specified name, a real return type, and a single real argument...
static void reset_sigs()
Reset the signature singleton to contain no instances.
bool discrete_first_arg(const std::string &name) const
Return true if all of the function signatures for functions with the specified name have integer base...
void add_nullary(const ::std::string &name)
Add a built-in function with the specified name, a real return type, and no arguments.
bool is_defined(const std::string &name, const function_signature_t &sig)
Return true if the specified function name is defined for the specified signature.
void add_quaternary(const ::std::string &name)
Add a built-in function with the specified name, a real return type, and four real arguments...
bool is_user_defined(const std::pair< std::string, function_signature_t > &name_sig)
Return true if the specified name and signature have been added as user-defined functions.
std::pair< expr_type, std::vector< expr_type > > function_signature_t
The type of a function signature, mapping a vector of argument expression types to a result expressio...
void add_ternary(const ::std::string &name)
Add a built-in function with the specified name, a real return type, and three real arguments...
std::set< std::string > key_set() const
Return the set of function names defined.
bool has_key(const std::string &key) const
Return true if specified key is the name of a declared function.
void set_user_defined(const std::pair< std::string, function_signature_t > &name_sig)
Set the specified name and signature to be a user-defined function.
void add_unary_vectorized(const ::std::string &name)
Add built-in functions for all the vectorized form of a unary function with the speicifed name and a ...

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