Merge pull request #693 from cleeus/fix-exp2-precision-with-cxx11
Fix exp2 precision with cxx11 #693
This commit is contained in:
commit
0f956f6dbc
@ -90,6 +90,9 @@ namespace detail
|
|||||||
return detail::functor1<L, T, T, Q>::call(log, x);
|
return detail::functor1<L, T, T, Q>::call(log, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# if GLM_HAS_CXX11_STL
|
||||||
|
using std::exp2;
|
||||||
|
# else
|
||||||
//exp2, ln2 = 0.69314718055994530941723212145818f
|
//exp2, ln2 = 0.69314718055994530941723212145818f
|
||||||
template<typename genType>
|
template<typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType exp2(genType x)
|
GLM_FUNC_QUALIFIER genType exp2(genType x)
|
||||||
@ -98,6 +101,7 @@ namespace detail
|
|||||||
|
|
||||||
return std::exp(static_cast<genType>(0.69314718055994530941723212145818) * x);
|
return std::exp(static_cast<genType>(0.69314718055994530941723212145818) * x);
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
template<length_t L, typename T, qualifier Q>
|
template<length_t L, typename T, qualifier Q>
|
||||||
GLM_FUNC_QUALIFIER vec<L, T, Q> exp2(vec<L, T, Q> const& x)
|
GLM_FUNC_QUALIFIER vec<L, T, Q> exp2(vec<L, T, Q> const& x)
|
||||||
|
@ -113,6 +113,12 @@ static int test_exp2()
|
|||||||
glm::vec4 E = glm::exp2(glm::vec4(4.f, 3.f, 2.f, 1.f));
|
glm::vec4 E = glm::exp2(glm::vec4(4.f, 3.f, 2.f, 1.f));
|
||||||
Error += glm::all(glm::epsilonEqual(E, glm::vec4(16.f, 8.f, 4.f, 2.f), 0.01f)) ? 0 : 1;
|
Error += glm::all(glm::epsilonEqual(E, glm::vec4(16.f, 8.f, 4.f, 2.f), 0.01f)) ? 0 : 1;
|
||||||
|
|
||||||
|
# if GLM_HAS_CXX11_STL
|
||||||
|
//large exponent
|
||||||
|
float F = glm::exp2(23.f);
|
||||||
|
Error += glm::epsilonEqual(F, 8388608.f, 0.01f) ? 0 : 1;
|
||||||
|
# endif
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user