[Numpy-discussion] convert strides/shape/offset into nd index?
Zachary Pincus
zachary.pincus at yale.edu
Tue Dec 1 11:06:41 EST 2009
> Not to be a downer, but this problem is technically NP-complete. The
> so-called "knapsack problem" is to find a subset of a collection of
> numbers that adds up to the specified number, and it is NP-complete.
> Unfortunately, it is exactly what you need to do to find the indices
> to a particular memory location in an array of shape (2,2,...,2).
Ha ha, right -- that is the knapsack problem isn't it.
Oh well... I'll just require fortran- or C-style strided arrays, for
which case it is easy to unravel offsets into indices.
Thanks everyone!
Zach
More information about the NumPy-Discussion
mailing list