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 sublim21  
#1 Posted : 08 January 2013 18:49:29(UTC)
sublim21


Rank: Advanced Member

Groups: Registered
Joined: 18/05/2011(UTC)
Posts: 36

Was thanked: 3 time(s) in 3 post(s)
Hey all,

I've been trying to build a program that will return the type a variable is.

Basically, the function is an expansion of the IsString function, such that there is,

IsMatrix
IsNumber
IsSystem

etc..

I've attempted to accomplish this with num2str declarations and then seeing if there exists a string of "mat(" in the beginning. However, due to the problems of num2str 'ing matrices, this method fails. As does any other method i've tried.

I feel the best way to accomplish the variable type would be by building a plugin, however, my plugin building skills aren't up to the task. :/

-Pete

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

Offline Davide Carpi  
#2 Posted : 08 January 2013 19:54:55(UTC)
Davide Carpi


Rank: Advanced Member

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

Was thanked: 1340 time(s) in 879 post(s)
Originally Posted by: sublim21 Go to Quoted Post
Hey all,

I've been trying to build a program that will return the type a variable is.

Basically, the function is an expansion of the IsString function, such that there is,

IsMatrix
IsNumber
IsSystem

etc..

I've attempted to accomplish this with num2str declarations and then seeing if there exists a string of "mat(" in the beginning. However, due to the problems of num2str 'ing matrices, this method fails. As does any other method i've tried.

I feel the best way to accomplish the variable type would be by building a plugin, however, my plugin building skills aren't up to the task. :/

-Pete


