Automatic Differentiation
 
Loading...
Searching...
No Matches
tail.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_OPENCL_PRIM_TAIL_HPP
2#define STAN_MATH_OPENCL_PRIM_TAIL_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 tail(T_x&& x, size_t n) { // NOLINT
25 check_vector("head (OpenCL)", "x", x);
26 if (n != 0) {
27 check_vector_index("head", "n", x, n);
28 }
29 if (x.rows() == 1) {
30 return block(std::forward<T_x>(x), 1, 1 + x.cols() - n, 1, n);
31 } else {
32 return block(std::forward<T_x>(x), 1 + x.rows() - n, 1, n, 1);
33 }
34}
35} // namespace math
36} // namespace stan
37#endif
38#endif
void check_vector_index(const char *function, const char *name, const T &y, size_t i)
Check if the specified index is a valid element of the row or column vector This check is 1-indexed b...
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 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
auto tail(T_x &&x, size_t n)
Return the specified number of elements as a vector or row vector (same as input) from the back of th...
Definition tail.hpp:24
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...