Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
validate_row_index.hpp
Go to the documentation of this file.
1 #ifndef __STAN__MATH__MATRIX__VALIDATE_ROW_INDEX_HPP__
2 #define __STAN__MATH__MATRIX__VALIDATE_ROW_INDEX_HPP__
3 
4 #include <sstream>
5 #include <stdexcept>
8 
9 namespace stan {
10  namespace math {
11 
12  template <typename T, int R, int C>
13  void validate_row_index(const Eigen::Matrix<T,R,C>& m,
14  size_t i,
15  const char* msg) {
16  if (i > 0 && i <= static_cast<size_t>(m.rows())) return;
17  std::stringstream ss;
18  ss << "require 0 < row index <= number of rows in" << msg;
19  ss << " found rows()=" << m.rows()
20  << "; index i=" << i;
21  throw std::domain_error(ss.str());
22  }
23 
24  }
25 }
26 #endif

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