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

Home » Public Forums » archive » Re: TRIANGULATE. Finding contiguous cells efficiently?
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: TRIANGULATE. Finding contiguous cells efficiently? [message #52718 is a reply to message #52694] Mon, 26 February 2007 04:27 Go to previous messageGo to previous message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
On 25 Feb 2007 19:37:54 -0800, "Libertan" <tbethell@umich.edu> wrote:

> In case it has gone into the abyss

It has :-)

> thoughts:
> 1) The connectivity list might be fruitful after all.

I don't think this could make things faster.

> 2) Also I think that in these looped codes, the accumulated info in
> the loop can be used to increasingly reduce the remaining workload.

Well ... one could think of things like: "deleting triangles which are
already used 3 times". Example below gives an 18% improvement on my
PC, when using the shrinking-triangles.



pro test
x=RANDOMU(seed,10000,/normal)*10
y=RANDOMU(seed,10000,/normal)*10
nnodes=n_elements(x)
TRIANGULATE, X, Y, triangles
s=size(triangles,/dimensions)

; 1. With loop
Tm=systime(1)
ctriangles=fltarr(s[0],s[1],3)
for i=0,s[1]-1 do begin
t=total((triangles eq triangles[0,i])+$
(triangles eq triangles[1,i])+$
(triangles eq triangles[2,i]),1)

ind=where(t eq 2,ct)
if ct ne 0 then ctriangles[*,i,0:ct-1]=triangles[*,ind]
endfor
; Third dimension gives the three contiguous neighbours
print,systime(1)-Tm
Tm=systime(1)

; 2. With loop + shrinking triangles
Tm=systime(1)
ctriangles=fltarr(s[0],s[1],3)
trshrink=triangles
nused=bytarr(s[1])
indtr=lindgen(s[1])
for i=0,s[1]-1 do begin
t=total((trshrink eq triangles[0,i])+$
(trshrink eq triangles[1,i])+$
(trshrink eq triangles[2,i]),1)

ind=where(t eq 2,ct)
if ct ne 0 then begin
ctriangles[*,i,0:ct-1]=trshrink[*,ind]
nused[ind]++

tmp=where(nused eq
3,ct,COMPLEMENT=ind,NCOMPLEMENT=ct2)
if ct ne 0 then begin
if ct2 ne 0 then begin
nused=nused[ind]
trshrink=trshrink[*,ind]
endif
endif
endif
endfor
; Third dimension gives the three contiguous neighbours
print,systime(1)-Tm
Tm=systime(1)
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Improving a piece of code with arrays and for-loops
Next Topic: oplot in 3d ??

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

Current Time: Thu Oct 09 21:26:03 PDT 2025

Total time taken to generate the page: 1.19886 seconds