| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
inverse_softmax.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_INVERSE_SOFTMAX_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_INVERSE_SOFTMAX_HPP
3
4 #include <boost/math/tools/promotion.hpp>
5 #include <boost/throw_exception.hpp>
6 #include <stdexcept>
7
8 namespace stan {
9 namespace math {
10
33 template <typename Vector>
34 void inverse_softmax(const Vector& simplex, Vector& y) {
35 using std::log;
36 if (simplex.size() != y.size())
37 BOOST_THROW_EXCEPTION(std::invalid_argument
38 ("simplex.size() != y.size()"));
39 for (size_t i = 0; i < simplex.size(); ++i)
40 y[i] = log(simplex[i]);
41 }
42
43 }
44 }
45
46 #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::math::log
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
stan::math::invalid_argument
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.
Definition: invalid_argument.hpp:31

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