[SciPy-user] extracting elements of a matrix using arrays as indices
Wed May 21 09:17:04 CDT 2008
On Wed, May 21, 2008 at 10:06 AM, Robin <firstname.lastname@example.org> wrote:
> data = rand(648,690)
> data[data<0.14] = 0
Ah, that's clearer than my example. :)
> I tried data[ix_(i,j)] = 0 (not sure why you need to multiply itself
> by zero - you can just assign the value 0 directly) but it appears to
> be very slow so if you can use the boolean indexing it will probably
> be better.
I didn't have time to figure out why, but using ix_ like that was
enormously slow and used a *lot* of memory. It brought my system to a
crawl (until I killed it) with a 300x300 matrix, while the boolean
indexing method is very fast with 3000x3000.
More information about the SciPy-user