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 mkraska  
#1 Posted : 18 September 2016 18:33:30(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,988
Germany

Was thanked: 1126 time(s) in 723 post(s)
The function UnitsOf() just as Davide's UoM() returns the unit of measurement of a given argument.

The design decision has been made for both functions to return 1 if the argument expression has no explicit occurence of units, no matter if the remainder is numeric or undefined.

This means that any variable name is assumed to represent a dimensionless quantity. In paper and pencil physics, symbols always are declared to be of a certain dimension (belonging to a certain linear space), either by explicit statement or by naming conventions or by the relations defining them.

To represent this in SMath (which this post is not a vote for) you would need to be able to assign dimensions to unknowns. Then the function UnitsOf() would be expected to return the base unit of that particular dimension.

The use of UnitsOf() is usually to create unit-proof access to non-unit-aware functions, like numeric algorithms like the int(4) function.

Nobody would expect UnitsOf() to deliver a result unless the expression can be evaluated numerically, i.e. does not contain any names except units.
Thus it would be absolutely acceptable to return "unknown" or even an error message instead of 1.

My proposal is that UnitsOf() returns just itself, if the expression can't be split into a number and an expression of units (i.e. can't be evaluated numerically).

If it wants to be a bit smarter, it might do some symbolic processing like (with a undefined)

UnitsOf(a*'m) = UnitsOf(a)*'m

The question is: Is UnitsOf(something unknown)=1 what you expect in the context of a unit-aware environment?

Edited by moderator 19 September 2016 19:05:47(UTC)  | Reason: marked as fixed

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx

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

Offline mikekaganski  
#2 Posted : 18 September 2016 21:53:37(UTC)
mikekaganski


Rank: Advanced Member

Groups: Registered
Joined: 17/01/2013(UTC)
Posts: 296
Man
Russian Federation
Location: Khabarovsk, Russia

Was thanked: 151 time(s) in 107 post(s)
See also discussion in SS-2318
Best regards,
Mike Kaganski
Offline mkraska  
#3 Posted : 18 September 2016 23:34:04(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,988
Germany

Was thanked: 1126 time(s) in 723 post(s)
Originally Posted by: mikekaganski Go to Quoted Post
See also discussion in SS-2318


I think that the discussion was on how to evaluate function definitions and the function UnitsOf() was just used to illustrate the issue.
The "I can handle undefined input"-flag was introduced into the function interface to resolve that issue. It did only partly, as I demonstrate in SS-2409.

Here (and in SS-2409) I rise the issue of the behaviour of UnitsOf() outside function definition context, on the bare canvas. I am just not comfortable with UnitsOf() returning 1 when the unit in fact is unknown.


Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline Andrey Ivashov  
#4 Posted : 19 September 2016 01:17:26(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)
Good point. I'm agree. Fixed.

units_mega_bug_1.png

Regards.
thanks 4 users thanked Andrey Ivashov for this useful post.
on 19/09/2016(UTC),  on 19/09/2016(UTC),  on 19/09/2016(UTC),  on 19/09/2016(UTC)
Offline mikekaganski  
#5 Posted : 19 September 2016 08:38:44(UTC)
mikekaganski


Rank: Advanced Member

Groups: Registered
Joined: 17/01/2013(UTC)
Posts: 296
Man
Russian Federation
Location: Khabarovsk, Russia

Was thanked: 151 time(s) in 107 post(s)
Originally Posted by: mkraska Go to Quoted Post
I think that the discussion was on how to evaluate function definitions and the function UnitsOf() was just used to illustrate the issue.
The "I can handle undefined input"-flag was introduced into the function interface to resolve that issue. It did only partly, as I demonstrate in SS-2409.

Here (and in SS-2409) I rise the issue of the behaviour of UnitsOf() outside function definition context, on the bare canvas. I am just not comfortable with UnitsOf() returning 1 when the unit in fact is unknown.


Good I completely agree. And I'm glad that the issue is solved.
Just wanted to mention that just because of what you've wrote, I started my comment with words "See also": this was meant to add somewhat relevant bits of information (and thus create a complete view on the problem and its history landscape when someone reads the topic), not to mark your request as a duplicate of something.
Best regards,
Mike Kaganski
Offline Jean Giraud  
#6 Posted : 19 September 2016 16:39:14(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)
UoM does not support user "for loop" range.

Forum UoM.gif
Offline mkraska  
#7 Posted : 19 September 2016 18:07:01(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,988
Germany

Was thanked: 1126 time(s) in 723 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
UoM does not support user "for loop" range.

This is not an issue of UoM(). You try to augment a 4 element vector by a 3 element vector. Unless SMath introduces skyline matrices, this must fail because the array dimensions do not match, as the error message correctly says.
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
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.