In lines 19 & 21 of your posted code, can you explain why you are using j(i) and not j (as given in the screenshot of the algorithm posted by you). It seems strange as in the 20th line, you do use the expression (j == i) (instead of j(i) == i or something else), which actually returns a big logical vector (since you are increasing the size of j in each iteration of the loop).
Also, do try preallocating x (and j if you actually intend to create a vector j) to the required size to improve performance of your code.
@Sultan: How could I know this? You did not explain what "initializing the permutation sequence" means. All I know is using an expensive call of num2cell(randperm()) is wasted, if you replace the result in the next line.
Please read your question again. Remember, that the readers cannot know, what this means: "Iterate the PWLCM x_i+1=F(x_i) by using (2) for N_0 times to get rid of the transient effect." The first sentence is not clear for the readers already. Then all we can do is to find some inconsistencies in your code, e.g. you use j(i) sometimes, but the complete vector j other times.
What's really missing from the question is some context. We've been given the middle of an algorithm with no explanation of what it's trying to do. My feeling is that this algorithm is probably badly designed for matlab.
In particular, the
mod(floor(x*1e15, L)) + 1
with L = 65536 looks like a poor attempt at manipulating floating point numbers at the bit level. There are faster ways of manipulating bits. The + 1 is also puzzling, without it you get numbers that fit into a uint16, with it 99.9985% of the possible numbers fit on 16 bits, and one number, 65536, requires 17 bits.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
7 Comments
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_717908
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_717908
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_717921
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_717921
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_717927
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_717927
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_718027
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_718027
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_718162
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_718162
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_718424
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_718424
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_718439
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/468721-how-to-permute-the-sequence-why-it-takes-to-much-time#comment_718439
Sign in to comment.