1#ifndef STAN_MATH_PRIM_FUN_SEGMENT_HPP
2#define STAN_MATH_PRIM_FUN_SEGMENT_HPP
17template <
typename Vec, require_vector_t<Vec>* =
nullptr>
18inline auto segment(
const Vec& v,
size_t i,
size_t n) {
24 static_cast<size_t>(v.size()));
26 return v.segment(i - 1, n);
30std::vector<T>
segment(
const std::vector<T>& sv,
size_t i,
size_t n) {
36 static_cast<size_t>(sv.size()));
39 for (
size_t j = 0; j < n; ++j) {
40 s.push_back(sv[i + j - 1]);
void check_less_or_equal(const char *function, const char *name, const T_y &y, const T_high &high, Idxs... idxs)
Throw an exception if y is not less than high.
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 - ...
void check_greater(const char *function, const char *name, const T_y &y, const T_low &low, Idxs... idxs)
Throw an exception if y is not strictly greater than low.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...