10-12-2007 08:49 AM - edited 10-12-2007 08:49 AM
NB: The goal is not so much to replace the IEEE math... but to prevent that we need to write all workarounds for every day calculation. I'm sure that NI could make a faster 'round to # significant digits' than my version... We have tons of higher level VI's for all kinds of complicated operations... it seems silly that we don't have VI's to handle these basic problems.
Message Edited by Anthony de Vries on 10-12-2007 03:55 PM
10-12-2007 09:52 AM
10-12-2007 10:40 AM
10-12-2007 10:50 AM
Let me assure you, I don't intend to create another Mega thread!
But I would like to get extended or additional math operators in Labview. I now have my own replacement VI's that do the job, but it seems silly that those aren't built into Labview. I have used my own floating point QR quite a lot actually.
As for the floating point equality.... That thing gives totally unpredictable results with most fractional numbers. Then you can certainly question why you allow users to do so? You might just as well wire to a random vi...
Ofcourse, when the user is going to make his own equality operator that takes care of the rounding errors, he might need a float equality primitive. But then, it makes more sense to allready include such a extended equality primitive in Labview in the first place...
I find it odd that we did get fixed-point variables and operators, but not this little extra bit of functionality in the floating points operators.
10-12-2007 10:58 AM - edited 10-12-2007 10:58 AM
Well Wiebe... Try putting 0.2 into an integer.
As far as I am concerned... when QR accepts floating points, then it also should give meaningfull answers. Makes no sense to make a polymorphic floating-point version, that gives unexpected results.
Here's the vi's in PNG:
Round to # significant numbers:
Comparison of different QR routines.
I used the SGL version mostly, as that was sufficient for my purposes. But for a more general routine, I think the rounding to # significant numbers is better.
If you'd change the default behaviour of the floor routine, then the Labview QR routine would probably be fixed automatically... But that's something for NI to decide.
I wouldn't be surprised if the "In Range and Coerce" operation suffers from the same issue.
Message Edited by Anthony de Vries on 10-12-2007 06:04 PM
10-12-2007 11:49 AM
10-12-2007 12:24 PM
10-12-2007 01:04 PM
The equality operator is already bi-modal in some contexts. When fed two clusters, one can right-click to decide whether to do an aggregate comparison with a boolean output or an element comparison with a cluster-of-booleans output. So there *is* some precedent for handling equality comparisons in special ways...
Still, I think that if I were NI, I wouldn't want to touch this one before some considerable degree of consensus emerged on expected behaviors and implementation. There are quite a few comparison operators. Even a pure "greater than", which hasn't been discussed yet, might need to be considered. To wit, suppose you compare values that vary only by something like 1e-15. In some contexts, you might want to consider these equal and thus have a "greater than" comparison" return False.
So I think that due to the number of comparison functions, their implementation is more problematic. Do you make a whole new palette of comparison functions solely to handle floating-point inputs and allow rounding? Do you add an optional input to all the existing primitives to specify behavior with floating point inputs? Do you make them polymorphic with a visible menu to select the desired instance, like many of the DAQmx data acq functions? I would tend to include both "Search 1D Array" and "Threshold 1D Array" in this group as essentially comparison-based functions. "In Range & Coerce" has already been mentioned. There are probably others too.
Apart from the comparison functions, "Q-R" was also mentioned as a numeric function to consider for alternate behavior. What others should be considered? I think the numeric "Sign" function is a potential candidate but of somewhat lesser priority than Q-R. What others? (Personally, I considered mentioning primitives like "Sqrt", "1/x", and "Divide", but decided that they were too much of a stretch).
I agree with smercurio's replies. Existing operators & functions need to retain current behavior by default, but there may be value in providing optional alternatives for some of them. "Q-R" is surely one case and Anthony has provided some implementations to consider. I can certainly think of scenarios where I'd prefer to drop a function like his on my diagram than to use the native Q-R. I've been using an analogous home-grown "approximately equal" vi for years because it sometimes suits my needs better than official IEEE floating-point equality. In the end, *usefulness* is reason enough for a specialty vi.
Overall, this seems like the kind of thing that might gain traction as a set of OpenG tools. Oh, look! There's already a similar discussion going on...
-Kevin P.
10-12-2007 03:48 PM
You're right Kevin, this would also affect the greater than function. Basicly, it affects all comparison operators, and operations that rely on it.
But I think that in the end, the total number of actual changes would small... I don't know how exactly things like floor are implemented, but I wouldn't be surprised that when you have an alternative equal, greater than and smaller than, that all other comparison operations automatically follow. Certainly, to make the alternate QR, you only need to use the alternate floor. The function itself doesn't change. Same for the sign function.
Just to be clear... this doesn't affect things like 1/x, sqrt or divide. You absolutely shouldn't do any rounding there.
Interesting to read the OpenG discussion.
10-12-2007 05:05 PM