[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Vectorizing loops
From: |
andrewcd |
Subject: |
Re: Vectorizing loops |
Date: |
Sat, 5 Nov 2011 11:15:31 -0700 (PDT) |
To add to my problem:
I now have an even more massive loop. It is calculating as I type, and I
estimate that it will take about 4 hours to finish at current rates.
I have two matrices -- one is rainfall data at low resolution, and the other
is greenness data at high resolution. I want to assign the rainfall values
to the appropriate greenness rows in the greenness matrix (bearing in mind
that I'll find a better way to do a smoothing later, once I figure out this
easy step).
The greenness matrix (G) is 584304 x 4.
s = []
for i = 1:rows(G)
disp(i)
disp('of 584304')
for j = 1:rows(X)
if size(s,1)!=i
if G(i,3) = X(j,3)
xdiff=G(i,1)-X(j,1);
if xdiff<.1
if xdiff>0
ydiff=G(i,2)-X(j,2) ;
if ydiff<.1
if ydiff>0
s(i,1) = X(j,4);
endif
endif
endif
endif
endif
endif
end
end
Try as I might, I cant think of how to vecotrize this. If anyone would be
so kind as to provide an example, I'd be able to tweak and re-implement over
and over.
Many thanks!
Andrew
--
View this message in context:
http://octave.1599824.n4.nabble.com/Vectorizing-loops-tp3992596p3993901.html
Sent from the Octave - General mailing list archive at Nabble.com.