Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs 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

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