Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
inverse_softmax.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__FUNCTIONS__INVERSE_SOFTMAX_HPP
2 #define STAN__MATH__FUNCTIONS__INVERSE_SOFTMAX_HPP
3 
4 #include <boost/math/tools/promotion.hpp>
5 #include <stdexcept>
6 #include <boost/throw_exception.hpp>
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 ("simplex.size() != y.size()"));
38  for (size_t i = 0; i < simplex.size(); ++i)
39  y[i] = log(simplex[i]);
40  }
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.
Eigen::Matrix< T, Rows, Cols > log(const Eigen::Matrix< T, Rows, Cols > &m)
Return the element-wise logarithm of the matrix or vector.
Definition: log.hpp:16
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15

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