08-15-2022 11:01 AM
I don't understand why min=max would work because only two elements are being compared. All elements need to be the same to be considered true so each has to be compared somehow regardless. Extracting one such as the first element and using it to compare to the others is my suggestion.
08-15-2022 11:07 AM - edited 08-15-2022 11:32 AM
If you have a huge array and find the largest and smallest value AND if these two are the same, we can deduce that ALL values are the same. Right? No other element can be larger than the max or smaller that the min.
(You might run into trouble if the array is DBL and might even contain e.g. NaN, but equal comparison should never be done on DBL anyway. Too dangerous. No such issues with strings, integers, for example. On a side note, it is completely unclear why "array min&max" does not accept booleans! Please vote for this idea!!!! Thank.)
08-15-2022 01:18 PM
@altenbach wrote:
If you have a huge array and find the largest and smallest value AND if these two are the same, we can deduce that ALL values are the same. Right?
Not always. Array Max & Min ignores NaNs.
08-16-2022 01:31 AM
@paul_cardinale wrote:
@altenbach wrote:
If you have a huge array and find the largest and smallest value AND if these two are the same, we can deduce that ALL values are the same. Right?
Not always. Array Max & Min ignores NaNs.
(Yes, that's what I wrote in italic above)
One way around it would be to add each group of 15 to a new set. If the set has size=1 at the end, all elements are the same. Works even if all 15 elements are NaN. 😄 (Not sure how useful that would be, but still.... )
None of this code should be used for Floating point numerics anyway, even if there are no NaNs.
08-16-2022 10:22 AM
@altenbach wrote:
@paul_cardinale wrote:
@altenbach wrote:
If you have a huge array and find the largest and smallest value AND if these two are the same, we can deduce that ALL values are the same. Right?
Not always. Array Max & Min ignores NaNs.
(Yes, that's what I wrote in italic above)
One way around it would be to add each group of 15 to a new set. If the set has size=1 at the end, all elements are the same. Works even if all 15 elements are NaN. 😄 (Not sure how useful that would be, but still.... )
None of this code should be used for Floating point numerics anyway, even if there are no NaNs.
Sometimes it might be handy to have fuzzy comparisons. Of course the tricky part would be defining the fuzz.