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

Home » Public Forums » archive » Fast computation of pairwise array element differences
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
Fast computation of pairwise array element differences [message #78636] Sun, 04 December 2011 08:28
erik is currently offline  erik
Messages: 2
Registered: June 1993
Junior Member
Hi folks,

I have the following problem that I want to solve with IDL, but do not
know how:

I have a n^2 array (2D) with some arbitrary numercial data in it and a
lengthscale L (let's say a certain number of cells smaller than n).
What I want to do now is to compute all possible differences of
elements in this 2D array that are L cells far away from each other,
but *without using loops*!

Of course, I could do the following (in pseudo code):

------
diff = 0.d

FOR x = 0, n do begin
FOR y = 0, n do begin
- Take array element (x, y)
- Look for all cells that are L cells away from cell (x, y)
(e.g. in a ring arround (x, y) with radius of L cells)
- compute all differences from (x, y) to the other cells in a
radius of L
- Summ differences up in a variable diff
- continue with next array element and compute next differences
and so on...
ENDFOR
ENDFOR
------

This is an easy mathematical operation. Nevertheless, for an array of
500 x 500 it takes about hours to step through all the looping
processes and to calculate the sum of really all possible differences
on a lengthscale of L cells...

Does someone have another idea how to avoid the loops in this case and
to compute all possible differences in such an array very easily?

Thank you very much!

Kind regards,

Erik
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to create a 2D mask that automatically half’s an irregularly shaped 2D array from top to bottom?
Next Topic: Significant Update of cgImage

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

Current Time: Wed Oct 08 20:06:40 PDT 2025

Total time taken to generate the page: 0.00356 seconds