| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/scal/meta/return_type.hpp>
5 #include <stan/math/prim/scal/meta/scalar_type.hpp>
6 #include <stan/math/prim/scal/err/invalid_argument.hpp>
7 #include <stan/math/prim/mat/fun/Eigen.hpp>
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
stan::math::check_vector
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.
Definition: check_vector.hpp:34
stan
Definition: log_sum_exp.hpp:8
invalid_argument.hpp
stan::scalar_type::type
scalar_type_helper< is_vector< T >::value, T >::type type
Definition: scalar_type.hpp:34
return_type.hpp
stan::math::invalid_argument
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.
Definition: invalid_argument.hpp:31
Eigen.hpp
scalar_type.hpp

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