Automatic Differentiation
 
Loading...
Searching...
No Matches
segment.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_PRIM_SEGMENT_HPP
2#define STAN_MATH_OPENCL_PRIM_SEGMENT_HPP
3#ifdef STAN_OPENCL
4
8
9namespace stan {
10namespace math {
11
22template <typename T_x,
23 require_nonscalar_prim_or_rev_kernel_expression_t<T_x>* = nullptr>
24inline auto segment(T_x&& x, size_t i, size_t n) {
25 check_vector("segment (OpenCL)", "x", x);
26 if (x.rows() == 1) {
27 return block(std::forward<T_x>(x), 1, i, 1, n);
28 } else {
29 return block(std::forward<T_x>(x), i, 1, n, 1);
30 }
31}
32} // namespace math
33} // namespace stan
34#endif
35#endif
void check_vector(const char *function, const char *name, const Mat &x)
Check the input is either a row vector or column vector or a matrix with a single row or column.
auto segment(T_x &&x, size_t i, size_t n)
Return the specified number of elements as a row/column vector starting from the specified element - ...
Definition segment.hpp:24
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
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9