Automatic Differentiation
 
Loading...
Searching...
No Matches
one_hot_row_vector.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_ONE_HOT_ROW_VECTOR_HPP
2#define STAN_MATH_PRIM_FUN_ONE_HOT_ROW_VECTOR_HPP
3
6
7namespace stan {
8namespace math {
9
20inline Eigen::RowVectorXd one_hot_row_vector(int K, int k) {
21 static constexpr const char* function = "one_hot_row_vector";
22 check_positive(function, "size", K);
23 check_bounded(function, "k", k, 1, K);
24
25 Eigen::RowVectorXd ret = Eigen::RowVectorXd::Zero(K);
26 ret(k - 1) = 1;
27 return ret;
28}
29
30} // namespace math
31} // namespace stan
32
33#endif
void check_bounded(const char *function, const char *name, const T_y &y, const T_low &low, const T_high &high)
Check if the value is between the low and high values, inclusively.
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.
Eigen::RowVectorXd one_hot_row_vector(int K, int k)
Return a row vector with 1 in the k-th position and zero elsewhere.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...