Custom Functions plugin

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

#1 Posted: 8/31/2012 9:06:51 AM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Collection of multipurpose functions for SMath Studio.

2016-03-04 00_31_53-SMath Studio Desktop - [CustomFunctions_examples.sm].png

  • requirements: SMath Studio 0.97.5737 or later (previous versions may have different features);
  • installation: SMath Studio: Tools > Plugins... > Online Gallery;
  • documentation: File not found. File not found.;
  • sources: SVN repository.


>>> PLEASE REPORT IN THIS THREAD ANY ISSUE, MORE DETAILED AS POSSIBLE <<<
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
4 users liked this post
Mike Kaganski 4/23/2016 12:59:00 AM, ioan92 3/1/2014 3:57:00 PM, zoom 1/17/2016 5:13:00 PM, Radovan Omorjan 8/31/2012 11:16:00 AM
#2 Posted: 9/1/2012 11:12:44 AM
kilele

kilele

133 likes in 397 posts.

Group: User

thanks! please consider adding you usolve fuction to deal with units,
I would also like to get my hands dirty with .NET to create some plugins but for some reason I don't know where I should start,
could you recommend some tutorials/tips to deal with Smath in this respect of creating plugins ?
#3 Posted: 9/1/2012 11:55:08 AM
Edward Ulle

Edward Ulle

20 likes in 182 posts.

Group: Moderator

If you've done any programming, its relatively easy to develop custom functions for SMath. I've used Microsoft Visual Basic 2000 Express, which is free from the Microsoft web site. There is also an excellent example at the SMath wiki under Developers Guide. Its a little outdated and procedure calls have changed but when you compile and it complains about the calling sequence you can view the Object Browser and the SMath dlls and figure out the changes pretty easily. Good luck.
Ed
#4 Posted: 9/5/2012 9:21:12 AM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Wrote

thanks! please consider adding you usolve fuction to deal with units,


You're welcome

I thought about it, when I have some free time I will try to see if I can set the problem in an intelligent way... for example I have not yet figured out if you can recover somehow the units placed by the user on the right of equality ...

Wrote

I would also like to get my hands dirty with .NET to create some plugins but for some reason I don't know where I should start,
could you recommend some tutorials/tips to deal with Smath in this respect of creating plugins ?



like TheWizEd sais, it's relatively easy If you've done any programming experience previously...

However, I think you should follow these steps:

1) Chooose what programming language you want to use. In my background I have a little bit of C and PHP, so i preferred the Visual C# (C Sharp), but many other prefers the Visual Basic, and in the Visual SVN server there is also something in FORTRAN... so look in the web the differences and choose your...

2) Choose an IDE (integrated development environment)... here (IDEs and programming languages to use for developing plugins) there is a list of programming languages and IDEs (actually I'm using the SharpDevelop IDE).

3) Look in the wiki all the pages of the Developer Guide

4) Look in the SVN server all the plugings to try to understand how they are structured.

considers that the IDE usually have a converter to change the code from one language to another, so the examples on servers in other programming languages ​​can be analyzed. To analyze plugins in other languages (f.e. russian) copy and paste all the source code in the google translate window (from: russian to:english); some variable names are acronyms and cannot be translate dirctly, but if you separe the words where you see an uppercase letters almost certainly can be correctly transalte.


regards,

w3b5urf3r


P.S. I'll try to post the source of the plugins with more comments as possible, but consider that I am a noob so there may be something I have done that could have been done much more simply. :-p

EDIT: sources added in 1st post attachments.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#5 Posted: 10/3/2012 9:18:31 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Hi,

When trying the plugin I had some problems with the functions OoM.10 and eOoM.10. They are related to non-standard settings of decimal delimiter (Komma) and argument delimiter (Semicolon), see image. With standard settings (decimal delimiter dot and argument delimiter komma) no problem.

When choosing the functions from the menu or from the dynamic assistant, they appeare verbatim (i.e. with visible dot and without subscript formatting) but work correctly. If the expression is keyed in or created or copy-pasted, then formatting is done but the function is not known to SMath any more.

Also, if the sheet with the correctly working but incorrectly displayed function is saved and than re-opened, then the display is correct and the function is unknown.

