Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Dhivya

Posts: 23
Registered: 9/14/13
Time consumption in loop
Posted: Sep 20, 2013 2:28 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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??



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.