Automatic Differentiation
 
Loading...
Searching...
No Matches
check_vector.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_ERR_CHECK_VECTOR_HPP
2#define STAN_MATH_PRIM_ERR_CHECK_VECTOR_HPP
3
7#include <sstream>
8#include <string>
9#include <typeinfo>
10
11#ifdef STAN_OPENCL
13#endif
14
15namespace stan {
16namespace math {
17
29template <typename Mat,
30 require_any_t<is_matrix<Mat>,
31 is_prim_or_rev_kernel_expression<Mat>>* = nullptr>
32inline void check_vector(const char* function, const char* name, const Mat& x) {
33 if (!(x.rows() == 1 || x.cols() == 1)) {
35 [&]() STAN_COLD_PATH {
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, 0.0, "(", msg_str.c_str());
42 }();
43 }
44}
45
46} // namespace math
47} // namespace stan
48#endif
#define STAN_COLD_PATH
#define STAN_NO_RANGE_CHECKS_RETURN
Turns all range and size checks into no-ops.
void check_vector(const char *function, const char *name, const Mat &x)
Check the input is either a row vector or column vector or a matrix with a single row or column.
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.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...