Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ check_unit_vector() [1/2]

template<typename Vec , require_vector_t< Vec > * = nullptr, require_not_std_vector_t< Vec > * = nullptr>
void stan::math::check_unit_vector ( const char *  function,
const char *  name,
const Vec &  theta 
)

Throw an exception if the specified vector does not have unit Euclidiean length.

A valid unit vector is one where the square of the elements summed is equal to 1. This function tests that the sum is within the tolerance specified by CONSTRAINT_TOLERANCE. This function only accepts Eigen vectors, statically typed vectors, not general matrices with 1 column.

Template Parameters
VecA type derived from Eigen::EigenBase with either dynamic rows or columns but not both
Parameters
functionFunction name (for error messages)
nameVariable name (for error messages)
thetaVector to test
Exceptions
`std::invalid_argument`if theta is a 0-vector
`std::domain_error`if the vector is not a unit vector or if any element is NaN

Definition at line 37 of file check_unit_vector.hpp.