pro runrenorm

dimensions=intarr(2)
print,'Enter dimensions of array:'
read,dimensions

jumpdist=1.0
print,'Enter step distance:'
read,jumpdist

probbin=1.0
print,'Enter probability binsize:'
read,probbin

outarray=fltarr(round(1/probbin)+1,2)
outarray(*,0)=(findgen(round(1/probbin)+1))*probbin

start=systime(0)
print,start

for p=0,n_elements(outarray)/2-1 do begin
  print,'Simulating P='+string(outarray(p,0))
  for t=0,100 do begin
    field=randomu(seed,dimensions(0),dimensions(1))
    renorm,field,out,1-outarray(p,0),jumpdist,2
    if out(0,0) eq 1 then outarray(p,1)=outarray(p,1)+1
  endfor
endfor

finish=systime(0)
print,finish
stop
end

pro renormsub,infield,outfield,i,j,renormsize,prob,jumpdist

m=i*renormsize
n=j*renormsize


testfield=fltarr(renormsize,renormsize)

testfield=infield(m:m+renormsize-1,n:n+renormsize-1)
currlabel=1

labels=intarr(renormsize,renormsize)
for k=0,renormsize-1 do begin
  for l=0,renormsize-1 do begin
     if (testfield(k,l) GT prob) and (labels(k,l) EQ 0) then begin
        labelclus,testfield,prob,jumpdist,labels,k,l,currlabel
        currlabel=currlabel+1 
     endif
  endfor
endfor

clusnum=max(labels)
for n=1,clusnum do begin
   prods=1
   prodf=1
   for c=0,renormsize-1 do begin
     prods=prods*(labels(c,0)-clusnum)
     prodf=prodf*(labels(c,renormsize-1)-clusnum)
   endfor
   if (prods+prodf EQ 0) then begin
       outfield(i,j)=1
   endif
endfor
end


pro labelclus,field,prob,jumpdist,labels,i,j,currlabel

sizeinfo=size(field)
exdist=round(jumpdist)

labels(i,j)=currlabel

for m=-exdist,exdist do begin
  for n=-exdist,exdist do begin
    distsq=m^2+n^2
    if (distsq LE jumpdist^2) AND (distsq GT 0) AND (i+m GE 0) AND $
       (i+m LE sizeinfo(1)-1) AND (j+n GE 0) AND $
       (j+n LE sizeinfo(2)-1) then begin
      if (field(i+m,j+n) GT prob) AND (labels(i+m,j+n) EQ 0) then begin
        labelclus,field,prob,jumpdist,labels,i+m,j+n,currlabel
      endif
    endif
  endfor
endfor

end

Return to the main page