1 #ifndef STAN_MATH_PRIM_SCAL_FUN_INVERSE_SOFTMAX_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_INVERSE_SOFTMAX_HPP
4 #include <boost/math/tools/promotion.hpp>
5 #include <boost/throw_exception.hpp>
33 template <
typename Vector>
36 if (simplex.size() != y.size())
38 (
"simplex.size() != y.size()"));
39 for (
size_t i = 0; i < simplex.size(); ++i)
40 y[i] =
log(simplex[i]);
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)
void invalid_argument(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw an invalid_argument exception with a consistently formatted message.