Custom Functions plugin

Custom Functions plugin - functions: extended Max and Min, Unit of Measurement, Order of Magnitude - Messages

#121 Posted: 5/24/2021 4:18:17 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Fixed, plugin updated.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
2 users liked this post
Andrey Ivashov 5/24/2021 4:58:00 PM, sergio 5/25/2021 4:06:00 AM
#122 Posted: 5/31/2021 4:17:38 AM
Martin_B

Martin_B

21 likes in 84 posts.

Group: User

The function mat2sys.1 affects also the inner matrix, if evaluated numerically AND if this inner matrix contains only element.

Is that really the intended behaviour?

mat2sys1.png

I wanted to build my own mat2sys.1 using num2str, ... replace mat with sys... str2num
Looks like str2num is the "culprit", at least in my own function (only while evaluating numerically).

mat2sys1a.png

Maybe the better question is: Is this behaviour of str2num intended?
#123 Posted: 5/31/2021 11:02:37 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Is that really the intended behaviour?


There are miscellaneous applications, mostly Fourier stuff.

Fourier Geometric Coplanar COMPLEX.sm (17 KiB) downloaded 76 time(s).

#124 Posted: 5/31/2021 11:20:27 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

... I don't understand the remaining of the demand.

mat2sys.PNG
#125 Posted: 5/31/2021 11:24:14 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

mat2sys Otherwise.PNG
#126 Posted: 5/31/2021 12:13:07 PM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

The behaviour is driven by the evaluation of the outer sys(); on numerical evaluation, the "first level" of 1x1 matrices is suppressed.

2021-05-31 17_10_48-SMath Studio - [Documento1_].png

I'm not sure if it is really intended, but it might be part of the special behaviours of sys() (have to check the code/ask Andrey).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
2 users liked this post
NDTM Amarasekera 5/31/2021 12:29:00 PM, Martin_B 5/31/2021 12:37:00 PM
#127 Posted: 5/31/2021 1:02:53 PM
Martin_B

Martin_B

21 likes in 84 posts.

Group: User

By now I think it's the general behaviour (intended or not), that 1×1 matrices are evaluated to its element (numeric).

That's why I use Gettype() to check if an element was found.

matrix.png
#128 Posted: 6/9/2021 9:49:05 AM
Martin_B

Martin_B

21 likes in 84 posts.

Group: User

Found a bug in cases in combination with for loops and continue:

Two identical loops.
If if(,,) is used, continue causes the rest to be skipped (as expected).
If cases(,,) is used, continue has no effect

appVersion(4)="0.99.7822.147"
cases_continue.png
#129 Posted: 6/15/2021 2:40:15 AM
Martin_B

Martin_B

21 likes in 84 posts.

Group: User

Wrote




Sorry for pulling this to the surface.

I am wondering if I am the only one, who's using continue/break in a similar way.
At the moment I replace every cases with if(s), when used in combination with for loops and continue/break.
#130 Posted: 6/15/2021 3:19:03 AM
overlord

overlord

554 likes in 1333 posts.

Group: Moderator

Wrote

Found a bug in cases in combination with for loops and continue:

Two identical loops.
If if(,,) is used, continue causes the rest to be skipped (as expected).
If cases(,,) is used, continue has no effect

appVersion(4)="0.99.7822.147"


Confirmed, with a strange behavior.
Reversing the cases makes it correct.

2021-06-15_09-18.png
#131 Posted: 6/15/2021 3:46:04 AM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

At first glance I'm not sure about the cause, I'll check it.

However looking at the screenshot I have to point out once again that in general you shouldn't put definitions inside cases().
Unlike if(), when a condition or a case fails instead of throwing an error the whole function is returned like if doesn't exists. The consequence is that every argument is exposed and preprocessed, with potential unwanted behaviors respect to the expected logic. This is on the edge of SMath possibilities, but is what makes possible to use cases() whereas if() usually fails.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#132 Posted: 6/15/2021 3:55:31 AM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

Wrote


Sorry for pulling this to the surface.


Nothing to be afraid, is in the best interests of anyone having things to work flawlessly

Wrote

Confirmed, with a strange behavior.
Reversing the cases makes it correct.


Interesting, nice catch .

If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#133 Posted: 6/15/2021 7:56:43 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

AlgoSum.PNG
#134 Posted: 6/19/2021 8:12:37 AM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: Moderator

PLUGIN UPDATED SMath Studio 0.99.7822 and later

  • image2rgb/image2rgba: implemented different algorithm for linux users;
  • image2rgb/image2rgba fixed exception on failed disposal of temporary files;



If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#135 Posted: 7/19/2021 3:38:47 PM
overlord

overlord

554 likes in 1333 posts.

Group: Moderator

cases() refuse to be vectorized if it is a function.

2021-07-19_21-36.png
#136 Posted: 7/19/2021 4:13:54 PM
Martin_B

Martin_B

21 likes in 84 posts.

Group: User

Sometimes a line at the right place helps a lot.

And hovering the mouse over an expression helps finding the glitch.
if.png
#137 Posted: 7/19/2021 6:02:45 PM
overlord

overlord

554 likes in 1333 posts.

Group: Moderator

Wrote

Sometimes a line at the right place helps a lot.

And hovering the mouse over an expression helps finding the glitch.


Hah, I get it. Mysterious (but necessary according to this) line again.
Even though I use smath several years, I still forgot some of its tricks.
No need to hover the mouse, lasterror() has the same behavior.

Regards
  • New Posts New Posts
  • No New Posts No New Posts