Automatic Differentiation
 
Loading...
Searching...
No Matches
tail.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_TAIL_HPP
2#define STAN_MATH_PRIM_FUN_TAIL_HPP
3
7#include <vector>
8
9namespace stan {
10namespace math {
11
22template <typename T, require_vector_t<T>* = nullptr>
23inline auto tail(const T& v, size_t n) {
24 if (n != 0) {
25 check_vector_index("tail", "n", v, n);
26 }
27 return v.tail(n);
28}
29
40template <typename T>
41std::vector<T> tail(const std::vector<T>& sv, size_t n) {
42 if (n != 0) {
43 check_std_vector_index("tail", "n", sv, n);
44 }
45 std::vector<T> s(sv.end() - n, sv.end());
46 return s;
47}
48
49} // namespace math
50} // namespace stan
51
52#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...
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
void check_std_vector_index(const char *function, const char *name, const std::vector< T > &y, int i)
Check if the specified index is valid in std vector This check is 1-indexed by default.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...