| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #include <stan/math/prim/mat/err/check_row_index.hpp>
6 #include <stan/math/prim/mat/err/check_column_index.hpp>
7
8 namespace stan {
9 namespace math {
10
20 template <typename T>
21 inline
22 Eigen::Matrix<T, 1, Eigen::Dynamic>
23 sub_row(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& m,
24 size_t i, size_t j, size_t ncols) {
25 check_row_index("sub_row", "i", m, i);
26 check_column_index("sub_row", "j", m, j);
27 if (ncols > 0)
28 check_column_index("sub_col", "j+ncols-1", m, j+ncols-1);
29 return m.block(i - 1, j - 1, 1, ncols);
30 }
31
32 }
33 }
34 #endif
stan
Definition: log_sum_exp.hpp:8
stan::math::sub_row
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:23
check_column_index.hpp
stan::math::check_row_index
bool check_row_index(const char *function, const char *name, const Eigen::Matrix< T_y, R, C > &y, size_t i)
Return true if the specified index is a valid row of the matrix.
Definition: check_row_index.hpp:32
check_row_index.hpp
Eigen.hpp
stan::math::check_column_index
bool check_column_index(const char *function, const char *name, const Eigen::Matrix< T_y, R, C > &y, const size_t i)
Return true if the specified index is a valid column of the matrix.
Definition: check_column_index.hpp:37

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