1 #ifndef STAN__MATH__FUNCTIONS__INVERSE_SOFTMAX_HPP
2 #define STAN__MATH__FUNCTIONS__INVERSE_SOFTMAX_HPP
4 #include <boost/math/tools/promotion.hpp>
6 #include <boost/throw_exception.hpp>
33 template <
typename Vector>
36 if(simplex.size() != y.size())
37 BOOST_THROW_EXCEPTION(std::invalid_argument (
"simplex.size() != y.size()"));
38 for (
size_t i = 0; i < simplex.size(); ++i)
39 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.
Eigen::Matrix< T, Rows, Cols > log(const Eigen::Matrix< T, Rows, Cols > &m)
Return the element-wise logarithm of the matrix or vector.
fvar< T > log(const fvar< T > &x)