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

Home » Public Forums » archive » The IDL way: Find last non-zero value
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
The IDL way: Find last non-zero value [message #67747] Sun, 23 August 2009 17:07
Eric Hudson is currently offline  Eric Hudson
Messages: 19
Registered: June 2006
Junior Member
Hi,

I have a 2D array that looks something like:
x x 0 x x 0 0 x 0 0 0 0 0
x 0 x x x 0 x x x x 0 0 0
x 0 0 0 0 0 0 0 0 0 0 0 0
x x x x x 0 0 0 0 0 0 0 0

where x is some non-zero (positive definite) value. You'll notice
that each row ends with a string of zeros.
What I'd like to know is the 'IDL way' of returning a vector of the
location (column) of the last non-zero elements in each row. So in
this case, [7,9,0,4]

It's straight forward to program with loops, but I figure there must
be a clever way. I thought that maybe reversing it and doing a
cumulative total might be a start, but then I can't convince myself
that that is really going to be faster than doing a loop.

For a sense of scale, the real array is something like 200 x 160000

Thanks,
Eric
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Voxels in IDL
Next Topic: Re: SKIP the window "press click to continue" using the VIRTUAL MACHINE

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

Current Time: Thu Oct 09 07:33:48 PDT 2025

Total time taken to generate the page: 0.88120 seconds