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 Razonar  
#1 Posted : 05 October 2018 21:33:54(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi. There are not try-catch here.

Clipboard01.gif

Best regards.
Alvaro.

Edited by moderator 06 October 2018 16:03:26(UTC)  | Reason: added BTS ID

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

Offline Jean Giraud  
#2 Posted : 06 October 2018 03:01:23(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Razonar Go to Quoted Post
There are not try-catch here.


There are not too many applications in this forum.
It works numerically ... visit this application.

Jean

Image Rotate RGB Copy.sm (350kb) downloaded 15 time(s).
Offline Razonar  
#3 Posted : 06 October 2018 15:21:26(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
This seems to be a workaround for the bug.

Clipboard01.gif

Length_Try_Catch.sm (9kb) downloaded 9 time(s).

Functions like this Length, and equivalents for Rows and Cols are a standard way in Mathcad to check if one works with matrices or scalars, avoiding the use of IsMatrix (absent in SMath at this time), and saving some program steps.

Best regards.
Alvaro.

PD: Try-catch is the name in Maple and others for the SMath try-on error.

Edited by user 06 October 2018 15:25:10(UTC)  | Reason: Not specified

thanks 1 user thanked Razonar for this useful post.
on 06/10/2018(UTC)
Offline Davide Carpi  
#4 Posted : 06 October 2018 16:15:00(UTC)
Davide Carpi


Rank: Advanced Member

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

Was thanked: 1329 time(s) in 875 post(s)
Added in the BTS as SS-3568


P.S. as for now, if you have custom functions:

2018-10-06 15_14_15-Window.png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline Razonar  
#5 Posted : 07 October 2018 05:36:17(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Originally Posted by: Davide Carpi Go to Quoted Post
Added in the BTS as SS-3568


P.S. as for now, if you have custom functions:

2018-10-06 15_14_15-Window.png


Hi Davide. Thanks.
Best regards. For the plugin and for add as issue.
Alvaro
Offline Razonar  
#6 Posted : 07 October 2018 08:32:15(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
With this version of IsMatrix you catch the length for symbolic matrices. Also, avoiding the use of strings have some advantages over the simple version, here as IsMat.

Length.sm (49kb) downloaded 14 time(s).

Clipboard01.gif

Best regards.
Alvaro
Offline Andrey Ivashov  
#7 Posted : 30 October 2018 18:35:13(UTC)
Andrey Ivashov


Rank: Administration

Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member
Joined: 11/07/2008(UTC)
Posts: 1,616
Man
Russian Federation

Was thanked: 1978 time(s) in 666 post(s)
Described behavior of the try...catch is by design.

In your example length(x) calculated symbolically and does not raise an error. You can check it by calculating length(x) with symbolic optimization.
To have the behavior you want please use eval(lenght(x)) instead.

Best regards.
Offline Razonar  
#8 Posted : 30 October 2018 22:08:18(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Originally Posted by: Andrey Ivashov Go to Quoted Post
Described behavior of the try...catch is by design.

Best regards.


Hi Andrey. Thanks for the clarification. I guess that the origin of this behavior is from about which is the "default unassigned variable type" in SMath. In maple and mathcad it is a complex number, but in SMath it seems to be a matrix or anything else:

Clipboard03.gif

If this is the case, it's correct to return rows, cols and length as an error in numerical evaluations and unevaluated form in symbolic ones.

For other side, it seems that if actuate like having something like evalb (maple's eval boolean), forcing the numerical evaluation, as it is showed in the yellow regions, and widely apply in the attached. This behavior is very useful, at least to me, because enable following routines for Length, Rows, Cols, IsMatrix (without using num2str which causes some issues for some applications) and others useful tools, which yield the same result for numeric and symbolic evaluations, making more easy the live to me.

Length.sm (62kb) downloaded 18 time(s).

Best regards.
Alvaro.

PD: It seems that in the attached file I change the default font color, but don't know how, neither how to revert it to black.
thanks 1 user thanked Razonar for this useful post.
on 31/10/2018(UTC)
Offline Davide Carpi  
#9 Posted : 31 October 2018 13:40:04(UTC)
Davide Carpi


Rank: Advanced Member

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

Was thanked: 1329 time(s) in 875 post(s)
Originally Posted by: Razonar Go to Quoted Post
Hi Andrey. Thanks for the clarification. I guess that the origin of this behavior is from about which is the "default unassigned variable type" in SMath. In maple and mathcad it is a complex number, but in SMath it seems to be a matrix or anything else

Unassigned variables are considered as unknown type; there were problems in the past because they were consider scalar or matrices...

Clipboard03.gif
I suggest to open a separate correction request here or in the bug tracker to improve behavior of length/rows/cols when a matrix contains unknowns... Good

Edited by user 01 November 2018 02:47:19(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
thanks 1 user thanked Davide Carpi for this useful post.
on 01/11/2018(UTC)
Offline Jean Giraud  
#10 Posted : 01 November 2018 01:22:50(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
... plenty of things will reflect in "on-error"

Maths on_error.sm (16kb) downloaded 13 time(s).
Offline Razonar  
#11 Posted : 01 November 2018 04:06:16(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi Davide. Thanks for your answer.

Originally Posted by: Davide Carpi Go to Quoted Post

Unassigned variables are considered as unknown type; there were problems in the past because they were consider scalar or matrices...


Good to know. So, the results for rows, length, etc. it's correct. I don't have enough time nor ideas about how to test try...on error function, but guess that it is correcto too.

Originally Posted by: Davide Carpi Go to Quoted Post

I suggest to open a separate correction request here or in the bug tracker to improve behavior of length/rows/cols when a matrix contains unknowns... Good


Thanks for the suggestion. But don't know what could be more convenient. For instance, maple have evalb (booleans), evalm (matrix, but obsolete in news versions), evalc (complexes) and some others for modify the way that evaluations are done. Also, the eval maple's function is like the "at" function in the Custom Functions plugin. So, maybe instead of modify rows and those functions, could be more practical introduce a second argument for eval, of the type of "complex", or "scalar", or "matrix" or things like this. Or maybe there are some simplify function under development which can handle those cases, or ... I actually don't know enogh for say which is the best path to follow.

Best regards.
Alvaro.
Offline Jean Giraud  
#12 Posted : 02 November 2018 21:58:04(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Andrey Ivashov Go to Quoted Post
Described behavior of the try...catch is by design.


What should it do that is missing ? Catch errors piecewise in program ?

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