Stan Math Library  2.9.0
reverse mode automatic differentiation
check_vector.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_VECTOR_HPP
2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_VECTOR_HPP
3 
8 #include <sstream>
9 #include <string>
10 
11 namespace stan {
12  namespace math {
13 
33  template <typename T, int R, int C>
34  inline bool check_vector(const char* function,
35  const char* name,
36  const Eigen::Matrix<T, R, C>& x) {
37  if (R == 1)
38  return true;
39  if (C == 1)
40  return true;
41  if (x.rows() == 1 || x.cols() == 1)
42  return true;
43 
44  std::ostringstream msg;
45  msg << ") has " << x.rows() << " rows and "
46  << x.cols() << " columns but it should be a vector so it should "
47  << "either have 1 row or 1 column";
48  std::string msg_str(msg.str());
49  invalid_argument(function,
50  name,
51  typename scalar_type<T>::type(),
52  "(", msg_str.c_str());
53  return false;
54  }
55 
56  }
57 }
58 #endif
bool check_vector(const char *function, const char *name, const Eigen::Matrix< T, R, C > &x)
Return true if the matrix is either a row vector or column vector.
scalar_type_helper< is_vector< T >::value, T >::type type
Definition: scalar_type.hpp:38
void invalid_argument(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw an invalid_argument exception with a consistently formatted message.

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