Function vector_largest (o2scl)¶
- 
template<class vec_t, class data_t>
 void o2scl::vector_largest(size_t n, vec_t &data, size_t k, vec_t &largest)¶
- Find the k largest entries of the first - nelements of a vector.- Given a vector - dataof size- nthis sets the first- kentries of the vector- largestto the k largest entries from vector- datain descending order. The vector- largestmust be allocated beforehand to hold at least- kelements.- This works similarly to the GSL function - gsl_sort_largest().- If - kis zero, then this function does nothing and returns o2scl::success .- Note - This \( {\cal O}(k N) \) algorithm is useful only when \( k << N \). 
- 
template<class vec_t, class data_t>
 void o2scl::vector_largest(vec_t &data, size_t k, vec_t &largest)¶
- Find the k largest entries of a vector of a vector. - Given a vector - data, this function sets the first- kentries of the vector- largestto the k largest entries from vector- datain ascending order. The vector- largestis resized if necessary to hold at least- kelements.- This works similarly to the GSL function - gsl_sort_largest().- If - kis zero, then this function does nothing and returns o2scl::success .- Note - This \( {\cal O}(k N) \) algorithm is useful only when \( k << N \).