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 mikekaganski  
#1 Posted : 30 March 2016 02:12:42(UTC)
mikekaganski


Rank: Advanced Member

Groups: Registered
Joined: 17/01/2013(UTC)
Posts: 296
Man
Russian Federation
Location: Khabarovsk, Russia

Was thanked: 151 time(s) in 107 post(s)
scr4.png

You may see that the trace() (that always returns 1) is eliminated from the expression, thus making this kind of use impossible. I may use line() to overcome it, but doing this is less convenient (takes more restructuring) than this technique.

So I ask Andrey, if possible, please disable optimizing out the trace() call. (Yes, I understand that passing a complex expression as an argument to F() may result in side effects, but this is up to user who wants to trace things.)
Best regards,
Mike Kaganski

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

Offline Davide Carpi  
#2 Posted : 30 March 2016 02:59:06(UTC)
Davide Carpi


Rank: Advanced Member

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

Was thanked: 1331 time(s) in 876 post(s)
I think this is not related to vectorize(); trace() is evaluated on function definition and since can handle symbolic data -> does his job on the output window and returns 1 (that is the value stored in the function - vectorize acts on what it knows, and what it knows is what is stored -> x^2). Solutions: use trace(eval(x))) or use a programming function F(x):line(...)

2016-03-30 02_10_50-SMath Studio Desktop - [Page1_].png

Edited by user 21 May 2016 18:41:47(UTC)  | Reason: marked as fixed by SS-2318

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 1 user thanked Davide Carpi for this useful post.
on 30/03/2016(UTC)
Offline mikekaganski  
#3 Posted : 30 March 2016 03:12:14(UTC)
mikekaganski


Rank: Advanced Member

Groups: Registered
Joined: 17/01/2013(UTC)
Posts: 296
Man
Russian Federation
Location: Khabarovsk, Russia

Was thanked: 151 time(s) in 107 post(s)
Originally Posted by: Davide Carpi Go to Quoted Post
I think this is not related to vectorize();


I also don't think so; vectorize() was used only to make multiple calls to the function to demonstrate that the output doesn't contain the multiple traces.

Quote:
trace() is evaluated on function definition and since can handle symbolic data -> does his job on the output window and returns 1 (that is the value stored in the function - vectorize acts on what it knows, and what it knows is what is stored -> x^2). Solutions: use trace(eval(x))) or use a programming function F(x):line(...)


Thank you. Well, I know the solutions (I cited one of them above); I included the tooltip to demonstrate the elimination in the resulting internal representation of the function; I only asked for a new possibility - to avoid the exclusion of trace() while processing the function definition on the grounds that SMath knows that its result is always 1. trace() is a debug function; it's not wise to eliminate debugging facilities (it's not C++, where I may use conditionals to control inclusion of debugging facilities).

Edited by user 30 March 2016 03:17:15(UTC)  | Reason: Not specified

Best regards,
Mike Kaganski
thanks 1 user thanked mikekaganski for this useful post.
on 30/03/2016(UTC)
Offline Davide Carpi  
#4 Posted : 30 March 2016 03:15:40(UTC)
Davide Carpi


Rank: Advanced Member

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

Was thanked: 1331 time(s) in 876 post(s)
Originally Posted by: mikekaganski Go to Quoted Post
Thank you. Well, I know the solutions (I cited one of them above); I included the tooltip to demonstrate the elimination in the resulting internal representation of the function; I only asked for a new possibility - to avoid the exclusion of trace() while processing the function definition on the grounds that SMath knows that its result is always 1.

Ah! I beg you pardon, read it again and you are right Good

Maybe we may think to avoid any preprocessing on none optimization Blush

Edited by user 30 March 2016 03:24:04(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
Offline mikekaganski  
#5 Posted : 30 March 2016 04:12:42(UTC)
mikekaganski


Rank: Advanced Member

Groups: Registered
Joined: 17/01/2013(UTC)
Posts: 296
Man
Russian Federation
Location: Khabarovsk, Russia

Was thanked: 151 time(s) in 107 post(s)
By the way: it would be awesome, if trace() woudn't return 1, but instead returned its argument itself (unchanged, unlike eval()). This way, we could simplify everything.
Consider this:

F(x;y):=x*y

I want to trace x. So instead of what I have to do now:

F(x;y):=trace(eval(x))*x*y

I would do simply

F(x;y):=trace(x)*y

This way, the very problem of trace() elimination could be solved, because its return would not be constant, but depend on its (last?) argument.
And by the way: eval() in trace won't work nicely in case of vectorize(), because it will trace the vector value of argument, not the individual params (thus, for instance, will be unhelpful if I want to find which specific input gives error and stops execution).
Best regards,
Mike Kaganski
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.