Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Time consumption in loop
Replies: 19   Last Post: Sep 30, 2013 1:11 PM

 Messages: [ Previous | Next ]
 Dhivya Posts: 25 Registered: 9/14/13
Time consumption in loop
Posted: Sep 20, 2013 2:28 AM

In my work using Chinese remainder theorem as

C = num2cell(reshape(n, 4, 65536), 1); % n is an array of 262144 elements
for i=1:65536
l=length(C{i});
ba=C{i}';
ga=[311 313 317 293];
[bx by] = meshgrid(ba, ba);
bb = gcd(bx,by)-diag(ba);
pp = ~sum(sum(bb>1));
xo = by-diag(ba-1);
Mk = prod(xo);
[Gk, nk, Nk] = gcd ( ba, Mk ) ;
Sum_ga_Nk_Mk = sum ( (ga .* Nk) .* Mk ) ;
f1(i) = mod(Sum_ga_Nk_Mk,prod(ba));
end

The time consumption for this loop is quite long as the loop is repeated for 65536 times
Can you help me for reducing it??

Date Subject Author
9/20/13 Dhivya
9/20/13 Roger Stafford
9/20/13 Roger Stafford
9/21/13 Dhivya
9/21/13 Dhivya
9/21/13 Roger Stafford
9/21/13 Dhivya
9/22/13 Roger Stafford
9/25/13 Dhivya
9/25/13 Roger Stafford
9/25/13 Roger Stafford
9/26/13 Dhivya
9/26/13 Roger Stafford
9/27/13 Dhivya
9/27/13 Roger Stafford
9/27/13 Roger Stafford
9/28/13 Dhivya
9/28/13 Roger Stafford
9/30/13 Dhivya
9/30/13 Roger Stafford