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 
Return to the default flat view Create a new topic Submit Reply
Re: faster then where possible? [message #66275] Thu, 07 May 2009 09:42 Go to previous 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
[Message index]
 
Read Message
Read Message
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:12:25 PDT 2025

Total time taken to generate the page: 0.00445 seconds