Stan Math Library  2.20.0
reverse mode automatic differentiation
sub_row.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_SUB_ROW_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_SUB_ROW_HPP
3 
7 
8 namespace stan {
9 namespace math {
10 
20 template <typename T>
21 inline Eigen::Matrix<T, 1, Eigen::Dynamic> sub_row(
22  const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& m, size_t i,
23  size_t j, size_t ncols) {
24  check_row_index("sub_row", "i", m, i);
25  check_column_index("sub_row", "j", m, j);
26  if (ncols > 0)
27  check_column_index("sub_col", "j+ncols-1", m, j + ncols - 1);
28  return m.block(i - 1, j - 1, 1, ncols);
29 }
30 
31 } // namespace math
32 } // namespace stan
33 #endif
Eigen::Matrix< T, 1, Eigen::Dynamic > sub_row(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m, size_t i, size_t j, size_t ncols)
Return a 1 x nrows subrow starting at (i-1, j-1).
Definition: sub_row.hpp:21
void check_column_index(const char *function, const char *name, const Eigen::Matrix< T_y, R, C > &y, size_t i)
Check if the specified index is a valid column of the matrix.
void check_row_index(const char *function, const char *name, const Eigen::Matrix< T_y, R, C > &y, size_t i)
Check if the specified index is a valid row of the matrix This check is 1-indexed by default...

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