Automatic Differentiation
 
Loading...
Searching...
No Matches
block.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_BLOCK_HPP
2#define STAN_MATH_PRIM_FUN_BLOCK_HPP
3
6
7namespace stan {
8namespace math {
9
21template <typename T, require_matrix_t<T>* = nullptr>
22inline auto block(const T& m, size_t i, size_t j, size_t nrows, size_t ncols) {
23 check_row_index("block", "i", m, i);
24 check_row_index("block", "i+nrows-1", m, i + nrows - 1);
25 check_column_index("block", "j", m, j);
26 check_column_index("block", "j+ncols-1", m, j + ncols - 1);
27 return m.block(i - 1, j - 1, nrows, ncols);
28}
29
30} // namespace math
31} // namespace stan
32
33#endif
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.
auto block(T_x &&x, 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:24
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 ...