Registered Member
|
I would like to find the second largest element and in general the k^{th} largest element in VectorXd. Currently, I am aware that if 'A' is of type 'VectorXd', then
Thanks |
Moderator
|
You can use std::nth_element on a copy of the vector using vec.data() and vec.data()+vec.size() as begin/end iterators.
http://en.cppreference.com/w/cpp/algorithm/nth_element |
Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]