May be the plugin is not to be blamed for this, than this would be a bug in SMath, but I can't tell.

Best regards, Martin Kraska
german1.PNG
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 users liked this post
Davide Carpi 10/3/2012 11:11:00 AM
#6 Posted: 10/3/2012 11:13:13 AM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Wrote

Hi,

When trying the plugin I had some problems with the functions OoM.10 and eOoM.10. They are related to non-standard settings of decimal delimiter (Komma) and argument delimiter (Semicolon), see image. With standard settings (decimal delimiter dot and argument delimiter komma) no problem.

When choosing the functions from the menu or from the dynamic assistant, they appeare verbatim (i.e. with visible dot and without subscript formatting) but work correctly. If the expression is keyed in or created or copy-pasted, then formatting is done but the function is not known to SMath any more.

Also, if the sheet with the correctly working but incorrectly displayed function is saved and than re-opened, then the display is correct and the function is unknown.

May be the plugin is not to be blamed for this, than this would be a bug in SMath, but I can't tell.

Best regards, Martin Kraska



Fixed, thank you


P.S. same issue will be fixed on the next relase of NonLinearSolvers.dll (Homotopy solvers)


best regards,

w3b5urf3r
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#7 Posted: 10/3/2012 11:57:07 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Wrote



Fixed, thank you


P.S. same issue will be fixed on the next relase of NonLinearSolvers.dll (Homotopy solvers)




Thank you! Works perfectly. (Thanks button throws error message)

Best regards, Martin Kraska
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#8 Posted: 10/14/2012 11:06:08 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Hi,

I have some problems using the Min and Max functions from the customFunctions plugin. It is NOT a custom delim settings issue.

Best regards, Martin
MinMax.sm (11 KiB) downloaded 141 time(s).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#9 Posted: 10/15/2012 1:59:56 PM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Wrote

Hi,

I have some problems using the Min and Max functions from the customFunctions plugin. It is NOT a custom delim settings issue.

Best regards, Martin



Thank you,

bug fixed and plugin updated b)


regards,

w3b5urf3r


SMath Studio - [MinMax.sm].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#10 Posted: 10/15/2012 4:34:22 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Wrote


bug fixed and plugin updated b)



Thank you for fixing the bug, Min/Max work fine now. However, there is a strange OS message when running your example file. It says something like "object reference not pointing to an object instance" or whatever might be the correct translation. It is not an smath message as it is in german even if I switch Interface language.

Also, this is not delimiter related.

Best regards, Martin.


customFunctions.sm (22 KiB) downloaded 117 time(s).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#11 Posted: 10/15/2012 4:56:53 PM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Wrote

Wrote


bug fixed and plugin updated b)



Thank you for fixing the bug, Min/Max work fine now. However, there is a strange OS message when running your example file. It says something like "object reference not pointing to an object instance" or whatever might be the correct translation. It is not an smath message as it is in german even if I switch Interface language.

Also, this is not delimiter related.

Best regards, Martin.



ooops

fixed & updated, thank you again


best regards,

w3b5urf3r
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#12 Posted: 11/1/2012 10:08:29 AM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

PLUGIN UPDATED

- Added Zeros(...)
- Added Ones(...)
- Added mat2sys(...) and sys2mat(...)
- Added Diag(...) - this function, previously shown in a NonlinearSolvers.dll BETA, has been moved in that plugin.


regards,

w3b5urf3r
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
sergio 11/2/2012 5:34:00 AM
#13 Posted: 12/14/2012 10:19:50 AM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

PLUGIN UPDATED

Added new function Clear(...)

Many thank to [userlink]Rising Eagle[/userlink] for the great trick


best regards,

w3b5urf3r
SMath Studio - [customFunctions.sm].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#14 Posted: 1/30/2013 7:52:04 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Hello,

I came across a situation where using a Clear()ed variable is not equivalent to a virgin one. The attached example has two equations, where I introduce a dummy variable in order to solve for the numerical value of a physical quantity (because neither solve nor roots can solve for variables with units).

The approach allows to keep the equation readable and the unit used in the quantity split is arbitrary.

Instead of using a new dummy variable (x,y...) for the numeric value in successive solve operations I tried to always use just one variable. This fails by whatever reason.

