diff options
-rw-r--r-- | mathfuncs_base.h | 4 | ||||
-rw-r--r-- | mathfuncs_fabs.h | 40 |
2 files changed, 36 insertions, 8 deletions
diff --git a/mathfuncs_base.h b/mathfuncs_base.h index e8f24a8..22df222 100644 --- a/mathfuncs_base.h +++ b/mathfuncs_base.h @@ -66,6 +66,10 @@ namespace vecmathlib { static realvec_t vml_fmax(realvec_t x, realvec_t y); static realvec_t vml_fmin(realvec_t x, realvec_t y); static intvec_t vml_ilogb(realvec_t x); + static boolvec_t vml_ieee_isfinite(realvec_t x); + static boolvec_t vml_ieee_isinf(realvec_t x); + static boolvec_t vml_ieee_isnan(realvec_t x); + static boolvec_t vml_ieee_isnormal(realvec_t x); static boolvec_t vml_isfinite(realvec_t x); static boolvec_t vml_isinf(realvec_t x); static boolvec_t vml_isnan(realvec_t x); diff --git a/mathfuncs_fabs.h b/mathfuncs_fabs.h index 170a827..4f7aa60 100644 --- a/mathfuncs_fabs.h +++ b/mathfuncs_fabs.h @@ -66,10 +66,38 @@ namespace vecmathlib { } template<typename realvec_t> + auto mathfuncs<realvec_t>::vml_ieee_isfinite(realvec_t x) -> boolvec_t + { + return (as_int(x) & IV(FP::exponent_mask)) != IV(FP::exponent_mask); + } + + template<typename realvec_t> + auto mathfuncs<realvec_t>::vml_ieee_isinf(realvec_t x) -> boolvec_t + { + return (as_int(x) & IV(~FP::signbit_mask)) == IV(FP::exponent_mask); + } + + template<typename realvec_t> + auto mathfuncs<realvec_t>::vml_ieee_isnan(realvec_t x) -> boolvec_t + { + return + (as_int(x) & IV(FP::exponent_mask)) == IV(FP::exponent_mask) && + (as_int(x) & IV(FP::mantissa_mask)) != IV(I(0)); + } + + template<typename realvec_t> + auto mathfuncs<realvec_t>::vml_ieee_isnormal(realvec_t x) -> boolvec_t + { + return + (as_int(x) & IV(FP::exponent_mask)) != IV(FP::exponent_mask) && + (as_int(x) & IV(FP::exponent_mask)) != IV(I(0)); + } + + template<typename realvec_t> auto mathfuncs<realvec_t>::vml_isfinite(realvec_t x) -> boolvec_t { #if defined VML_HAVE_INF || defined VML_HAVE_NAN - return (as_int(x) & IV(FP::exponent_mask)) != IV(FP::exponent_mask); + return vml_ieee_isfinite(x); #else return BV(true); #endif @@ -79,7 +107,7 @@ namespace vecmathlib { auto mathfuncs<realvec_t>::vml_isinf(realvec_t x) -> boolvec_t { #if defined VML_HAVE_INF - return (as_int(x) & IV(~FP::signbit_mask)) == IV(FP::exponent_mask); + return vml_ieee_isinf(x); #else return BV(false); #endif @@ -89,9 +117,7 @@ namespace vecmathlib { auto mathfuncs<realvec_t>::vml_isnan(realvec_t x) -> boolvec_t { #if defined VML_HAVE_NAN - return - (as_int(x) & IV(FP::exponent_mask)) == IV(FP::exponent_mask) && - (as_int(x) & IV(FP::mantissa_mask)) != IV(I(0)); + return vml_ieee_isnan(x); #else return BV(false); #endif @@ -101,9 +127,7 @@ namespace vecmathlib { auto mathfuncs<realvec_t>::vml_isnormal(realvec_t x) -> boolvec_t { #if defined VML_HAVE_DENORMALS || defined VML_HAVE_INF || defined VML_HAVE_NAN - return - (as_int(x) & IV(FP::exponent_mask)) != IV(FP::exponent_mask) && - (as_int(x) & IV(FP::exponent_mask)) != IV(I(0)); + return vml_ieee_isnormal(x); #else return BV(true); #endif |