diff options
author | Erik Schnetter <schnetter@gmail.com> | 2013-07-02 22:35:41 -0400 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2013-07-02 22:35:41 -0400 |
commit | 2cfd4347353565804661483d66a60394af7c40f7 (patch) | |
tree | 20aa19d2541a52160919bfb1dc2b0336f3b8c57f | |
parent | e4fbcb8815d919662b9c100e7e2aed1ab5599add (diff) | |
download | vecmathlib-2cfd4347353565804661483d66a60394af7c40f7.zip vecmathlib-2cfd4347353565804661483d66a60394af7c40f7.tar.gz |
Improve performance of ilogb and frexp
-rw-r--r-- | vec_pseudo.h | 10 | ||||
-rw-r--r-- | vec_sse_double1.h | 5 |
2 files changed, 9 insertions, 6 deletions
diff --git a/vec_pseudo.h b/vec_pseudo.h index c3658c0..29f2ed0 100644 --- a/vec_pseudo.h +++ b/vec_pseudo.h @@ -752,8 +752,9 @@ namespace vecmathlib { for (int d=0; d<size; ++d) { int ir; real_t r = std::frexp(v[d], &ir); - if (ir == FP_ILOGB0) ir = std::numeric_limits<int_t>::min(); - else if (ir == FP_ILOGBNAN) ir = std::numeric_limits<int_t>::max(); + typedef std::numeric_limits<int_t> NL; + if (FP_ILOGB0 != NL::min() and ir == FP_ILOGB0) ir = NL::min(); + else if (FP_ILOGBNAN != NL::max() and ir == FP_ILOGBNAN) ir = NL::max(); res.v[d] = r; ires.v[d] = ir; } @@ -765,8 +766,9 @@ namespace vecmathlib { intvec_t res; for (int d=0; d<size; ++d) { int_t r = std::ilogb(v[d]); - if (r == FP_ILOGB0) r = std::numeric_limits<int_t>::min(); - else if (r == FP_ILOGBNAN) r = std::numeric_limits<int_t>::max(); + typedef std::numeric_limits<int_t> NL; + if (FP_ILOGB0 != NL::min() and r == FP_ILOGB0) r = NL::min(); + else if (FP_ILOGBNAN != NL::max() and r == FP_ILOGBNAN) r = NL::max(); res.v[d] = r; } return res; diff --git a/vec_sse_double1.h b/vec_sse_double1.h index e4680d9..a7455f0 100644 --- a/vec_sse_double1.h +++ b/vec_sse_double1.h @@ -426,8 +426,9 @@ namespace vecmathlib { intvec_t ilogb() const { int_t r = std::ilogb(v); - if (r == FP_ILOGB0) r = std::numeric_limits<int_t>::min(); - else if (r == FP_ILOGBNAN) r = std::numeric_limits<int_t>::max(); + typedef std::numeric_limits<int_t> NL; + if (FP_ILOGB0 == NL::min() and r == FP_ILOGB0) r = NL::min(); + else if (FP_ILOGBNAN == NL::max() and r == FP_ILOGBNAN) r = NL::max(); return r; } boolvec_t isfinite() const { return std::isfinite(v); } |