comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Array element deletion
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Array element deletion [message #36387 is a reply to message #36386] Fri, 12 September 2003 06:27 Go to previous messageGo to previous message
jjbezair is currently offline  jjbezair
Messages: 2
Registered: July 2003
Junior Member
In article <bjsh0u$q77$1@news.ox.ac.uk>,
Edd Edmondson <eddedmondson@hotmail.com> wrote:
> Supposing I have a big array and I also have an array containing indices
> of unwanted elements. Is there a neat way of removing those elements from
> the array?
>
> Attempts using WHERE() have failed for me* and currently I'm looping
> through the array of indices and deleting them one at a time - which is
> fine when I've only got 20 or 30 of them but I doubt it'll scale well.
>
>
> * - I tried to make a list of indices that I wanted to keep using
> WHERE(indgen(x) ne unwanted) but that only produces the first
> n_elements(unwanted) of the correct indices.
>
> --
> Edd

I'm sure one or more of the gurus here will have a faster solution that
uses histogram, but I've always used index masks for this sort of thing

indexMask = lonarr(n_elements(bigArray))
indexMask(unwanted) = 1
wanted = where(indexMask == 0)
smallArray = bigArray(wanted)


of course you should check that where returns a nonzero array, etc., and
this method uses 4 times the memory of the original array, but memory is
cheap these days, and these 4 lines of code are quick to type...

I'm curious to see what more efficient techniques other people here use.

regards,
Jeff
--
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Contour overlay
Next Topic: Re: Floating Point Slider Widgets

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 00:39:20 PDT 2025

Total time taken to generate the page: 0.79900 seconds