cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Mathcad 15 stuck due to loop

ptc-5051640
1-Newbie

Mathcad 15 stuck due to loop

Hi,

My program implements a loop, when I increase my loop size , mathcad get stuck

doent show any output neither save anything. Kindly anyone could guide about this issue.

Thanks and Regards.

4 REPLIES 4
MikeArmstrong
5-Regular Member
(To:ptc-5051640)

Could you please upload a worksheet.

Mike

Iam attaching my code.

It looks like the program is very slow due to the reallocation of memory for the delay_err array.

Try the attached snippets. (You will need to enable the debug window to see the 'trace' output.)

Regards

Andy

Find attached some remarks. and comments. E.g. I'm not sure if you really want your vector Preamble to be constructed the way you did.

As Andy pointed out, it will not be necessary to initialize a Matrix element by element to zero. Most of the time you will not need to initialize at all. mathcad will create/enlarge a Matrix as needed and fills in zeros itself.

As written the number of cycles of the m-loop is dependend exponentially by the upper value of the L-range. To find out which routine is the most promising candidate for optimizing you will have to use trace, as Andy pointed out.

EDITED: I additionally attached an streamlined version "updated_3") and hope its correct. The different result are mainly (I think) because you did not reset your vector Binary and so got vectors of wrong length. Again, still read the comments in "updated_2".

The main question now is: Why do you need the L-loop and a 2-dimensional matrix? The row for the largest L will always include all the others. The value of L is used only to determine the largest value for m in the inner loop, so the results should be (and are) the same. L is also used as max-digits for the decimal to binary conversion but has no effect there, as the values converted alway have less than L bits in their full representation.

Top Tags