Automatic Differentiation
 
Loading...
Searching...
No Matches
sub_row.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_SUB_ROW_HPP
2#define STAN_MATH_PRIM_FUN_SUB_ROW_HPP
3
6
7namespace stan {
8namespace math {
9
20template <
21 typename T, require_matrix_t<T>* = nullptr,
22 require_all_not_nonscalar_prim_or_rev_kernel_expression_t<T>* = nullptr>
23inline auto sub_row(const T& m, size_t i, 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 }
29 return m.row(i - 1).segment(j - 1, ncols);
30}
31
32} // namespace math
33} // namespace stan
34
35#endif
auto sub_row(T_x &&x, size_t i, size_t j, size_t ncols)
Return a 1 x ncols subrow starting at (i-1, j-1).
Definition sub_row.hpp:23
void check_row_index(const char *function, const char *name, const T_y &y, size_t i)
Check if the specified index is a valid row of the matrix This check is 1-indexed by default.
void check_column_index(const char *function, const char *name, const T_y &y, size_t i)
Check if the specified index is a valid column of the matrix.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9