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

Home » Public Forums » archive » Re: faster then where possible?
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
Re: faster then where possible? [message #66275] Thu, 07 May 2009 09:42 Go to next message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
rogass@googlemail.com wrote:
> Hi,
> i'm searching for some alternative approaches to compute the following
> "much" faster:
>
> -> matrix1 has m columns and n rows, matrix2 has 2 columns and n rows
> -> the values in matrix2 are NOT in matrix1, but within the min-max-
> range of matrix1
>
> szm1=size(matrix1,/dimensions)
> szm2=size(matrix2,/dimensions)
> index={ind:ptr_new()}
> indices=replicate(index,szm2[1])
>
> for j=0ull,szm1[1] do begin
> helpindex= where(matrix1[*,j] ge matrix2[0,j] and matrix1[*,j] le
> matrix2[1,j],c)
> if c gt 0 then begin
> indices[j] = ptr_new(uintarr(c))
> (*indices)[j]=helpindex
> endif else continue
> endfor
>
> It seems to be a typical Nearest-Neighbor-Problem, but all alternative
> approaches I tried were always slower. Maybe someone here has a good
> idea?
>
> Thank you and best regards
>
> Christian
>

Hi,

if you have enough memory, you could do something like this (not tested):
minArray = rebin(matrix2[0,*], n_elements(matrix1[*,0],
n_elements(matrix1[0,*]))
maxArray = rebin(matrix2[1,*], n_elements(matrix1[*,0],
n_elements(matrix1[0,*]))

goodIdx = where (matrix2 lt minArray and matrix2 gt minarray)

then you just have to transform the index so they match each row

Jean
Re: faster then where possible? [message #66464 is a reply to message #66275] Fri, 08 May 2009 02:12 Go to previous message
rogass is currently offline  rogass
Messages: 200
Registered: April 2008
Senior Member
Dear Jean,
good idea, but unfortunately it is much slower (20 times) in my
specific case (spectral resampling routine). But thank you!

Any other ideas? Maybe some triangulation magic for getting nearest
neighbor? :)

Best regards

Christian
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: envi_output_to_external_format - jpeg output not working
Next Topic: P value for the regression analysis?

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

Current Time: Wed Oct 08 19:34:22 PDT 2025

Total time taken to generate the page: 0.00611 seconds