Microsoft.FSharp.Math functions should support units of measure
Is your feature request related to a problem? Please describe. Math functions require untagging UOMs
Describe the solution you'd like Math functions should respect UOMs
Describe alternatives you've considered I have to untag and retag UOM every time I use a Math function
Math functions should respect UOMs
The relevant ones seem to be Abs, Max, Min, Sign. (Edit: not pown)
Math functions should respect UOMs
The relevant ones seem to be Abs, Max, Min, Sign, and pown.
I'm not sure it makes sense for all of those to be applied to UOM. Say we have a velocity, x. Then Abs x is no longer a velocity (but rather a speed). Also, Sign x is not a velocity. Pown seems the most dubious of all: what is velocity^dollars, or even 3.14^velocity ? I don't see a problem with Max or Min, though.
Abs:'num<'m>->'num<'m>
Sign:'num<'m>->int
(On phone. Sorry if the type syntax isn't right.) pown won't work on second thoughts as the measure of the output depends on the number of the integer exponent and that is not statically known.
Abs:'num<'m>->'num<'m> Sign:'num<'m>->int(On phone. Sorry if the type syntax isn't right.) pown won't work on second thoughts as the measure of the output depends on the number of the integer exponent and that is not statically known.
In general, it only makes sense to use algebraic functions (versus transcendental functions) on UOM: see https://en.wikipedia.org/wiki/Transcendental_function#Dimensional_analysis .
Since Abs = sqrt(x^2), I guess that one does make sense.
That's not right. Functions which are homogenous in each variable are compatible with units. This excludes algebraic functions like x^2+x.
abs is not quite homogenous but is homogenous when restricted to multiplication by positive quantities. So if units are considered positive (which is acceptable), then abs can work.
That's not right. Functions which are homogenous in each variable are compatible with units. This includes non-algebraic functions like abs, and excludes algebraic functions like x^2+x.
Being homogeneous is a necessary condition, so is being algebraic. Abs x = sqrt(x^2) is an example of a homogeneous algebraic function.
Please see above post as I was editing my (wrong) answer when you replied.
I'm not sure why you want to assume units are positive. With that assumption there would be no reason to apply Abs in the first place?
Min/Max/Abs functions do support units of measure ;; those are also the functions where it makes sense to keep the units. I will close the issue for now - please let us know if more support is needed via examples of expected consumption.