Open jannschu opened 4 years ago
For what it is worth, here is what I am using for is_nan
to avoid adding this bound:
#[inline]
fn is_nan<R: RealField>(x: R) -> bool {
let zero = R::zero();
if x < zero {
false
} else {
if x >= zero {
false
} else {
true
}
}
}
same but more succinct
#[inline]
fn is_nan<R: RealField>(x: R) -> bool {
x.partial_cmp(&R::zero()).is_none()
}
Thanks @lelongg . Also clippy does not complain about your version.
There are a couple of occasions where I regularly have to add an additional
num_traits::Float
bound.Methods I need from
num_traits::Float
include the following:min_positive_value
is_nan
nan
infinity
andneg_infinity
max
andmin
with theNaN
semanticscopysign
Is the
RealField
suitable for these methods or is it intended to be more abstract, i.e., it not necessarily represents these floating point semantics?