Stan Math Library  2.20.0
reverse mode automatic differentiation
block.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_BLOCK_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_BLOCK_HPP
3 
7 
8 namespace stan {
9 namespace math {
10 
21 template <typename T>
22 inline Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> block(
23  const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& m, size_t i,
24  size_t j, size_t nrows, size_t ncols) {
25  check_row_index("block", "i", m, i);
26  check_row_index("block", "i+nrows-1", m, i + nrows - 1);
27  check_column_index("block", "j", m, j);
28  check_column_index("block", "j+ncols-1", m, j + ncols - 1);
29  return m.block(i - 1, j - 1, nrows, ncols);
30 }
31 
32 } // namespace math
33 } // namespace stan
34 #endif
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...
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > block(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m, size_t i, size_t j, size_t nrows, size_t ncols)
Return a nrows x ncols submatrix starting at (i-1, j-1).
Definition: block.hpp:22

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