summaryrefslogtreecommitdiffstats
path: root/mathfuncs_convert.h
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-02-16 23:37:38 -0500
committerErik Schnetter <schnetter@gmail.com>2013-02-16 23:37:38 -0500
commit68fc04ed1826328d357a7c6402b10ae89aa8f059 (patch)
treefe290c5ba3cb6744b403bda6a82c6b8fd0ed7628 /mathfuncs_convert.h
parent3dd2cd307b3795e7061fa1ff715903764b35df61 (diff)
downloadvecmathlib-68fc04ed1826328d357a7c6402b10ae89aa8f059.zip
vecmathlib-68fc04ed1826328d357a7c6402b10ae89aa8f059.tar.gz
Add cbrt, hypot, trunc; rename scalbn to ldexp
Diffstat (limited to 'mathfuncs_convert.h')
-rw-r--r--mathfuncs_convert.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/mathfuncs_convert.h b/mathfuncs_convert.h
index 44a3aee..190388f 100644
--- a/mathfuncs_convert.h
+++ b/mathfuncs_convert.h
@@ -100,7 +100,7 @@ namespace vecmathlib {
{
realvec_t r = x;
// Round by adding a large number, destroying all excess precision
- realvec_t offset = copysign(RV(std::scalbn(R(1.0), FP::mantissa_bits)), x);
+ realvec_t offset = copysign(RV(std::ldexp(R(1.0), FP::mantissa_bits)), x);
r += offset;
// Ensure the rounding is not optimised away
r.barrier();
@@ -112,7 +112,7 @@ namespace vecmathlib {
realvec_t mathfuncs<realvec_t>::vml_ceil(realvec_t x)
{
boolvec_t iszero = x == RV(0.0);
- realvec_t offset = RV(0.5) - scalbn(fabs(x), I(-FP::mantissa_bits));
+ realvec_t offset = RV(0.5) - ldexp(fabs(x), I(-FP::mantissa_bits));
return ifthen(iszero, x, round(x + offset));
}
@@ -120,10 +120,16 @@ namespace vecmathlib {
realvec_t mathfuncs<realvec_t>::vml_floor(realvec_t x)
{
boolvec_t iszero = x == RV(0.0);
- realvec_t offset = RV(0.5) - scalbn(fabs(x), I(-FP::mantissa_bits));
+ realvec_t offset = RV(0.5) - ldexp(fabs(x), I(-FP::mantissa_bits));
return ifthen(iszero, x, round(x - offset));
}
+ template<typename realvec_t>
+ realvec_t mathfuncs<realvec_t>::vml_trunc(realvec_t x)
+ {
+ return copysign(floor(fabs(x)), x);
+ }
+
}; // namespace vecmathlib
#endif // #ifndef MATHFUNCS_CONVERT_H
OpenPOWER on IntegriCloud