Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
exp.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_EXP_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_EXP_HPP
3 
5 #include <boost/math/special_functions/fpclassify.hpp>
6 #include <limits>
7 
8 namespace stan {
9  namespace math {
10 
17  template<typename T, int Rows, int Cols>
18  inline Eigen::Matrix<T, Rows, Cols>
19  exp(const Eigen::Matrix<T, Rows, Cols>& m) {
20  return m.array().exp().matrix();
21  }
22 
23  // FIXME:
24  // specialization not needed once Eigen fixes issue:
25  // http:// eigen.tuxfamily.org/bz/show_bug.cgi?id=859
26  template<int Rows, int Cols>
27  inline Eigen::Matrix<double, Rows, Cols>
28  exp(const Eigen::Matrix<double, Rows, Cols>& m) {
29  Eigen::Matrix<double, Rows, Cols> mat = m.array().exp().matrix();
30  for (int i = 0, size_ = mat.size(); i < size_; i++)
31  if (boost::math::isnan(m(i)))
32  mat(i) = std::numeric_limits<double>::quiet_NaN();
33  return mat;
34  }
35 
36  }
37 }
38 #endif
bool isnan(const stan::math::var &v)
Checks if the given number is NaN.
Definition: boost_isnan.hpp:22
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
size_t size_
Definition: dot_self.hpp:18

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