All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
check_vector.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_VECTOR_HPP
#define STAN_MATH_PRIM_MAT_ERR_CHECK_VECTOR_HPP
#include <stan/math/prim/scal/meta/return_type.hpp>
#include <stan/math/prim/scal/meta/scalar_type.hpp>
#include <stan/math/prim/scal/err/invalid_argument.hpp>
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <sstream>
#include <string>
namespace stan {
namespace math {
template <typename T, int R, int C>
inline bool check_vector(const char* function,
const char* name,
const Eigen::Matrix<T, R, C>& x) {
if (R == 1)
return true;
if (C == 1)
return true;
if (x.rows() == 1 || x.cols() == 1)
return true;
std::ostringstream msg;
msg << ") has " << x.rows() << " rows and "
<< x.cols() << " columns but it should be a vector so it should "
<< "either have 1 row or 1 column";
std::string msg_str(msg.str());
invalid_argument(function,
name,
typename scalar_type<T>::type(),
"(", msg_str.c_str());
return false;
}
}
}
#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
invalid_argument.hpp
stan::scalar_type::type
scalar_type_helper< is_vector< T >::value, T >::type type
Definition: scalar_type.hpp:38
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
scalar_type.hpp
Eigen.hpp

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