Completed EXT_*_integer extensions
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user