1 #ifndef STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_UNIT_VECTOR_HPP
2 #define STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_UNIT_VECTOR_HPP
26 template <
typename T_prob,
typename T_result>
28 const Eigen::Matrix<T_prob,Eigen::Dynamic,1>& theta,
31 if (theta.size() == 0) {
32 std::string message(name);
33 message +=
" is not a valid unit vector. %1% elements in the vector.";
38 T_prob ssq = theta.squaredNorm();
40 std::stringstream msg;
41 msg <<
"in function check_unit_vector(%1%), ";
42 msg << name <<
" is not a valid unit vector.";
43 msg <<
" The sum of the squares of the elements should be 1, but is "
45 std::string tmp(msg.str());
46 return dom_err(
function,ssq,name,
56 const Eigen::Matrix<T,Eigen::Dynamic,1>& theta,
59 return check_unit_vector<T,T>(
function,theta,name,result);
fvar< T > fabs(const fvar< T > &x)
bool dom_err(const char *function, const T &y, const char *name, const char *error_msg, const T_msg error_msg2, T_result *result)
bool check_unit_vector(const char *function, const Eigen::Matrix< T_prob, Eigen::Dynamic, 1 > &theta, const char *name, T_result *result)
Return true if the specified vector is unit vector.
const double CONSTRAINT_TOLERANCE
The tolerance for checking arithmetic bounds In rank and in simplexes.