Stan Math Library  2.14.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 
5 #include <cmath>
6 
7 namespace stan {
8  namespace math {
9 
33  template <typename Vector>
34  void inverse_softmax(const Vector& simplex, Vector& y) {
35  using std::log;
36  check_matching_sizes("inverse_softmax",
37  "simplex", simplex,
38  "y", y);
39  for (size_t i = 0; i < simplex.size(); ++i)
40  y[i] = log(simplex[i]);
41  }
42 
43  }
44 }
45 #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:14
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–2016, Stan Development Team.