Automatic Differentiation
 
Loading...
Searching...
No Matches
unit_vector_free.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_UNIT_VECTOR_FREE_HPP
2#define STAN_MATH_PRIM_FUN_UNIT_VECTOR_FREE_HPP
3
8#include <cmath>
9
10namespace stan {
11namespace math {
12
23template <typename EigVec, require_eigen_col_vector_t<EigVec>* = nullptr>
24inline auto unit_vector_free(EigVec&& x) {
25 auto&& x_ref = to_ref(std::forward<EigVec>(x));
26 check_unit_vector("stan::math::unit_vector_free", "Unit vector variable",
27 x_ref);
28 return x_ref;
29}
30
38template <typename T, require_std_vector_t<T>* = nullptr>
39auto unit_vector_free(const T& x) {
41 x, [](auto&& v) { return unit_vector_free(v); });
42}
43
44} // namespace math
45} // namespace stan
46
47#endif
void 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.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:17
auto unit_vector_free(EigVec &&x)
Transformation of a unit length vector to a "free" vector However, we are just fixing the unidentifie...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9