Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline sublim21  
#1 Posted : 16 April 2013 18:32:11(UTC)
sublim21


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
File Attachment(s):
approxEllipse_1.sm (24kb) downloaded 28 time(s).

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Davide Carpi  
#2 Posted : 16 April 2013 19:41:22(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,650
Man
Italy
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

File Attachment(s):
approxEllipse_1.sm (24kb) downloaded 39 time(s).
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline sublim21  
#3 Posted : 16 April 2013 19:48:17(UTC)
sublim21


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?
Offline Davide Carpi  
#4 Posted : 16 April 2013 19:59:37(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,650
Man
Italy
Location: Italy

Was thanked: 1334 time(s) in 877 post(s)
Originally Posted by: sublim21 Go to Quoted Post
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
Offline sublim21  
#5 Posted : 16 April 2013 20:06:49(UTC)
sublim21


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.
Offline Davide Carpi  
#6 Posted : 16 April 2013 20:11:11(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,650
Man
Italy
Location: Italy

Was thanked: 1334 time(s) in 877 post(s)
You're welcome Good
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline Ber7  
#7 Posted : 16 April 2013 20:29:53(UTC)
Ber7


Rank: Advanced Member

Groups: Registered
Joined: 15/07/2010(UTC)
Posts: 437
Man
Israel
Location: Beer-Sheva

Was thanked: 520 time(s) in 288 post(s)
Originally Posted by: w3b5urf3r_reloaded Go to Quoted Post
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

File Attachment(s):
approxEllipse_1M.sm (24kb) downloaded 29 time(s).
Offline sublim21  
#8 Posted : 16 April 2013 20:50:27(UTC)
sublim21


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.
Users browsing this topic
Guest
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.