Stan Math Library  2.20.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 
26 template <typename T, int R, int C>
27 inline void check_vector(const char* function, const char* name,
28  const Eigen::Matrix<T, R, C>& x) {
29  if (R == 1)
30  return;
31  if (C == 1)
32  return;
33  if (x.rows() == 1 || x.cols() == 1)
34  return;
35 
36  std::ostringstream msg;
37  msg << ") has " << x.rows() << " rows and " << x.cols()
38  << " columns but it should be a vector so it should "
39  << "either have 1 row or 1 column";
40  std::string msg_str(msg.str());
41  invalid_argument(function, name, typename scalar_type<T>::type(), "(",
42  msg_str.c_str());
43 }
44 
45 } // namespace math
46 } // namespace stan
47 #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.
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–2018, Stan Development Team.