Need to speed up this loop in matlab -
Need to speed up this loop in matlab -
i'm running mcmc simulation in matlab , need speed loop iterations, after profiling found next loop taking time far:
for i=1 : n u=0; ii=0 : t-1 if bitget(r(i),8-ii)==1 u=bitset(u,ii+1+2*t); end if bitget(g(i),8-ii)==1 u=bitset(u,ii+1+t); end if bitget(b(i),8-ii)==1 u=bitset(u,ii+1); end end %u = tcb(i)*tcr(i); p(1+u) = p(1+u) + 1; %kernel(x(i)*x(i)+y(i)*y(i)); end
it part of algorithm obtain colour distribution of image. here profile results:
you can save time defining 8-ii , ii+1 variables @ origin of loop, thereby reducing repeated calculations.
matlab
Comments
Post a Comment