Stan Math Library  2.14.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 
7 #include <sstream>
8 #include <string>
9 
10 namespace stan {
11  namespace math {
12 
31  template <typename T, int R, int C>
32  inline void check_vector(const char* function,
33  const char* name,
34  const Eigen::Matrix<T, R, C>& x) {
35  if (R == 1)
36  return;
37  if (C == 1)
38  return;
39  if (x.rows() == 1 || x.cols() == 1)
40  return;
41 
42  std::ostringstream msg;
43  msg << ") has " << x.rows() << " rows and "
44  << x.cols() << " columns but it should be a vector so it should "
45  << "either have 1 row or 1 column";
46  std::string msg_str(msg.str());
47  invalid_argument(function,
48  name,
49  typename scalar_type<T>::type(),
50  "(", msg_str.c_str());
51  }
52 
53  }
54 }
55 #endif
void check_vector(const char *function, const char *name, const Eigen::Matrix< T, R, C > &x)
Check 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:34
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–2016, Stan Development Team.