diff options
author | Erik Schnetter <schnetter@gmail.com> | 2012-12-01 13:51:20 -0500 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2012-12-01 13:51:20 -0500 |
commit | cc75e470ce2a6975ff2092af614daf5e5a96702e (patch) | |
tree | a4750ae16affba0f2b49ccb9e82e61233c8a506b /mathfuncs_convert.h | |
parent | 1d94d7894b3802497833de2d465529118e1f70c5 (diff) | |
download | vecmathlib-cc75e470ce2a6975ff2092af614daf5e5a96702e.zip vecmathlib-cc75e470ce2a6975ff2092af614daf5e5a96702e.tar.gz |
Implement ceil floor fmod pow remainder round
Diffstat (limited to 'mathfuncs_convert.h')
-rw-r--r-- | mathfuncs_convert.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mathfuncs_convert.h b/mathfuncs_convert.h index 19f7025..852c94e 100644 --- a/mathfuncs_convert.h +++ b/mathfuncs_convert.h @@ -84,6 +84,31 @@ namespace vecmathlib { return ix; } + + + template<typename realvec_t> + realvec_t mathfuncs<realvec_t>::vml_round(realvec_t x) + { + realvec_t r = fabs(x); + real_t offset = RV(std::scalbn(R(1.0), FP::mantissa_bits)); + r += offset; +#warning "TODO: don't optimise this away!" + r -= offset; + return copysign(r, x); + } + + template<typename realvec_t> + realvec_t mathfuncs<realvec_t>::vml_ceil(realvec_t x) + { + return round(x + RV(0.5)); + } + + template<typename realvec_t> + realvec_t mathfuncs<realvec_t>::vml_floor(realvec_t x) + { + return round(x - RV(0.5)); + } + }; // namespace vecmathlib #endif // #ifndef MATHFUNCS_CONVERT_H |