Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sub_col.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__MATRIX__SUB_COL_HPP
2 #define STAN__MATH__MATRIX__SUB_COL_HPP
3 
7 
8 namespace stan {
9  namespace math {
10 
19  template <typename T>
20  inline
21  Eigen::Matrix<T,Eigen::Dynamic,1>
22  sub_col(const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic>& m,
23  size_t i, size_t j, size_t nrows) {
24  stan::math::check_row_index("sub_col(%1%)",i,m,"i",(double*)0);
25  if (nrows > 0)
26  stan::math::check_row_index("sub_col(%1%)",i+nrows-1,m,"i+nrows-1",(double*)0);
27  stan::math::check_column_index("sub_col(%1%)",j,m,"j",(double*)0);
28  return m.block(i - 1,j - 1,nrows,1);
29  }
30 
31 
32  }
33 }
34 
35 #endif
bool check_column_index(const char *function, size_t i, const Eigen::Matrix< T_y, R, C > &y, const char *name, T_result *result)
Return true if the specified index is a valid column of the matrix.
bool check_row_index(const char *function, size_t i, const Eigen::Matrix< T_y, R, C > &y, const char *name, T_result *result)
Return true if the specified index is a valid row of the matrix.
Eigen::Matrix< T, Eigen::Dynamic, 1 > sub_col(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m, size_t i, size_t j, size_t nrows)
Return a nrows x 1 subcolumn starting at (i-1,j-1).
Definition: sub_col.hpp:22

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