1 #ifndef STAN_MATH_PRIM_FUN_CSR_U_TO_Z
2 #define STAN_MATH_PRIM_FUN_CSR_U_TO_Z
3 
4 #include <stan/math/prim/err.hpp>
5 #include <stdexcept>
6 #include <vector>
7 
8 namespace stan {
9 namespace math {
10 
11 /** \addtogroup csr_format
12  *  @{
13  */
14 
15 /**
16  * Return the z vector computed from the specified u vector at the
17  * index for the z vector.
18  *
19  * @param[in] u U vector.
20  * @param[in] i Index into resulting z vector.
21  * @return z[i] where z is conversion from u.
22  * @throw std::domain_error if u is zero length.
23  * @throw std::out_of_range if i is out of range.
24  */
csr_u_to_z(const std::vector<int> & u,int i)25 inline int csr_u_to_z(const std::vector<int>& u, int i) {
26   check_range("csr_u_to_z", "i", u.size(), i + 1, "index out of range");
27   return u[i + 1] - u[i];
28 }
29 
30 }  // namespace math
31 }  // namespace stan
32 
33 #endif
34