Custom Functions plugin

Custom Functions plugin - functions: extended Max and Min, Unit of Measurement, Order of Magnitude - Сообщения

#1 Опубликовано: 31.08.2012 09:06:51
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: 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: Файл не найден. Файл не найден.;
  • 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 пользователям понравился этот пост
Mike Kaganski 23.04.2016 00:59:00, ioan92 01.03.2014 15:57:00, zoom 17.01.2016 17:13:00, Radovan Omorjan 31.08.2012 11:16:00
#2 Опубликовано: 01.09.2012 11:12:44
kilele

kilele

133 сообщений из 397 понравились пользователям.

Группа: 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 Опубликовано: 01.09.2012 11:55:08
Edward Ulle

Edward Ulle

20 сообщений из 182 понравились пользователям.

Группа: 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 Опубликовано: 05.09.2012 09:21:12
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: 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 Опубликовано: 03.10.2012 09:18:31
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: 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 пользователям понравился этот пост
Davide Carpi 03.10.2012 11:11:00
#6 Опубликовано: 03.10.2012 11:13:13
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: 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 Опубликовано: 03.10.2012 11:57:07
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: 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 Опубликовано: 14.10.2012 11:06:08
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: 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 КиБ) скачан 176 раз(а).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#9 Опубликовано: 15.10.2012 13:59:56
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: 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 Опубликовано: 15.10.2012 16:34:22
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: 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 КиБ) скачан 147 раз(а).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#11 Опубликовано: 15.10.2012 16:56:53
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: 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 Опубликовано: 01.11.2012 10:08:29
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: 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 пользователям понравился этот пост
sergio 02.11.2012 05:34:00
#13 Опубликовано: 14.12.2012 10:19:50
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: 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 Опубликовано: 30.01.2013 19:52:04
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: 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 КиБ) скачан 147 раз(а).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#15 Опубликовано: 31.01.2013 04:03:05
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: 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 пользователям понравился этот пост
Davide Carpi 31.01.2013 05:42:00
#16 Опубликовано: 31.01.2013 06:00:07
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: 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 пользователям понравился этот пост
sergio 31.01.2013 08:09:00, Radovan Omorjan 31.01.2013 10:09:00, Martin Kraska 31.01.2013 18:32:00
#17 Опубликовано: 31.01.2013 19:02:53
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: 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 Опубликовано: 31.01.2013 21:39:57
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: 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 Опубликовано: 10.02.2013 12:21:36
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: 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 Опубликовано: 10.02.2013 12:33:19
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: 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
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений