1#ifndef STAN_MATH_PRIM_FUN_RANK_HPP
2#define STAN_MATH_PRIM_FUN_RANK_HPP
19template <
typename C, require_container_t<C>* =
nullptr>
20inline int rank(
const C& v,
int s) {
24 const auto& vec_ref =
to_ref(vec);
26 return (vec_ref.array() < vec_ref.coeff(s)).template cast<int>().sum();
int rank(const T &v, int s)
Return the number of components of v less than v[s].
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
void check_range(const char *function, const char *name, int max, int index, int nested_level, const char *error_msg)
Check if specified index is within range.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...