mirror of
https://github.com/g-truc/glm.git
synced 2024-11-25 18:04:34 +00:00
Completed EXT_*_integer extensions
This commit is contained in:
parent
3288df2f89
commit
3a65b7a628
@ -15,6 +15,7 @@
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/qualifier.hpp"
|
||||
#include "../detail/_vectorize.hpp"
|
||||
#include "../detail/type_float.hpp"
|
||||
#include "../vector_relational.hpp"
|
||||
#include "../common.hpp"
|
||||
#include <limits>
|
||||
|
@ -159,6 +159,8 @@ namespace detail
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_QUALIFIER bool isPowerOfTwo(genIUType Value)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'isPowerOfTwo' only accept integer inputs");
|
||||
|
||||
genIUType const Result = glm::abs(Value);
|
||||
return !(Result & (Result - 1));
|
||||
}
|
||||
@ -166,30 +168,40 @@ namespace detail
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_QUALIFIER genIUType nextPowerOfTwo(genIUType value)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'nextPowerOfTwo' only accept integer inputs");
|
||||
|
||||
return detail::compute_ceilPowerOfTwo<1, genIUType, defaultp, std::numeric_limits<genIUType>::is_signed>::call(vec<1, genIUType, defaultp>(value)).x;
|
||||
}
|
||||
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_QUALIFIER genIUType prevPowerOfTwo(genIUType value)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'prevPowerOfTwo' only accept integer inputs");
|
||||
|
||||
return isPowerOfTwo(value) ? value : static_cast<genIUType>(1) << findMSB(value);
|
||||
}
|
||||
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_QUALIFIER bool isMultiple(genIUType Value, genIUType Multiple)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'isMultiple' only accept integer inputs");
|
||||
|
||||
return isMultiple(vec<1, genIUType>(Value), vec<1, genIUType>(Multiple)).x;
|
||||
}
|
||||
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_QUALIFIER genIUType nextMultiple(genIUType Source, genIUType Multiple)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'nextMultiple' only accept integer inputs");
|
||||
|
||||
return detail::compute_ceilMultiple<std::numeric_limits<genIUType>::is_iec559, std::numeric_limits<genIUType>::is_signed>::call(Source, Multiple);
|
||||
}
|
||||
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_QUALIFIER genIUType prevMultiple(genIUType Source, genIUType Multiple)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'prevMultiple' only accept integer inputs");
|
||||
|
||||
return detail::compute_floorMultiple<std::numeric_limits<genIUType>::is_iec559, std::numeric_limits<genIUType>::is_signed>::call(Source, Multiple);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -32,7 +32,7 @@ namespace glm
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType next_float(genType x);
|
||||
GLM_FUNC_DECL genType nextFloat(genType x);
|
||||
|
||||
/// Return the previous ULP value(s) before the input value(s).
|
||||
///
|
||||
@ -40,7 +40,7 @@ namespace glm
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType prev_float(genType x);
|
||||
GLM_FUNC_DECL genType prevFloat(genType x);
|
||||
|
||||
/// Return the value(s) ULP distance after the input value(s).
|
||||
///
|
||||
@ -48,7 +48,7 @@ namespace glm
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType next_float(genType x, int ULPs);
|
||||
GLM_FUNC_DECL genType nextFloat(genType x, int ULPs);
|
||||
|
||||
/// Return the value(s) ULP distance before the input value(s).
|
||||
///
|
||||
@ -56,17 +56,17 @@ namespace glm
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType prev_float(genType x, int ULPs);
|
||||
GLM_FUNC_DECL genType prevFloat(genType x, int ULPs);
|
||||
|
||||
/// Return the distance in the number of ULP between 2 single-precision floating-point scalars.
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
GLM_FUNC_DECL int float_distance(float x, float y);
|
||||
GLM_FUNC_DECL int floatDistance(float x, float y);
|
||||
|
||||
/// Return the distance in the number of ULP between 2 double-precision floating-point scalars.
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
GLM_FUNC_DECL int64 float_distance(double x, double y);
|
||||
GLM_FUNC_DECL int64 floatDistance(double x, double y);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
@ -189,7 +189,7 @@ namespace detail
|
||||
namespace glm
|
||||
{
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER float next_float(float x)
|
||||
GLM_FUNC_QUALIFIER float nextFloat(float x)
|
||||
{
|
||||
# if GLM_HAS_CXX11_STL
|
||||
return std::nextafter(x, std::numeric_limits<float>::max());
|
||||
@ -203,7 +203,7 @@ namespace glm
|
||||
}
|
||||
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER double next_float(double x)
|
||||
GLM_FUNC_QUALIFIER double nextFloat(double x)
|
||||
{
|
||||
# if GLM_HAS_CXX11_STL
|
||||
return std::nextafter(x, std::numeric_limits<double>::max());
|
||||
@ -217,18 +217,18 @@ namespace glm
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER T next_float(T x, int ULPs)
|
||||
GLM_FUNC_QUALIFIER T nextFloat(T x, int ULPs)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'next_float' only accept floating-point input");
|
||||
assert(ULPs >= 0);
|
||||
|
||||
T temp = x;
|
||||
for(int i = 0; i < ULPs; ++i)
|
||||
temp = next_float(temp);
|
||||
temp = nextFloat(temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float prev_float(float x)
|
||||
GLM_FUNC_QUALIFIER float prevFloat(float x)
|
||||
{
|
||||
# if GLM_HAS_CXX11_STL
|
||||
return std::nextafter(x, std::numeric_limits<float>::min());
|
||||
@ -241,7 +241,7 @@ namespace glm
|
||||
# endif
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER double prev_float(double x)
|
||||
GLM_FUNC_QUALIFIER double prevFloat(double x)
|
||||
{
|
||||
# if GLM_HAS_CXX11_STL
|
||||
return std::nextafter(x, std::numeric_limits<double>::min());
|
||||
@ -255,18 +255,18 @@ namespace glm
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER T prev_float(T x, int ULPs)
|
||||
GLM_FUNC_QUALIFIER T prevFloat(T x, int ULPs)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'prev_float' only accept floating-point input");
|
||||
assert(ULPs >= 0);
|
||||
|
||||
T temp = x;
|
||||
for(int i = 0; i < ULPs; ++i)
|
||||
temp = prev_float(temp);
|
||||
temp = prevFloat(temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int float_distance(float x, float y)
|
||||
GLM_FUNC_QUALIFIER int floatDistance(float x, float y)
|
||||
{
|
||||
detail::float_t<float> const a(x);
|
||||
detail::float_t<float> const b(y);
|
||||
@ -274,7 +274,7 @@ namespace glm
|
||||
return abs(a.i - b.i);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int64 float_distance(double x, double y)
|
||||
GLM_FUNC_QUALIFIER int64 floatDistance(double x, double y)
|
||||
{
|
||||
detail::float_t<double> const a(x);
|
||||
detail::float_t<double> const b(y);
|
||||
|
@ -5,6 +5,8 @@ namespace glm
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, bool, Q> isPowerOfTwo(vec<L, T, Q> const& Value)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'isPowerOfTwo' only accept integer inputs");
|
||||
|
||||
vec<L, T, Q> const Result(abs(Value));
|
||||
return equal(Result & (Result - vec<L, T, Q>(1)), vec<L, T, Q>(0));
|
||||
}
|
||||
@ -12,48 +14,64 @@ namespace glm
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> nextPowerOfTwo(vec<L, T, Q> const& v)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'nextPowerOfTwo' only accept integer inputs");
|
||||
|
||||
return detail::compute_ceilPowerOfTwo<L, T, Q, std::numeric_limits<T>::is_signed>::call(v);
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> prevPowerOfTwo(vec<L, T, Q> const& v)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'prevPowerOfTwo' only accept integer inputs");
|
||||
|
||||
return detail::functor1<vec, L, T, T, Q>::call(prevPowerOfTwo, v);
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, bool, Q> isMultiple(vec<L, T, Q> const& Value, T Multiple)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'isMultiple' only accept integer inputs");
|
||||
|
||||
return (Value % Multiple) == vec<L, T, Q>(0);
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, bool, Q> isMultiple(vec<L, T, Q> const& Value, vec<L, T, Q> const& Multiple)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'isMultiple' only accept integer inputs");
|
||||
|
||||
return (Value % Multiple) == vec<L, T, Q>(0);
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> nextMultiple(vec<L, T, Q> const& Source, T Multiple)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'nextMultiple' only accept integer inputs");
|
||||
|
||||
return detail::functor2<vec, L, T, Q>::call(nextMultiple, Source, vec<L, T, Q>(Multiple));
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> nextMultiple(vec<L, T, Q> const& Source, vec<L, T, Q> const& Multiple)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'nextMultiple' only accept integer inputs");
|
||||
|
||||
return detail::functor2<vec, L, T, Q>::call(nextMultiple, Source, Multiple);
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> prevMultiple(vec<L, T, Q> const& Source, T Multiple)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'prevMultiple' only accept integer inputs");
|
||||
|
||||
return detail::functor2<vec, L, T, Q>::call(prevMultiple, Source, vec<L, T, Q>(Multiple));
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> prevMultiple(vec<L, T, Q> const& Source, vec<L, T, Q> const& Multiple)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'prevMultiple' only accept integer inputs");
|
||||
|
||||
return detail::functor2<vec, L, T, Q>::call(prevMultiple, Source, Multiple);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -33,7 +33,7 @@ namespace glm
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> next_float(vec<L, T, Q> const& x);
|
||||
GLM_FUNC_DECL vec<L, T, Q> nextFloat(vec<L, T, Q> const& x);
|
||||
|
||||
/// Return the value(s) ULP distance after the input value(s).
|
||||
///
|
||||
@ -43,7 +43,7 @@ namespace glm
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> next_float(vec<L, T, Q> const& x, int ULPs);
|
||||
GLM_FUNC_DECL vec<L, T, Q> nextFloat(vec<L, T, Q> const& x, int ULPs);
|
||||
|
||||
/// Return the value(s) ULP distance after the input value(s).
|
||||
///
|
||||
@ -53,7 +53,7 @@ namespace glm
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> next_float(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs);
|
||||
GLM_FUNC_DECL vec<L, T, Q> nextFloat(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs);
|
||||
|
||||
/// Return the previous ULP value(s) before the input value(s).
|
||||
///
|
||||
@ -63,7 +63,7 @@ namespace glm
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> prev_float(vec<L, T, Q> const& x);
|
||||
GLM_FUNC_DECL vec<L, T, Q> prevFloat(vec<L, T, Q> const& x);
|
||||
|
||||
/// Return the value(s) ULP distance before the input value(s).
|
||||
///
|
||||
@ -73,7 +73,7 @@ namespace glm
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> prev_float(vec<L, T, Q> const& x, int ULPs);
|
||||
GLM_FUNC_DECL vec<L, T, Q> prevFloat(vec<L, T, Q> const& x, int ULPs);
|
||||
|
||||
/// Return the value(s) ULP distance before the input value(s).
|
||||
///
|
||||
@ -83,7 +83,7 @@ namespace glm
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> prev_float(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs);
|
||||
GLM_FUNC_DECL vec<L, T, Q> prevFloat(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs);
|
||||
|
||||
/// Return the distance in the number of ULP between 2 single-precision floating-point scalars.
|
||||
///
|
||||
@ -92,7 +92,7 @@ namespace glm
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, int, Q> float_distance(vec<L, float, Q> const& x, vec<L, float, Q> const& y);
|
||||
GLM_FUNC_DECL vec<L, int, Q> floatDistance(vec<L, float, Q> const& x, vec<L, float, Q> const& y);
|
||||
|
||||
/// Return the distance in the number of ULP between 2 double-precision floating-point scalars.
|
||||
///
|
||||
@ -101,7 +101,7 @@ namespace glm
|
||||
///
|
||||
/// @see ext_scalar_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, int64, Q> float_distance(vec<L, double, Q> const& x, vec<L, double, Q> const& y);
|
||||
GLM_FUNC_DECL vec<L, int64, Q> floatDistance(vec<L, double, Q> const& x, vec<L, double, Q> const& y);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
@ -1,74 +1,74 @@
|
||||
namespace glm
|
||||
{
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> next_float(vec<L, T, Q> const& x)
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> nextFloat(vec<L, T, Q> const& x)
|
||||
{
|
||||
vec<L, T, Q> Result;
|
||||
for(length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = next_float(x[i]);
|
||||
Result[i] = nextFloat(x[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> next_float(vec<L, T, Q> const& x, int ULPs)
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> nextFloat(vec<L, T, Q> const& x, int ULPs)
|
||||
{
|
||||
vec<L, T, Q> Result;
|
||||
for(length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = next_float(x[i], ULPs);
|
||||
Result[i] = nextFloat(x[i], ULPs);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> next_float(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs)
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> nextFloat(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs)
|
||||
{
|
||||
vec<L, T, Q> Result;
|
||||
for(length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = next_float(x[i], ULPs[i]);
|
||||
Result[i] = nextFloat(x[i], ULPs[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> prev_float(vec<L, T, Q> const& x)
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> prevFloat(vec<L, T, Q> const& x)
|
||||
{
|
||||
vec<L, T, Q> Result;
|
||||
for(length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = prev_float(x[i]);
|
||||
Result[i] = prevFloat(x[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> prev_float(vec<L, T, Q> const& x, int ULPs)
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> prevFloat(vec<L, T, Q> const& x, int ULPs)
|
||||
{
|
||||
vec<L, T, Q> Result;
|
||||
for(length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = prev_float(x[i], ULPs);
|
||||
Result[i] = prevFloat(x[i], ULPs);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> prev_float(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs)
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> prevFloat(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs)
|
||||
{
|
||||
vec<L, T, Q> Result;
|
||||
for(length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = prev_float(x[i], ULPs[i]);
|
||||
Result[i] = prevFloat(x[i], ULPs[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, int, Q> float_distance(vec<L, float, Q> const& x, vec<L, float, Q> const& y)
|
||||
GLM_FUNC_QUALIFIER vec<L, int, Q> floatDistance(vec<L, float, Q> const& x, vec<L, float, Q> const& y)
|
||||
{
|
||||
vec<L, int, Q> Result;
|
||||
for(length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = float_distance(x[i], y[i]);
|
||||
Result[i] = floatDistance(x[i], y[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, int64, Q> float_distance(vec<L, double, Q> const& x, vec<L, double, Q> const& y)
|
||||
GLM_FUNC_QUALIFIER vec<L, int64, Q> floatDistance(vec<L, double, Q> const& x, vec<L, double, Q> const& y)
|
||||
{
|
||||
vec<L, int64, Q> Result;
|
||||
for(length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = float_distance(x[i], y[i]);
|
||||
Result[i] = floatDistance(x[i], y[i]);
|
||||
return Result;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -30,7 +30,7 @@ namespace glm
|
||||
/// @addtogroup gtc_integer
|
||||
/// @{
|
||||
|
||||
/// Returns the log2 of x for integer values. Can be reliably using to compute mipmap count from the texture size.
|
||||
/// Returns the log2 of x for integer values. Usefull to compute mipmap count from the texture size.
|
||||
/// @see gtc_integer
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_DECL genIUType log2(genIUType x);
|
||||
|
@ -1,230 +1,10 @@
|
||||
/// @ref gtc_round
|
||||
|
||||
#include "../integer.hpp"
|
||||
#include "../ext/vector_integer.hpp"
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
namespace glm
|
||||
{
|
||||
template<length_t L, typename T, qualifier Q, bool compute = false>
|
||||
struct compute_ceilShift
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& v, T)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
struct compute_ceilShift<L, T, Q, true>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& v, T Shift)
|
||||
{
|
||||
return v | (v >> Shift);
|
||||
}
|
||||
};
|
||||
|
||||
template<length_t L, typename T, qualifier Q, bool isSigned = true>
|
||||
struct compute_ceilPowerOfTwo
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(!std::numeric_limits<T>::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs");
|
||||
|
||||
vec<L, T, Q> const Sign(sign(x));
|
||||
|
||||
vec<L, T, Q> v(abs(x));
|
||||
|
||||
v = v - static_cast<T>(1);
|
||||
v = v | (v >> static_cast<T>(1));
|
||||
v = v | (v >> static_cast<T>(2));
|
||||
v = v | (v >> static_cast<T>(4));
|
||||
v = compute_ceilShift<L, T, Q, sizeof(T) >= 2>::call(v, 8);
|
||||
v = compute_ceilShift<L, T, Q, sizeof(T) >= 4>::call(v, 16);
|
||||
v = compute_ceilShift<L, T, Q, sizeof(T) >= 8>::call(v, 32);
|
||||
return (v + static_cast<T>(1)) * Sign;
|
||||
}
|
||||
};
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
struct compute_ceilPowerOfTwo<L, T, Q, false>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(!std::numeric_limits<T>::is_iec559, "'ceilPowerOfTwo' only accept integer scalar or vector inputs");
|
||||
|
||||
vec<L, T, Q> v(x);
|
||||
|
||||
v = v - static_cast<T>(1);
|
||||
v = v | (v >> static_cast<T>(1));
|
||||
v = v | (v >> static_cast<T>(2));
|
||||
v = v | (v >> static_cast<T>(4));
|
||||
v = compute_ceilShift<L, T, Q, sizeof(T) >= 2>::call(v, 8);
|
||||
v = compute_ceilShift<L, T, Q, sizeof(T) >= 4>::call(v, 16);
|
||||
v = compute_ceilShift<L, T, Q, sizeof(T) >= 8>::call(v, 32);
|
||||
return v + static_cast<T>(1);
|
||||
}
|
||||
};
|
||||
|
||||
template<bool is_float, bool is_signed>
|
||||
struct compute_ceilMultiple{};
|
||||
|
||||
template<>
|
||||
struct compute_ceilMultiple<true, true>
|
||||
{
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source > genType(0))
|
||||
return Source + (Multiple - std::fmod(Source, Multiple));
|
||||
else
|
||||
return Source + std::fmod(-Source, Multiple);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct compute_ceilMultiple<false, false>
|
||||
{
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
genType Tmp = Source - genType(1);
|
||||
return Tmp + (Multiple - (Tmp % Multiple));
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct compute_ceilMultiple<false, true>
|
||||
{
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source > genType(0))
|
||||
{
|
||||
genType Tmp = Source - genType(1);
|
||||
return Tmp + (Multiple - (Tmp % Multiple));
|
||||
}
|
||||
else
|
||||
return Source + (-Source % Multiple);
|
||||
}
|
||||
};
|
||||
|
||||
template<bool is_float, bool is_signed>
|
||||
struct compute_floorMultiple{};
|
||||
|
||||
template<>
|
||||
struct compute_floorMultiple<true, true>
|
||||
{
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source >= genType(0))
|
||||
return Source - std::fmod(Source, Multiple);
|
||||
else
|
||||
return Source - std::fmod(Source, Multiple) - Multiple;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct compute_floorMultiple<false, false>
|
||||
{
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source >= genType(0))
|
||||
return Source - Source % Multiple;
|
||||
else
|
||||
{
|
||||
genType Tmp = Source + genType(1);
|
||||
return Tmp - Tmp % Multiple - Multiple;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct compute_floorMultiple<false, true>
|
||||
{
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source >= genType(0))
|
||||
return Source - Source % Multiple;
|
||||
else
|
||||
{
|
||||
genType Tmp = Source + genType(1);
|
||||
return Tmp - Tmp % Multiple - Multiple;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<bool is_float, bool is_signed>
|
||||
struct compute_roundMultiple{};
|
||||
|
||||
template<>
|
||||
struct compute_roundMultiple<true, true>
|
||||
{
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source >= genType(0))
|
||||
return Source - std::fmod(Source, Multiple);
|
||||
else
|
||||
{
|
||||
genType Tmp = Source + genType(1);
|
||||
return Tmp - std::fmod(Tmp, Multiple) - Multiple;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct compute_roundMultiple<false, false>
|
||||
{
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source >= genType(0))
|
||||
return Source - Source % Multiple;
|
||||
else
|
||||
{
|
||||
genType Tmp = Source + genType(1);
|
||||
return Tmp - Tmp % Multiple - Multiple;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct compute_roundMultiple<false, true>
|
||||
{
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER static genType call(genType Source, genType Multiple)
|
||||
{
|
||||
if(Source >= genType(0))
|
||||
return Source - Source % Multiple;
|
||||
else
|
||||
{
|
||||
genType Tmp = Source + genType(1);
|
||||
return Tmp - Tmp % Multiple - Multiple;
|
||||
}
|
||||
}
|
||||
};
|
||||
}//namespace detail
|
||||
|
||||
////////////////
|
||||
// isPowerOfTwo
|
||||
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isPowerOfTwo(genType Value)
|
||||
{
|
||||
genType const Result = glm::abs(Value);
|
||||
return !(Result & (Result - 1));
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, bool, Q> isPowerOfTwo(vec<L, T, Q> const& Value)
|
||||
{
|
||||
vec<L, T, Q> const Result(abs(Value));
|
||||
return equal(Result & (Result - 1), vec<L, T, Q>(0));
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// ceilPowerOfTwo
|
||||
|
||||
@ -275,27 +55,6 @@ namespace detail
|
||||
return detail::functor1<vec, L, T, T, Q>::call(roundPowerOfTwo, v);
|
||||
}
|
||||
|
||||
////////////////
|
||||
// isMultiple
|
||||
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isMultiple(genType Value, genType Multiple)
|
||||
{
|
||||
return isMultiple(vec<1, genType>(Value), vec<1, genType>(Multiple)).x;
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, bool, Q> isMultiple(vec<L, T, Q> const& Value, T Multiple)
|
||||
{
|
||||
return (Value % Multiple) == vec<L, T, Q>(0);
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, bool, Q> isMultiple(vec<L, T, Q> const& Value, vec<L, T, Q> const& Multiple)
|
||||
{
|
||||
return (Value % Multiple) == vec<L, T, Q>(0);
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// ceilMultiple
|
||||
|
||||
|
132
glm/gtc/ulp.hpp
132
glm/gtc/ulp.hpp
@ -15,10 +15,138 @@
|
||||
#pragma once
|
||||
|
||||
// Dependencies
|
||||
#include "../ext/scalar_ulp.hpp"
|
||||
#include "../ext/vector_ulp.hpp"
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/qualifier.hpp"
|
||||
#include "../detail/_vectorize.hpp"
|
||||
#include "../ext/scalar_int_sized.hpp"
|
||||
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_ulp extension included")
|
||||
#endif
|
||||
|
||||
namespace glm
|
||||
{
|
||||
/// Return the next ULP value(s) after the input value(s).
|
||||
///
|
||||
/// @tparam genType A floating-point scalar type.
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType next_float(genType x);
|
||||
|
||||
/// Return the previous ULP value(s) before the input value(s).
|
||||
///
|
||||
/// @tparam genType A floating-point scalar type.
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType prev_float(genType x);
|
||||
|
||||
/// Return the value(s) ULP distance after the input value(s).
|
||||
///
|
||||
/// @tparam genType A floating-point scalar type.
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType next_float(genType x, int ULPs);
|
||||
|
||||
/// Return the value(s) ULP distance before the input value(s).
|
||||
///
|
||||
/// @tparam genType A floating-point scalar type.
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType prev_float(genType x, int ULPs);
|
||||
|
||||
/// Return the distance in the number of ULP between 2 single-precision floating-point scalars.
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
GLM_FUNC_DECL int float_distance(float x, float y);
|
||||
|
||||
/// Return the distance in the number of ULP between 2 double-precision floating-point scalars.
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
GLM_FUNC_DECL int64 float_distance(double x, double y);
|
||||
|
||||
/// Return the next ULP value(s) after the input value(s).
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> next_float(vec<L, T, Q> const& x);
|
||||
|
||||
/// Return the value(s) ULP distance after the input value(s).
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> next_float(vec<L, T, Q> const& x, int ULPs);
|
||||
|
||||
/// Return the value(s) ULP distance after the input value(s).
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> next_float(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs);
|
||||
|
||||
/// Return the previous ULP value(s) before the input value(s).
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> prev_float(vec<L, T, Q> const& x);
|
||||
|
||||
/// Return the value(s) ULP distance before the input value(s).
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> prev_float(vec<L, T, Q> const& x, int ULPs);
|
||||
|
||||
/// Return the value(s) ULP distance before the input value(s).
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam T Floating-point
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, T, Q> prev_float(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs);
|
||||
|
||||
/// Return the distance in the number of ULP between 2 single-precision floating-point scalars.
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, int, Q> float_distance(vec<L, float, Q> const& x, vec<L, float, Q> const& y);
|
||||
|
||||
/// Return the distance in the number of ULP between 2 double-precision floating-point scalars.
|
||||
///
|
||||
/// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
|
||||
/// @tparam Q Value from qualifier enum
|
||||
///
|
||||
/// @see gtc_ulp
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_DECL vec<L, int64, Q> float_distance(vec<L, double, Q> const& x, vec<L, double, Q> const& y);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
#include "ulp.inl"
|
||||
|
173
glm/gtc/ulp.inl
173
glm/gtc/ulp.inl
@ -1,3 +1,174 @@
|
||||
/// @ref gtc_ulp
|
||||
///
|
||||
|
||||
#include "../ext/scalar_integer.hpp"
|
||||
#include "../ext/vector_integer.hpp"
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER float next_float(float x)
|
||||
{
|
||||
# if GLM_HAS_CXX11_STL
|
||||
return std::nextafter(x, std::numeric_limits<float>::max());
|
||||
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return detail::nextafterf(x, FLT_MAX);
|
||||
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
|
||||
return __builtin_nextafterf(x, FLT_MAX);
|
||||
# else
|
||||
return nextafterf(x, FLT_MAX);
|
||||
# endif
|
||||
}
|
||||
|
||||
template<>
|
||||
GLM_FUNC_QUALIFIER double next_float(double x)
|
||||
{
|
||||
# if GLM_HAS_CXX11_STL
|
||||
return std::nextafter(x, std::numeric_limits<double>::max());
|
||||
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return detail::nextafter(x, std::numeric_limits<double>::max());
|
||||
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
|
||||
return __builtin_nextafter(x, DBL_MAX);
|
||||
# else
|
||||
return nextafter(x, DBL_MAX);
|
||||
# endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER T next_float(T x, int ULPs)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'next_float' only accept floating-point input");
|
||||
assert(ULPs >= 0);
|
||||
|
||||
T temp = x;
|
||||
for (int i = 0; i < ULPs; ++i)
|
||||
temp = next_float(temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float prev_float(float x)
|
||||
{
|
||||
# if GLM_HAS_CXX11_STL
|
||||
return std::nextafter(x, std::numeric_limits<float>::min());
|
||||
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return detail::nextafterf(x, FLT_MIN);
|
||||
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
|
||||
return __builtin_nextafterf(x, FLT_MIN);
|
||||
# else
|
||||
return nextafterf(x, FLT_MIN);
|
||||
# endif
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER double prev_float(double x)
|
||||
{
|
||||
# if GLM_HAS_CXX11_STL
|
||||
return std::nextafter(x, std::numeric_limits<double>::min());
|
||||
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return _nextafter(x, DBL_MIN);
|
||||
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
|
||||
return __builtin_nextafter(x, DBL_MIN);
|
||||
# else
|
||||
return nextafter(x, DBL_MIN);
|
||||
# endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GLM_FUNC_QUALIFIER T prev_float(T x, int ULPs)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'prev_float' only accept floating-point input");
|
||||
assert(ULPs >= 0);
|
||||
|
||||
T temp = x;
|
||||
for (int i = 0; i < ULPs; ++i)
|
||||
temp = prev_float(temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int float_distance(float x, float y)
|
||||
{
|
||||
detail::float_t<float> const a(x);
|
||||
detail::float_t<float> const b(y);
|
||||
|
||||
return abs(a.i - b.i);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER int64 float_distance(double x, double y)
|
||||
{
|
||||
detail::float_t<double> const a(x);
|
||||
detail::float_t<double> const b(y);
|
||||
|
||||
return abs(a.i - b.i);
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> next_float(vec<L, T, Q> const& x)
|
||||
{
|
||||
vec<L, T, Q> Result;
|
||||
for (length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = next_float(x[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> next_float(vec<L, T, Q> const& x, int ULPs)
|
||||
{
|
||||
vec<L, T, Q> Result;
|
||||
for (length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = next_float(x[i], ULPs);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> next_float(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs)
|
||||
{
|
||||
vec<L, T, Q> Result;
|
||||
for (length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = next_float(x[i], ULPs[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> prev_float(vec<L, T, Q> const& x)
|
||||
{
|
||||
vec<L, T, Q> Result;
|
||||
for (length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = prev_float(x[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> prev_float(vec<L, T, Q> const& x, int ULPs)
|
||||
{
|
||||
vec<L, T, Q> Result;
|
||||
for (length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = prev_float(x[i], ULPs);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> prev_float(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs)
|
||||
{
|
||||
vec<L, T, Q> Result;
|
||||
for (length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = prev_float(x[i], ULPs[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, int, Q> float_distance(vec<L, float, Q> const& x, vec<L, float, Q> const& y)
|
||||
{
|
||||
vec<L, int, Q> Result;
|
||||
for (length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = float_distance(x[i], y[i]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<length_t L, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, int64, Q> float_distance(vec<L, double, Q> const& x, vec<L, double, Q> const& y)
|
||||
{
|
||||
vec<L, int64, Q> Result;
|
||||
for (length_t i = 0, n = Result.length(); i < n; ++i)
|
||||
Result[i] = float_distance(x[i], y[i]);
|
||||
return Result;
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
|
@ -54,6 +54,10 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
|
||||
## Release notes
|
||||
|
||||
### [GLM 0.9.9.6](https://github.com/g-truc/glm/tree/master)
|
||||
#### Features:
|
||||
- Added EXT_scalar_integer extension with power of two and multiple scalar functions
|
||||
- Added EXT_vector_integer extension with power of two and multiple vector functions
|
||||
|
||||
#### Improvements:
|
||||
- Added SYCL support #914
|
||||
- Added Visual C++ 2019 detection
|
||||
@ -65,6 +69,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
|
||||
- Fixed .natvis as structs renamed #915
|
||||
- Fixed ldexp and frexp declaration #895
|
||||
- Fixed missing const to quaternion conversion operators #890
|
||||
- Fixed EXT_scalar_ulp and EXT_vector_ulp API coding style
|
||||
|
||||
### [GLM 0.9.9.5](https://github.com/g-truc/glm/releases/tag/0.9.9.5) - 2019-04-01
|
||||
#### Fixes:
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <glm/ext/vector_float2.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/ext/vector_float4.hpp>
|
||||
#include <glm/gtc/ulp.hpp>
|
||||
#include <glm/ext/scalar_ulp.hpp>
|
||||
|
||||
template <typename matType, typename vecType>
|
||||
static int test_equal()
|
||||
@ -70,16 +70,16 @@ static int test_equal_ulps()
|
||||
|
||||
int Error = 0;
|
||||
|
||||
T const ULP1Plus = glm::next_float(One);
|
||||
T const ULP1Plus = glm::nextFloat(One);
|
||||
Error += glm::all(glm::equal(Ones, mat4(ULP1Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Plus = glm::next_float(ULP1Plus);
|
||||
T const ULP2Plus = glm::nextFloat(ULP1Plus);
|
||||
Error += !glm::all(glm::equal(Ones, mat4(ULP2Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP1Minus = glm::prev_float(One);
|
||||
T const ULP1Minus = glm::prevFloat(One);
|
||||
Error += glm::all(glm::equal(Ones, mat4(ULP1Minus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Minus = glm::prev_float(ULP1Minus);
|
||||
T const ULP2Minus = glm::prevFloat(ULP1Minus);
|
||||
Error += !glm::all(glm::equal(Ones, mat4(ULP2Minus), 1)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
@ -95,16 +95,16 @@ static int test_notEqual_ulps()
|
||||
|
||||
int Error = 0;
|
||||
|
||||
T const ULP1Plus = glm::next_float(One);
|
||||
T const ULP1Plus = glm::nextFloat(One);
|
||||
Error += !glm::all(glm::notEqual(Ones, mat4(ULP1Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Plus = glm::next_float(ULP1Plus);
|
||||
T const ULP2Plus = glm::nextFloat(ULP1Plus);
|
||||
Error += glm::all(glm::notEqual(Ones, mat4(ULP2Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP1Minus = glm::prev_float(One);
|
||||
T const ULP1Minus = glm::prevFloat(One);
|
||||
Error += !glm::all(glm::notEqual(Ones, mat4(ULP1Minus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Minus = glm::prev_float(ULP1Minus);
|
||||
T const ULP2Minus = glm::prevFloat(ULP1Minus);
|
||||
Error += glm::all(glm::notEqual(Ones, mat4(ULP2Minus), 1)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/gtc/ulp.hpp>
|
||||
#include <glm/ext/scalar_integer.hpp>
|
||||
#include <glm/ext/scalar_ulp.hpp>
|
||||
#include <cmath>
|
||||
|
||||
static int test_equal_epsilon()
|
||||
@ -36,16 +37,16 @@ static int test_equal_ulps()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float const ULP1Plus = glm::next_float(1.0f);
|
||||
float const ULP1Plus = glm::nextFloat(1.0f);
|
||||
Error += glm::equal(1.0f, ULP1Plus, 1) ? 0 : 1;
|
||||
|
||||
float const ULP2Plus = glm::next_float(ULP1Plus);
|
||||
float const ULP2Plus = glm::nextFloat(ULP1Plus);
|
||||
Error += !glm::equal(1.0f, ULP2Plus, 1) ? 0 : 1;
|
||||
|
||||
float const ULP1Minus = glm::prev_float(1.0f);
|
||||
float const ULP1Minus = glm::prevFloat(1.0f);
|
||||
Error += glm::equal(1.0f, ULP1Minus, 1) ? 0 : 1;
|
||||
|
||||
float const ULP2Minus = glm::prev_float(ULP1Minus);
|
||||
float const ULP2Minus = glm::prevFloat(ULP1Minus);
|
||||
Error += !glm::equal(1.0f, ULP2Minus, 1) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
@ -55,16 +56,16 @@ static int test_notEqual_ulps()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float const ULP1Plus = glm::next_float(1.0f);
|
||||
float const ULP1Plus = glm::nextFloat(1.0f);
|
||||
Error += !glm::notEqual(1.0f, ULP1Plus, 1) ? 0 : 1;
|
||||
|
||||
float const ULP2Plus = glm::next_float(ULP1Plus);
|
||||
float const ULP2Plus = glm::nextFloat(ULP1Plus);
|
||||
Error += glm::notEqual(1.0f, ULP2Plus, 1) ? 0 : 1;
|
||||
|
||||
float const ULP1Minus = glm::prev_float(1.0f);
|
||||
float const ULP1Minus = glm::prevFloat(1.0f);
|
||||
Error += !glm::notEqual(1.0f, ULP1Minus, 1) ? 0 : 1;
|
||||
|
||||
float const ULP2Minus = glm::prev_float(ULP1Minus);
|
||||
float const ULP2Minus = glm::prevFloat(ULP1Minus);
|
||||
Error += glm::notEqual(1.0f, ULP2Minus, 1) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
|
@ -7,14 +7,14 @@ static int test_ulp_float_dist()
|
||||
|
||||
float A = 1.0f;
|
||||
|
||||
float B = glm::next_float(A);
|
||||
float B = glm::nextFloat(A);
|
||||
Error += glm::notEqual(A, B, 0) ? 0 : 1;
|
||||
float C = glm::prev_float(B);
|
||||
float C = glm::prevFloat(B);
|
||||
Error += glm::equal(A, C, 0) ? 0 : 1;
|
||||
|
||||
int D = glm::float_distance(A, B);
|
||||
int D = glm::floatDistance(A, B);
|
||||
Error += D == 1 ? 0 : 1;
|
||||
int E = glm::float_distance(A, C);
|
||||
int E = glm::floatDistance(A, C);
|
||||
Error += E == 0 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
@ -28,14 +28,14 @@ static int test_ulp_float_step()
|
||||
|
||||
for(int i = 10; i < 1000; i *= 10)
|
||||
{
|
||||
float B = glm::next_float(A, i);
|
||||
float B = glm::nextFloat(A, i);
|
||||
Error += glm::notEqual(A, B, 0) ? 0 : 1;
|
||||
float C = glm::prev_float(B, i);
|
||||
float C = glm::prevFloat(B, i);
|
||||
Error += glm::equal(A, C, 0) ? 0 : 1;
|
||||
|
||||
int D = glm::float_distance(A, B);
|
||||
int D = glm::floatDistance(A, B);
|
||||
Error += D == i ? 0 : 1;
|
||||
int E = glm::float_distance(A, C);
|
||||
int E = glm::floatDistance(A, C);
|
||||
Error += E == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
@ -48,14 +48,14 @@ static int test_ulp_double_dist()
|
||||
|
||||
double A = 1.0;
|
||||
|
||||
double B = glm::next_float(A);
|
||||
double B = glm::nextFloat(A);
|
||||
Error += glm::notEqual(A, B, 0) ? 0 : 1;
|
||||
double C = glm::prev_float(B);
|
||||
double C = glm::prevFloat(B);
|
||||
Error += glm::equal(A, C, 0) ? 0 : 1;
|
||||
|
||||
glm::int64 const D = glm::float_distance(A, B);
|
||||
glm::int64 const D = glm::floatDistance(A, B);
|
||||
Error += D == 1 ? 0 : 1;
|
||||
glm::int64 const E = glm::float_distance(A, C);
|
||||
glm::int64 const E = glm::floatDistance(A, C);
|
||||
Error += E == 0 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
@ -69,14 +69,14 @@ static int test_ulp_double_step()
|
||||
|
||||
for(int i = 10; i < 1000; i *= 10)
|
||||
{
|
||||
double B = glm::next_float(A, i);
|
||||
double B = glm::nextFloat(A, i);
|
||||
Error += glm::notEqual(A, B, 0) ? 0 : 1;
|
||||
double C = glm::prev_float(B, i);
|
||||
double C = glm::prevFloat(B, i);
|
||||
Error += glm::equal(A, C, 0) ? 0 : 1;
|
||||
|
||||
glm::int64 const D = glm::float_distance(A, B);
|
||||
glm::int64 const D = glm::floatDistance(A, B);
|
||||
Error += D == i ? 0 : 1;
|
||||
glm::int64 const E = glm::float_distance(A, C);
|
||||
glm::int64 const E = glm::floatDistance(A, C);
|
||||
Error += E == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <glm/ext/vector_double3_precision.hpp>
|
||||
#include <glm/ext/vector_double4.hpp>
|
||||
#include <glm/ext/vector_double4_precision.hpp>
|
||||
#include <glm/gtc/ulp.hpp>
|
||||
#include <glm/ext/vector_ulp.hpp>
|
||||
|
||||
template <typename vecType>
|
||||
static int test_equal()
|
||||
@ -79,16 +79,16 @@ static int test_equal_ulps()
|
||||
|
||||
int Error = 0;
|
||||
|
||||
T const ULP1Plus = glm::next_float(One);
|
||||
T const ULP1Plus = glm::nextFloat(One);
|
||||
Error += glm::all(glm::equal(Ones, vec4(ULP1Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Plus = glm::next_float(ULP1Plus);
|
||||
T const ULP2Plus = glm::nextFloat(ULP1Plus);
|
||||
Error += !glm::all(glm::equal(Ones, vec4(ULP2Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP1Minus = glm::prev_float(One);
|
||||
T const ULP1Minus = glm::prevFloat(One);
|
||||
Error += glm::all(glm::equal(Ones, vec4(ULP1Minus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Minus = glm::prev_float(ULP1Minus);
|
||||
T const ULP2Minus = glm::prevFloat(ULP1Minus);
|
||||
Error += !glm::all(glm::equal(Ones, vec4(ULP2Minus), 1)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
@ -104,16 +104,16 @@ static int test_notEqual_ulps()
|
||||
|
||||
int Error = 0;
|
||||
|
||||
T const ULP1Plus = glm::next_float(One);
|
||||
T const ULP1Plus = glm::nextFloat(One);
|
||||
Error += !glm::all(glm::notEqual(Ones, vec4(ULP1Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Plus = glm::next_float(ULP1Plus);
|
||||
T const ULP2Plus = glm::nextFloat(ULP1Plus);
|
||||
Error += glm::all(glm::notEqual(Ones, vec4(ULP2Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP1Minus = glm::prev_float(One);
|
||||
T const ULP1Minus = glm::prevFloat(One);
|
||||
Error += !glm::all(glm::notEqual(Ones, vec4(ULP1Minus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Minus = glm::prev_float(ULP1Minus);
|
||||
T const ULP2Minus = glm::prevFloat(ULP1Minus);
|
||||
Error += glm::all(glm::notEqual(Ones, vec4(ULP2Minus), 1)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
|
@ -10,14 +10,14 @@ static int test_ulp_float_dist()
|
||||
|
||||
glm::vec4 const A(1.0f);
|
||||
|
||||
glm::vec4 const B = glm::next_float(A);
|
||||
glm::vec4 const B = glm::nextFloat(A);
|
||||
Error += glm::any(glm::notEqual(A, B, 0)) ? 0 : 1;
|
||||
glm::vec4 const C = glm::prev_float(B);
|
||||
glm::vec4 const C = glm::prevFloat(B);
|
||||
Error += glm::all(glm::equal(A, C, 0)) ? 0 : 1;
|
||||
|
||||
glm::ivec4 const D = glm::float_distance(A, B);
|
||||
glm::ivec4 const D = glm::floatDistance(A, B);
|
||||
Error += D == glm::ivec4(1) ? 0 : 1;
|
||||
glm::ivec4 const E = glm::float_distance(A, C);
|
||||
glm::ivec4 const E = glm::floatDistance(A, C);
|
||||
Error += E == glm::ivec4(0) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
@ -31,14 +31,14 @@ static int test_ulp_float_step()
|
||||
|
||||
for(int i = 10; i < 1000; i *= 10)
|
||||
{
|
||||
glm::vec4 const B = glm::next_float(A, i);
|
||||
glm::vec4 const B = glm::nextFloat(A, i);
|
||||
Error += glm::any(glm::notEqual(A, B, 0)) ? 0 : 1;
|
||||
glm::vec4 const C = glm::prev_float(B, i);
|
||||
glm::vec4 const C = glm::prevFloat(B, i);
|
||||
Error += glm::all(glm::equal(A, C, 0)) ? 0 : 1;
|
||||
|
||||
glm::ivec4 const D = glm::float_distance(A, B);
|
||||
glm::ivec4 const D = glm::floatDistance(A, B);
|
||||
Error += D == glm::ivec4(i) ? 0 : 1;
|
||||
glm::ivec4 const E = glm::float_distance(A, C);
|
||||
glm::ivec4 const E = glm::floatDistance(A, C);
|
||||
Error += E == glm::ivec4(0) ? 0 : 1;
|
||||
}
|
||||
|
||||
@ -51,14 +51,14 @@ static int test_ulp_double_dist()
|
||||
|
||||
glm::dvec4 const A(1.0);
|
||||
|
||||
glm::dvec4 const B = glm::next_float(A);
|
||||
glm::dvec4 const B = glm::nextFloat(A);
|
||||
Error += glm::any(glm::notEqual(A, B, 0)) ? 0 : 1;
|
||||
glm::dvec4 const C = glm::prev_float(B);
|
||||
glm::dvec4 const C = glm::prevFloat(B);
|
||||
Error += glm::all(glm::equal(A, C, 0)) ? 0 : 1;
|
||||
|
||||
glm::ivec4 const D(glm::float_distance(A, B));
|
||||
glm::ivec4 const D(glm::floatDistance(A, B));
|
||||
Error += D == glm::ivec4(1) ? 0 : 1;
|
||||
glm::ivec4 const E = glm::float_distance(A, C);
|
||||
glm::ivec4 const E = glm::floatDistance(A, C);
|
||||
Error += E == glm::ivec4(0) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
@ -72,14 +72,14 @@ static int test_ulp_double_step()
|
||||
|
||||
for(int i = 10; i < 1000; i *= 10)
|
||||
{
|
||||
glm::dvec4 const B = glm::next_float(A, i);
|
||||
glm::dvec4 const B = glm::nextFloat(A, i);
|
||||
Error += glm::any(glm::notEqual(A, B, 0)) ? 0 : 1;
|
||||
glm::dvec4 const C = glm::prev_float(B, i);
|
||||
glm::dvec4 const C = glm::prevFloat(B, i);
|
||||
Error += glm::all(glm::equal(A, C, 0)) ? 0 : 1;
|
||||
|
||||
glm::ivec4 const D(glm::float_distance(A, B));
|
||||
glm::ivec4 const D(glm::floatDistance(A, B));
|
||||
Error += D == glm::ivec4(i) ? 0 : 1;
|
||||
glm::ivec4 const E(glm::float_distance(A, C));
|
||||
glm::ivec4 const E(glm::floatDistance(A, C));
|
||||
Error += E == glm::ivec4(0) ? 0 : 1;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
#include <glm/ext/scalar_ulp.hpp>
|
||||
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/gtc/type_precision.hpp>
|
||||
#include <glm/gtx/fast_trigonometry.hpp>
|
||||
#include <glm/gtx/integer.hpp>
|
||||
#include <glm/gtx/common.hpp>
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/gtc/ulp.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <glm/trigonometric.hpp>
|
||||
#include <cmath>
|
||||
@ -21,11 +22,11 @@ namespace fastCos
|
||||
float result = 0.f;
|
||||
|
||||
const std::clock_t timestamp1 = std::clock();
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f)
|
||||
result = glm::fastCos(i);
|
||||
|
||||
const std::clock_t timestamp2 = std::clock();
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f)
|
||||
result = glm::cos(i);
|
||||
|
||||
const std::clock_t timestamp3 = std::clock();
|
||||
@ -55,11 +56,11 @@ namespace fastSin
|
||||
float result = 0.f;
|
||||
|
||||
const std::clock_t timestamp1 = std::clock();
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f)
|
||||
result = glm::fastSin(i);
|
||||
|
||||
const std::clock_t timestamp2 = std::clock();
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f)
|
||||
result = glm::sin(i);
|
||||
|
||||
const std::clock_t timestamp3 = std::clock();
|
||||
@ -81,11 +82,11 @@ namespace fastTan
|
||||
float result = 0.f;
|
||||
|
||||
const std::clock_t timestamp1 = std::clock();
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f)
|
||||
result = glm::fastTan(i);
|
||||
|
||||
const std::clock_t timestamp2 = std::clock();
|
||||
for (float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
|
||||
for (float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f)
|
||||
result = glm::tan(i);
|
||||
|
||||
const std::clock_t timestamp3 = std::clock();
|
||||
@ -107,11 +108,11 @@ namespace fastAcos
|
||||
float result = 0.f;
|
||||
|
||||
const std::clock_t timestamp1 = std::clock();
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f)
|
||||
result = glm::fastAcos(i);
|
||||
|
||||
const std::clock_t timestamp2 = std::clock();
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f)
|
||||
result = glm::acos(i);
|
||||
|
||||
const std::clock_t timestamp3 = std::clock();
|
||||
@ -133,10 +134,10 @@ namespace fastAsin
|
||||
const float end = glm::pi<float>();
|
||||
float result = 0.f;
|
||||
const std::clock_t timestamp1 = std::clock();
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f)
|
||||
result = glm::fastAsin(i);
|
||||
const std::clock_t timestamp2 = std::clock();
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f)
|
||||
result = glm::asin(i);
|
||||
const std::clock_t timestamp3 = std::clock();
|
||||
const std::clock_t time_fast = timestamp2 - timestamp1;
|
||||
@ -156,10 +157,10 @@ namespace fastAtan
|
||||
const float end = glm::pi<float>();
|
||||
float result = 0.f;
|
||||
const std::clock_t timestamp1 = std::clock();
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f)
|
||||
result = glm::fastAtan(i);
|
||||
const std::clock_t timestamp2 = std::clock();
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
|
||||
for(float i = begin; i < end; i = NextFloat ? glm::nextFloat(i) : i += 0.1f)
|
||||
result = glm::atan(i);
|
||||
const std::clock_t timestamp3 = std::clock();
|
||||
const std::clock_t time_fast = timestamp2 - timestamp1;
|
||||
|
Loading…
Reference in New Issue
Block a user