You can try to use/enhance the IsScalar() and IsMatrix() functions of varManager snippet (updated to fix an issue in IsArray(#)).

EDIT: If you are writing a plugin you can use something like the getNumOfElements function in StatisticalTools or NonlinearSolvers plugins


best regards,

w3b5urf3r

Edited by user 08 January 2013 22:10:46(UTC)  | Reason: Not specified

Davide Carpi attached the following image(s):
StatisticalTools - SharpDevelop.png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline sublim21  
#3 Posted : 08 January 2013 23:28:02(UTC)
sublim21


Rank: Advanced Member

Groups: Registered
Joined: 18/05/2011(UTC)
Posts: 36

Was thanked: 3 time(s) in 3 post(s)
Originally Posted by: w3b5urf3r_reloaded Go to Quoted Post
Originally Posted by: sublim21 Go to Quoted Post
Hey all,

I've been trying to build a program that will return the type a variable is.

Basically, the function is an expansion of the IsString function, such that there is,

IsMatrix
IsNumber
IsSystem

etc..

I've attempted to accomplish this with num2str declarations and then seeing if there exists a string of "mat(" in the beginning. However, due to the problems of num2str 'ing matrices, this method fails. As does any other method i've tried.

I feel the best way to accomplish the variable type would be by building a plugin, however, my plugin building skills aren't up to the task. :/

-Pete


You can try to use/enhance the IsScalar() and IsMatrix() functions of varManager snippet (updated to fix an issue in IsArray(#)).

EDIT: If you are writing a plugin you can use something like the getNumOfElements function in StatisticalTools or NonlinearSolvers plugins


best regards,

w3b5urf3r


File Attachment(s):
whatIsFunction.sm (10kb) downloaded 17 time(s).
Offline Infinity  
#4 Posted : 09 January 2013 00:03:01(UTC)
Infinity


Rank: Member

Groups: Registered
Joined: 19/01/2012(UTC)
Posts: 12
Man

Was thanked: 3 time(s) in 2 post(s)
Hi,

I started a new PlugIn Project called FunctionBox for SMath.
To bring it to life, I added the three requested functions
- IsMatrix
- IsSystem
- IsNumber

I did a lot of SMath plugin programming in the past and will contribute to the SMath project by providing some helpful plugins.
In the near future I will create a Wiki page for the FunctionBox where I describe the already available functions.
Also a post in this forum related to the plugin would be good to discuss new features.

So, find attached the FunctionBox.dll plugin and feel free to test it and provide feedback.

Have fun,
Infinity
File Attachment(s):
FunctionBox.dll.zip (200kb) downloaded 19 time(s).
Infinity attached the following image(s):
Showcase.jpg
thanks 2 users thanked Infinity for this useful post.
on 09/01/2013(UTC),  on 09/01/2013(UTC)
Offline Davide Carpi  
#5 Posted : 09 January 2013 00:37:34(UTC)
Davide Carpi


Rank: Advanced Member

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

Was thanked: 1340 time(s) in 879 post(s)
Hi Infinity Good

I'm very glad that you came back with a new plugin Clap

Just as a feedback the IsNumber fails evaluating infinity and imaginary unit and there are some issues with single elements arrays/systems Good


best regards,

w3b5urf3r

Edited by user 09 January 2013 00:43:12(UTC)  | Reason: Not specified

File Attachment(s):
Fbox_debug.sm (15kb) downloaded 15 time(s).
Davide Carpi attached the following image(s):
SMath Studio - [Fbox_debug.sm].png
SMath Studio - [Fbox_debug.sm]_2.png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline omorr  
#6 Posted : 09 January 2013 02:50:22(UTC)
omorr


Rank: Administration

Groups: Registered, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
Originally Posted by: Infinity Go to Quoted Post

I did a lot of SMath plugin programming in the past and will contribute to the SMath project by providing some helpful plugins.
In the near future I will create a Wiki page for the FunctionBox where I describe the already available functions.
Also a post in this forum related to the plugin would be good to discuss new features.


Thank you Infinity for your efforts Good

As far as I could see, user made plugins started to grow in numbers Good . There are not to many of them yet, but I've already feel that I start losing the track of them mainly because they are scattered here on the Forum - most of them are in "Samples" forum and mixed with some other examples of using SMath . w3b5urf3r is trying to make a list of plugins and links to them on Wiki page PLUGINS. Essentially, we just need DLL's with accompanied help files in order to use these plugins and, therefore, I suppose that a new dedicated Forum "User plugins" might be more appropriate for this.

Any comments about it?

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
thanks 1 user thanked omorr for this useful post.
on 09/01/2013(UTC)
Offline Davide Carpi  
#7 Posted : 09 January 2013 15:49:59(UTC)
Davide Carpi


Rank: Advanced Member

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

Was thanked: 1340 time(s) in 879 post(s)
Originally Posted by: omorr Go to Quoted Post
Thank you Infinity for your efforts Good

As far as I could see, user made plugins started to grow in numbers Good . There are not to many of them yet, but I've already feel that I start losing the track of them mainly because they are scattered here on the Forum - most of them are in "Samples" forum and mixed with some other examples of using SMath . w3b5urf3r is trying to make a list of plugins and links to them on Wiki page PLUGINS. Essentially, we just need DLL's with accompanied help files in order to use these plugins and, therefore, I suppose that a new dedicated Forum "User plugins" might be more appropriate for this.

Any comments about it?

Regards,
Radovan


I agree with you, I think that a dedicated forum/sub-forum is desirable Good
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline sublim21  
#8 Posted : 09 January 2013 21:24:14(UTC)
sublim21


Rank: Advanced Member

Groups: Registered
Joined: 18/05/2011(UTC)
Posts: 36

Was thanked: 3 time(s) in 3 post(s)
Updated the whatIs function to handle infinity and others. Checked to make sure correct output will be given regardless of optimization option. Corrected sheet is attached.

I also second the idea of creating a plugin forum.

Also, if we're going to create a database of plugins, and snippets, then i suggest we use couchdb as the database software to hold the code.
File Attachment(s):
whatIsFunction.sm (19kb) downloaded 19 time(s).
Offline Davide Carpi  
#9 Posted : 09 January 2013 22:07:47(UTC)
Davide Carpi


Rank: Advanced Member

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

Was thanked: 1340 time(s) in 879 post(s)
Originally Posted by: sublim21 Go to Quoted Post
Updated the whatIs function to handle infinity and others. Checked to make sure correct output will be given regardless of optimization option. Corrected sheet is attached.

I also second the idea of creating a plugin forum.

Also, if we're going to create a database of plugins, and snippets, then i suggest we use couchdb as the database software to hold the code.


Good, also a snippet sub-forum it's not a bad idea!

There still remain some other issues in your snippet (see the snapshot) Good


regards,

w3b5urf3r
Davide Carpi attached the following image(s):
SMath Studio - [whatIsFunction.sm].png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline sublim21  
#10 Posted : 10 January 2013 18:42:42(UTC)
sublim21


Rank: Advanced Member

Groups: Registered
Joined: 18/05/2011(UTC)
Posts: 36

Was thanked: 3 time(s) in 3 post(s)
Hey websurfer,

You're correct about the error. I've fixed the sheet and have attached it below.

It'll work for everything i've tested it for, except strings with leading spaces " a".

Personally i don't like how the sheet is laid out. Duck typing the solution is a bad idea. As is the weird nested function solution, but i can't do a better solution until the num2str with spaces and other characters is fixed.

for now, it is highly recommended that you stick to A-z, 0-9, and _ until the bugs can be worked out.

Speaking of which, in your sheets websurfer, i noticed you use #var inside functions, whats the reason for that?

-Pete
File Attachment(s):
whatIsFunction.sm (21kb) downloaded 22 time(s).
Offline Davide Carpi  
#11 Posted : 10 January 2013 20:01:17(UTC)
Davide Carpi


Rank: Advanced Member

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

Was thanked: 1340 time(s) in 879 post(s)
Originally Posted by: sublim21 Go to Quoted Post
Hey websurfer,

You're correct about the error. I've fixed the sheet and have attached it below.

It'll work for everything i've tested it for, except strings with leading spaces " a".

Personally i don't like how the sheet is laid out. Duck typing the solution is a bad idea. As is the weird nested function solution, but i can't do a better solution until the num2str with spaces and other characters is fixed.

for now, it is highly recommended that you stick to A-z, 0-9, and _ until the bugs can be worked out.

Speaking of which, in your sheets websurfer, i noticed you use #var inside functions, whats the reason for that?

-Pete


Good ^__^

I think that a better and strong variable type identification will be implemented (soon or later) in the SMath executables, but at least for now our snippets and plugins could be a good help for users.

Sometimes I use #var or _var to distinguish between local and global variables. It's not really required but sometimes could be useful (especially for large scripts debugging).


regards,

w3b5urf3r

P.S. here there's a new wiki page with a list of compiled PLUGINS.
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline sublim21  
#12 Posted : 11 January 2013 18:00:51(UTC)
sublim21


Rank: Advanced Member

Groups: Registered
Joined: 18/05/2011(UTC)
Posts: 36

Was thanked: 3 time(s) in 3 post(s)
That's a good programming practice websurfer.

Thanks for the plugin link as well.

-Pete
Offline stevec  
#13 Posted : 06 February 2013 23:59:38(UTC)
stevec

Rank: Newbie

Groups: Registered
Joined: 06/02/2013(UTC)
Posts: 5
United Kingdom
Location: at home

Was thanked: 1 time(s) in 1 post(s)
A plug-in repository would get my vote!
if you decide to go down this route, might I suggest a plug-in manager plug-in such as is common in a lot of software. I would also suggest a rating system for plug-ins to indicate the maturity of a plug-in.
Offline Davide Carpi  
#14 Posted : 07 February 2013 02:27:54(UTC)
Davide Carpi


Rank: Advanced Member

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

Was thanked: 1340 time(s) in 879 post(s)
Originally Posted by: stevec Go to Quoted Post
A plug-in repository would get my vote!
if you decide to go down this route, might I suggest a plug-in manager plug-in such as is common in a lot of software. I would also suggest a rating system for plug-ins to indicate the maturity of a plug-in.


You can browse the repository clicking on the "Code" button on the top of the page.

Using Tortoise SVN or other SVN tools you can see more details about each plugin.


regards,

w3b5urf3r
Davide Carpi attached the following image(s):
Variable Type Plugin - Feature Requests - SMath Studio Forum - Mozilla Firefox.png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
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.