Stan  2.14.0
probability, sampling & optimization
strip_prob_fun_suffix_def.hpp
Go to the documentation of this file.
1 #ifndef STAN_LANG_AST_FUN_STRIP_PROB_FUN_SUFFIX_DEF_HPP
2 #define STAN_LANG_AST_FUN_STRIP_PROB_FUN_SUFFIX_DEF_HPP
3 
4 #include <stan/lang/ast.hpp>
5 #include <string>
6 
7 namespace stan {
8  namespace lang {
9 
10  std::string strip_prob_fun_suffix(const std::string& fname) {
11  if (ends_with("_lpdf", fname))
12  return fname.substr(0, fname.size() - 5);
13  else if (ends_with("_lpmf", fname))
14  return fname.substr(0, fname.size() - 5);
15  else if (ends_with("_log", fname))
16  return fname.substr(0, fname.size() - 4);
17  else
18  return fname;
19  }
20 
21  }
22 }
23 #endif
Probability, optimization and sampling library.
bool ends_with(const std::string &suffix, const std::string &s)
Returns true if the specified suffix appears at the end of the specified string.
std::string strip_prob_fun_suffix(const std::string &dist_fun)
Return the result of stripping the suffix indicating it is a probability function from the specified ...

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