From 2877f4eda3d1b0c7431039e3142ecf1a282a34b1 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Tue, 21 Aug 2018 20:40:38 +0500 Subject: Update glm to 0.9.9.0 --- external/include/glm/gtc/ulp.inl | 136 ++++++++++++++++++++++----------------- 1 file changed, 77 insertions(+), 59 deletions(-) (limited to 'external/include/glm/gtc/ulp.inl') diff --git a/external/include/glm/gtc/ulp.inl b/external/include/glm/gtc/ulp.inl index 54c914a..620be36 100644 --- a/external/include/glm/gtc/ulp.inl +++ b/external/include/glm/gtc/ulp.inl @@ -9,6 +9,7 @@ /// is preserved. #include "../detail/type_int.hpp" +#include "epsilon.hpp" #include #include #include @@ -78,33 +79,42 @@ namespace detail ix = hx&0x7fffffff; // |x| iy = hy&0x7fffffff; // |y| - if((ix>0x7f800000) || // x is nan - (iy>0x7f800000)) // y is nan + if((ix>0x7f800000) || // x is nan + (iy>0x7f800000)) // y is nan return x+y; - if(x==y) return y; // x=y, return y - if(ix==0) { // x == 0 + if(compute_equal::call(x, y)) + return y; // x=y, return y + if(ix==0) + { // x == 0 GLM_SET_FLOAT_WORD(x,(hy&0x80000000)|1);// return +-minsubnormal t = x*x; - if(t==x) return t; else return x; // raise underflow flag + if(detail::compute_equal::call(t, x)) + return t; + else + return x; // raise underflow flag } - if(hx>=0) { // x > 0 - if(hx>hy) { // x > y, x -= ulp + if(hx>=0) + { // x > 0 + if(hx>hy) // x > y, x -= ulp hx -= 1; - } else { // x < y, x += ulp + else // x < y, x += ulp hx += 1; - } - } else { // x < 0 - if(hy>=0||hx>hy){ // x < y, x -= ulp + } + else + { // x < 0 + if(hy>=0||hx>hy) // x < y, x -= ulp hx -= 1; - } else { // x > y, x += ulp + else // x > y, x += ulp hx += 1; - } } hy = hx&0x7f800000; - if(hy>=0x7f800000) return x+x; // overflow - if(hy<0x00800000) { // underflow + if(hy>=0x7f800000) + return x+x; // overflow + if(hy<0x00800000) // underflow + { t = x*x; - if(t!=x) { // raise underflow flag + if(!detail::compute_equal::call(t, x)) + { // raise underflow flag GLM_SET_FLOAT_WORD(y,hx); return y; } @@ -121,27 +131,32 @@ namespace detail GLM_EXTRACT_WORDS(hx, lx, x); GLM_EXTRACT_WORDS(hy, ly, y); - ix = hx & 0x7fffffff; // |x| - iy = hy & 0x7fffffff; // |y| + ix = hx & 0x7fffffff; // |x| + iy = hy & 0x7fffffff; // |y| - if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || // x is nan - ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) // y is nan + if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || // x is nan + ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) // y is nan return x+y; - if(x==y) return y; // x=y, return y - if((ix|lx)==0) { // x == 0 - GLM_INSERT_WORDS(x, hy & 0x80000000, 1); // return +-minsubnormal + if(detail::compute_equal::call(x, y)) + return y; // x=y, return y + if((ix|lx)==0) + { // x == 0 + GLM_INSERT_WORDS(x, hy & 0x80000000, 1); // return +-minsubnormal t = x*x; - if(t==x) return t; else return x; // raise underflow flag + if(detail::compute_equal::call(t, x)) + return t; + else + return x; // raise underflow flag } - if(hx>=0) { // x > 0 - if(hx>hy||((hx==hy)&&(lx>ly))) { // x > y, x -= ulp + if(hx>=0) { // x > 0 + if(hx>hy||((hx==hy)&&(lx>ly))) { // x > y, x -= ulp if(lx==0) hx -= 1; lx -= 1; } else { // x < y, x += ulp lx += 1; if(lx==0) hx += 1; } - } else { // x < 0 + } else { // x < 0 if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){// x < y, x -= ulp if(lx==0) hx -= 1; lx -= 1; @@ -151,10 +166,13 @@ namespace detail } } hy = hx&0x7ff00000; - if(hy>=0x7ff00000) return x+x; // overflow - if(hy<0x00100000) { // underflow + if(hy>=0x7ff00000) + return x+x; // overflow + if(hy<0x00100000) + { // underflow t = x*x; - if(t!=x) { // raise underflow flag + if(!detail::compute_equal::call(t, x)) + { // raise underflow flag GLM_INSERT_WORDS(y,hx,lx); return y; } @@ -171,8 +189,8 @@ namespace detail namespace glm { - template <> - GLM_FUNC_QUALIFIER float next_float(float const & x) + template<> + GLM_FUNC_QUALIFIER float next_float(float const& x) { # if GLM_HAS_CXX11_STL return std::nextafter(x, std::numeric_limits::max()); @@ -185,8 +203,8 @@ namespace glm # endif } - template <> - GLM_FUNC_QUALIFIER double next_float(double const & x) + template<> + GLM_FUNC_QUALIFIER double next_float(double const& x) { # if GLM_HAS_CXX11_STL return std::nextafter(x, std::numeric_limits::max()); @@ -199,16 +217,16 @@ namespace glm # endif } - template class vecType> - GLM_FUNC_QUALIFIER vecType next_float(vecType const & x) + template + GLM_FUNC_QUALIFIER vec next_float(vec const& x) { - vecType Result(uninitialize); + vec Result; for(length_t i = 0, n = Result.length(); i < n; ++i) Result[i] = next_float(x[i]); return Result; } - GLM_FUNC_QUALIFIER float prev_float(float const & x) + GLM_FUNC_QUALIFIER float prev_float(float const& x) { # if GLM_HAS_CXX11_STL return std::nextafter(x, std::numeric_limits::min()); @@ -221,7 +239,7 @@ namespace glm # endif } - GLM_FUNC_QUALIFIER double prev_float(double const & x) + GLM_FUNC_QUALIFIER double prev_float(double const& x) { # if GLM_HAS_CXX11_STL return std::nextafter(x, std::numeric_limits::min()); @@ -234,17 +252,17 @@ namespace glm # endif } - template class vecType> - GLM_FUNC_QUALIFIER vecType prev_float(vecType const & x) + template + GLM_FUNC_QUALIFIER vec prev_float(vec const& x) { - vecType Result(uninitialize); + vec Result; for(length_t i = 0, n = Result.length(); i < n; ++i) Result[i] = prev_float(x[i]); return Result; } - template - GLM_FUNC_QUALIFIER T next_float(T const & x, uint const & ulps) + template + GLM_FUNC_QUALIFIER T next_float(T const& x, uint const& ulps) { T temp = x; for(uint i = 0; i < ulps; ++i) @@ -252,17 +270,17 @@ namespace glm return temp; } - template class vecType> - GLM_FUNC_QUALIFIER vecType next_float(vecType const & x, vecType const & ulps) + template + GLM_FUNC_QUALIFIER vec next_float(vec const& x, vec const& ulps) { - vecType Result(uninitialize); + vec Result; for(length_t i = 0, n = Result.length(); i < n; ++i) Result[i] = next_float(x[i], ulps[i]); return Result; } - template - GLM_FUNC_QUALIFIER T prev_float(T const & x, uint const & ulps) + template + GLM_FUNC_QUALIFIER T prev_float(T const& x, uint const& ulps) { T temp = x; for(uint i = 0; i < ulps; ++i) @@ -270,24 +288,24 @@ namespace glm return temp; } - template class vecType> - GLM_FUNC_QUALIFIER vecType prev_float(vecType const & x, vecType const & ulps) + template + GLM_FUNC_QUALIFIER vec prev_float(vec const& x, vec const& ulps) { - vecType Result(uninitialize); + vec Result; for(length_t i = 0, n = Result.length(); i < n; ++i) Result[i] = prev_float(x[i], ulps[i]); return Result; } - template - GLM_FUNC_QUALIFIER uint float_distance(T const & x, T const & y) + template + GLM_FUNC_QUALIFIER uint float_distance(T const& x, T const& y) { uint ulp = 0; if(x < y) { T temp = x; - while(temp != y)// && ulp < std::numeric_limits::max()) + while(glm::epsilonNotEqual(temp, y, glm::epsilon()))// && ulp < std::numeric_limits::max()) { ++ulp; temp = next_float(temp); @@ -296,7 +314,7 @@ namespace glm else if(y < x) { T temp = y; - while(temp != x)// && ulp < std::numeric_limits::max()) + while(glm::epsilonNotEqual(temp, x, glm::epsilon()))// && ulp < std::numeric_limits::max()) { ++ulp; temp = next_float(temp); @@ -310,10 +328,10 @@ namespace glm return ulp; } - template class vecType> - GLM_FUNC_QUALIFIER vecType float_distance(vecType const & x, vecType const & y) + template + GLM_FUNC_QUALIFIER vec float_distance(vec const& x, vec const& y) { - vecType Result(uninitialize); + vec Result; for(length_t i = 0, n = Result.length(); i < n; ++i) Result[i] = float_distance(x[i], y[i]); return Result; -- cgit v1.2.3