<commit_before>#ifndef STAN__MATH__MATRIX__EXP_HPP
#define STAN__MATH__MATRIX__EXP_HPP

#include <stan/math/matrix/Eigen.hpp>
#include <boost/math/special_functions/fpclassify.hpp>

namespace stan {
  namespace math {
    
    /**
     * Return the element-wise exponentiation of the matrix or vector.
     *
     * @param m The matrix or vector.
     * @return ret(i,j) = exp(m(i,j))
     */
    template<typename T, int Rows, int Cols>
    inline Eigen::Matrix<T,Rows,Cols> exp(const Eigen::Matrix<T,Rows,Cols> & m) {
      return m.array().exp().matrix();
    }
    
    template<int Rows, int Cols>
    inline Eigen::Matrix<double,Rows,Cols> exp(const Eigen::Matrix<double,Rows,Cols> & m) {
      for (const double * it = m.data(), * end_ = it + m.size(); it != end_; it++)
        if (boost::math::isnan(*it)) {
          Eigen::Matrix<double,Rows,Cols> mat = m;
          for (double * it = mat.data(), * end_ = it + mat.size(); it != end_; it++)
            *it = std::exp(*it);
          return mat;
        }
      return m.array().exp().matrix();
    }
    
  }
}
#endif<commit_msg>even simpler and better solution<commit_after>#ifndef STAN__MATH__MATRIX__EXP_HPP
#define STAN__MATH__MATRIX__EXP_HPP

#include <stan/math/matrix/Eigen.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <limits>

namespace stan {
  namespace math {
    
    /**
     * Return the element-wise exponentiation of the matrix or vector.
     *
     * @param m The matrix or vector.
     * @return ret(i,j) = exp(m(i,j))
     */
    template<typename T, int Rows, int Cols>
    inline Eigen::Matrix<T,Rows,Cols> exp(const Eigen::Matrix<T,Rows,Cols>& m) {
      return m.array().exp().matrix();
    }
    
    //FIXME:
    //specialization not needed once Eigen fixes issue:
    //http://eigen.tuxfamily.org/bz/show_bug.cgi?id=859
    template<int Rows, int Cols>
    inline Eigen::Matrix<double,Rows,Cols> exp(const Eigen::Matrix<double,Rows,Cols>& m) {
      Eigen::Matrix<double,Rows,Cols> mat = m.array().exp().matrix();
      for (int i = 0, size_ = mat.size(); i < size_; i++)
        if (boost::math::isnan(m(i)))
          mat(i) = std::numeric_limits<double>::quiet_NaN();
      return mat;
    }
    
  }
}
#endif
{'fraction_non_alphanumeric': 0.15626403233048944, 'fraction_numerical': 0.001796138302649304, 'mean_word_length': 3.0, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7122724', 'n_tokens_mistral': 798, 'n_tokens_neox': 779, 'n_words': 170}