Stan Math Library  2.20.0
reverse mode automatic differentiation
inverse_softmax.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_ARR_SCAL_FUN_INVERSE_SOFTMAX_HPP
2 #define STAN_MATH_ARR_SCAL_FUN_INVERSE_SOFTMAX_HPP
3 
6 #include <cmath>
7 
8 namespace stan {
9 namespace math {
10 
34 template <typename Vector>
35 void inverse_softmax(const Vector& simplex, Vector& y) {
36  using std::log;
37  check_matching_sizes("inverse_softmax", "simplex", simplex, "y", y);
38  for (size_t i = 0; i < simplex.size(); ++i)
39  y[i] = log(simplex[i]);
40 }
41 
42 } // namespace math
43 } // namespace stan
44 #endif
void inverse_softmax(const Vector &simplex, Vector &y)
Writes the inverse softmax of the simplex argument into the second argument.
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:12
void check_matching_sizes(const char *function, const char *name1, const T_y1 &y1, const char *name2, const T_y2 &y2)
Check if two structures at the same size.

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