[Numpy-discussion] Find the N maximum values and corresponding indexes in an array
Neal Becker
ndbecker2 at gmail.com
Wed Dec 2 22:12:31 EST 2009
Keith Goodman wrote:
...
> Oh, I thought he meant there was a numpy function for partial sorting.
>
Actually, I do use this myself. My code is a boost::python wrapper or
the std::partial_sum using pyublas. Here's the main pieces:
template<typename out_t, typename in_t>
inline out_t partial_sum (in_t const& in) {
out_t out (boost::size (in));
std::partial_sum (boost::begin (in), boost::end (in), boost::begin
(out));
return out;
}
...
def ("partial_sum",
&partial_sum<pyublas::numpy_vector<T>,pyublas::numpy_strided_vector<T>
>);
More information about the NumPy-Discussion
mailing list