The odd thing is that Clear(x) does not help... Thus we do not really have a Clear() function, or did I miss some detail?

Eventually I want to do some experiments with the NonlinearSolvers plugin.




AS 7-7solve.sm (100 KiB) downloaded 112 time(s).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#15 Posted: 1/31/2013 4:03:05 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Hello Martin,

It seems that Clear() is not doing the job correctly. If I am not wrong Clear(x) equals to line(x), and I suppose it is missing something. If you use the line like Rising Eagle proposed


[MATH=eng]x:line(x,1,1)[/MATH]

it will clear the x and the following roots() using x will be Ok, but line(x) will produce this

[math=eng]x:line(x,#,2,1)[/math]

I do not know how w3b5urf3r escaped from this additional placeholder. If you just use Clear(x) it reported that everything is Ok (result 1) but by using roots() afterwards line-function not defined error appeared. If you use line(x) then there is an empty placeholder and the error would be Fill in all empty ellements. which is logical. Therefore, I suppose that Clear() function needs to be revised. Then, this will also do the job

[MATH=eng]x:line(x,x,2,1)[/MATH]

as could be expected

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
1 users liked this post
Davide Carpi 1/31/2013 5:42:00 AM
#16 Posted: 1/31/2013 6:00:07 AM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

PLUGIN UPDATED

- Added SettingsDirectory(): show the path of SMath settings directory (e.g. useful to easily get the output path of built-in function wfile())

- Fixed issue in Clear() shown by Martin and solved by Radovan

Wrote

[...] it will clear the x and the following roots() using x will be Ok, but line(x) will produce this

[math=eng]x:line(x,#,2,1)[/math]

I do not know how w3b5urf3r escaped from this additional placeholder. If you just use Clear(x) it reported that everything is Ok (result 1) but by using roots() afterwards line-function not defined error appeared. If you use line(x) then there is an empty placeholder and the error would be Fill in all empty ellements. which is logical. Therefore, I suppose that Clear() function needs to be revised. Then, this will also do the job

[MATH=eng]x:line(x,x,2,1)[/MATH]



Thank you very much Radovan

For future reference of SMath plugin developers, the previous Clear() function was based on an hack that is possible working with low-level evaluation: x=line(x) (that is not x=line(x,1,1)).


best regards,

w3b5urf3r
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
3 users liked this post
sergio 1/31/2013 8:09:00 AM, Radovan Omorjan 1/31/2013 10:09:00 AM, Martin Kraska 1/31/2013 6:32:00 PM
#17 Posted: 1/31/2013 7:02:53 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Hello w3bsurf3r,

thanks for the fix! Now that Clear() does the job I see that I have to freeze (using eval) results prior to re-definition of x. Thus the approach with re-using x is a rather cumbersome workaround for roots() not being able to solve for quantities with units.

Martin
AS 7-7solveClearx.png
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#18 Posted: 1/31/2013 9:39:57 PM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Wrote

Hello w3bsurf3r,

thanks for the fix! Now that Clear() does the job I see that I have to freeze (using eval) results prior to re-definition of x. Thus the approach with re-using x is a rather cumbersome workaround for roots() not being able to solve for quantities with units.

Martin



Indeed here I can see one of the (rare) situations where the use of the eval() function is clearly required :-p (see the attachment)
SMath Studio - [variables and parametrics.sm]_4.png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#19 Posted: 2/10/2013 12:21:36 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Hi w3bsurf3r,

I am surprised by the behaviour of sys2mat, see the attached example. Is this a bug or a feature? For the latter I see no good reasons (ok, i might be blind).

Could the function sys2mat possibly be redesigned such that it does not require eval() in order to produce sensible results?

Martin


sysmath.png
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#20 Posted: 2/10/2013 12:33:19 PM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Wrote

Hi w3bsurf3r,

I am surprised by the behaviour of sys2mat, see the attached example. Is this a bug or a feature? For the latter I see no good reasons (ok, i might be blind).

Could the function sys2mat possibly be redesigned such that it does not require eval() in order to produce sensible results?

Martin



mhhh... probably it's a bug; indeed the sys2mat() function it's quite simple, I'll try to think something a little bit more sophisticated...
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
  • New Posts New Posts
  • No New Posts No New Posts