Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
check_vector.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_VECTOR_HPP
2 #define STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_VECTOR_HPP
3 
4 #include <sstream>
5 #include <stan/meta/traits.hpp>
8 
9 namespace stan {
10  namespace math {
11 
12  // NOTE: this will not throw if x contains nan values.
13  template <typename T, int R, int C, typename T_result>
14  inline bool check_vector(const char* function,
15  const Eigen::Matrix<T,R,C>& x,
16  const char* name,
17  T_result* result) {
18  if (x.rows() == 1 || x.cols() == 1)
19  return true;
20 
21  std::ostringstream msg;
22  msg << name << " (%1%) has " << x.rows() << " rows and "
23  << x.cols() << " columns but it should be a vector so it should either have 1 row or 1 column";
24  std::string tmp(msg.str());
25  return dom_err(function,
26  typename scalar_type<T>::type(),
27  name,
28  tmp.c_str(),"",
29  result);
30  }
31 
32  }
33 }
34 #endif
bool dom_err(const char *function, const T &y, const char *name, const char *error_msg, const T_msg error_msg2, T_result *result)
Definition: dom_err.hpp:36
bool check_vector(const char *function, const Eigen::Matrix< T, R, C > &x, const char *name, T_result *result)
scalar_type_helper< is_vector< T >::value, T >::type type
Definition: traits.hpp:139

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