Nested loops take time to execute.

Nested loops take time to execute. - I have a calculation with several nested For and While loops, but the execution takes too long - Poruke

#1 Objavljeno: 15. 4. 2025. 19:43:22
David Daniel Alvarez Galvis

David Daniel Alvarez Galvis

1 svidjanja u 9 postova.

Grupa: User

Software Jacobsen V1.sm (100,14 KiB) preuzeto 1879 put(ova).

Hi everyone,
I have a calculation with several nested FOR and WHILE loops, but the execution is taking too long. I don’t know what the issue is.
Also, I don’t know how to extract the variables SIGA and SIGT from the IF statements inside the loops.
Thanks in advance for your time and help.
#2 Objavljeno: 16. 4. 2025. 09:28:21
Davide Carpi

Davide Carpi

1.444 svidjanja u 2.936 postova.

Grupa: Moderator

Hello,

I've put some trace() "traps" in your code and it seems that there is some logic issue at least in the while(k<=1) level.

2025-04-16 11_21_29-SMath Solver - [Software Jacobsen V1.sm_].png

First issue is that k is never initialized.

Second issue is that the first if() inside that while() sends the algorithm in an endless loop, since k doesn't change up to that point.

2025-04-16 11_21_49-SMath Solver - [Software Jacobsen V1.sm_].png

There might be more problems but I'll start from those.

Izmenjeno 16. 4. 2025. 09:49:28
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
4 korisnika je svidelo ovu objavu
Andrey Ivashov 16. 4. 2025. 12:17:18, sergio 16. 4. 2025. 16:08:42, NDTM Amarasekera 18. 4. 2025. 11:04:52, David Daniel Alvarez Galvis 15. 5. 2025. 19:30:46
#3 Objavljeno: 2. 5. 2025. 18:19:15
David Daniel Alvarez Galvis

David Daniel Alvarez Galvis

1 svidjanja u 9 postova.

Grupa: User

Hello, you're right. I made some changes that match what you suggested. I've already managed to solve the issues—thank you very much!
  • Novi postovi
  • Nema novih postova