Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
exp.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__MATRIX__EXP_HPP
2 #define STAN__MATH__MATRIX__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> exp(const Eigen::Matrix<T,Rows,Cols>& m) {
19  return m.array().exp().matrix();
20  }
21 
22  //FIXME:
23  //specialization not needed once Eigen fixes issue:
24  //http://eigen.tuxfamily.org/bz/show_bug.cgi?id=859
25  template<int Rows, int Cols>
26  inline Eigen::Matrix<double,Rows,Cols> exp(const Eigen::Matrix<double,Rows,Cols>& m) {
27  Eigen::Matrix<double,Rows,Cols> mat = m.array().exp().matrix();
28  for (int i = 0, size_ = mat.size(); i < size_; i++)
29  if (boost::math::isnan(m(i)))
30  mat(i) = std::numeric_limits<double>::quiet_NaN();
31  return mat;
32  }
33 
34  }
35 }
36 #endif
bool isnan(const stan::agrad::var &v)
Checks if the given number is NaN.
Eigen::Matrix< T, Rows, Cols > exp(const Eigen::Matrix< T, Rows, Cols > &m)
Return the element-wise exponentiation of the matrix or vector.
Definition: exp.hpp:18
size_t size_
Definition: dot_self.hpp:18

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