| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/arr/err/check_matching_sizes.hpp>
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
stan::math::inverse_softmax
void inverse_softmax(const Vector &simplex, Vector &y)
Writes the inverse softmax of the simplex argument into the second argument.
Definition: inverse_softmax.hpp:34
stan
Definition: log_sum_exp.hpp:8
stan::math::log
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:14
check_matching_sizes.hpp
stan::math::check_matching_sizes
bool check_matching_sizes(const char *function, const char *name1, const T_y1 &y1, const char *name2, const T_y2 &y2)
Return true if two structures at the same size.
Definition: check_matching_sizes.hpp:29

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