Rank: Advanced Member Groups: Registered
Joined: 18/05/2011(UTC) Posts: 36
Was thanked: 3 time(s) in 3 post(s)
|
Hey all, I've written a smath sheet for representing ellipses as a series of n vectors. however, when i run the sheet it takes around 6-7 seconds to calculate on this computer. I was wondering if someone could take a look at the code and see if there's something i'm missing that could speed up the calculations. I've attempted changing the code various ways to speed it up, but to no avail. Much appreciated, -Pete
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,650 Location: Italy Was thanked: 1334 time(s) in 877 post(s)
|
Apply an eval() function to theta, rad1 and rad2 (this speed up the worksheet from 15 s to 3 s on my notebook) regards, w3b5urf3r Edited by user 16 April 2013 19:43:18(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 18/05/2011(UTC) Posts: 36
Was thanked: 3 time(s) in 3 post(s)
|
thanks a lot man.
so why does eval make the calculations go faster?
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,650 Location: Italy Was thanked: 1334 time(s) in 877 post(s)
|
Originally Posted by: sublim21 thanks a lot man.
so why does eval make the calculations go faster? The eval() function force a local calculation, so all operations made before the eval are "forgotten" in following calculations (in that point remain a division of two numbers). Another "best practice" it's to select and set all optimizations to numeric; this could take you some appreciable speed advantages. best regards, w3b5urf3r |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 18/05/2011(UTC) Posts: 36
Was thanked: 3 time(s) in 3 post(s)
|
duly noted. Much obliged man.
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,650 Location: Italy Was thanked: 1334 time(s) in 877 post(s)
|
You're welcome |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/07/2010(UTC) Posts: 437 Location: Beer-Sheva Was thanked: 520 time(s) in 288 post(s)
|
Originally Posted by: w3b5urf3r_reloaded Apply an eval() function to theta, rad1 and rad2 (this speed up the worksheet from 15 s to 3 s on my notebook) regards, w3b5urf3r Additionally apply an eval() function to retMatк regards,Ber7
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 18/05/2011(UTC) Posts: 36
Was thanked: 3 time(s) in 3 post(s)
|
much obliged ber. It seems to me, that any heavy calculations done inside a function should be done with an eval statement.
when declaring the definition of a variable, eval should be used if its a calculation. like a:=5*b should be a:=eval( 5 * b )
while,
a:=b should NOT be a:=eval( b )
By the way, both ber7 and websurfer are tremendous assets to the community. thanks for posting.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.