Rely on STL functions for GLM functions using the same prototype #233

This commit is contained in:
Christophe Riccio 2014-09-06 01:45:13 +02:00
parent 4a701c6760
commit ac3c2e37f1
8 changed files with 288 additions and 151 deletions

View file

@ -141,6 +141,18 @@
VECTORIZE3_VEC_SCA(func) \
VECTORIZE4_VEC_SCA(func)
#define VECTORIZE1_VEC_VEC(func) \
template <typename T, precision P> \
GLM_FUNC_QUALIFIER detail::tvec1<T, P> func \
( \
detail::tvec1<T, P> const & x, \
detail::tvec1<T, P> const & y \
) \
{ \
return detail::tvec1<T, P>( \
func(x.x, y.x)); \
}
#define VECTORIZE2_VEC_VEC(func) \
template <typename T, precision P> \
GLM_FUNC_QUALIFIER detail::tvec2<T, P> func \
@ -184,6 +196,7 @@
}
#define VECTORIZE_VEC_VEC(func) \
VECTORIZE1_VEC_VEC(func) \
VECTORIZE2_VEC_VEC(func) \
VECTORIZE3_VEC_VEC(func) \
VECTORIZE4_VEC_VEC(func)

View file

@ -254,6 +254,8 @@ namespace detail
VECTORIZE_VEC(roundEven)
// ceil
using std::ceil;
/*
template <typename genType>
GLM_FUNC_QUALIFIER genType ceil(genType const & x)
{
@ -263,7 +265,7 @@ namespace detail
return ::std::ceil(x);
}
*/
VECTORIZE_VEC(ceil)
// fract
@ -273,9 +275,7 @@ namespace detail
genType const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<genType>::is_iec559,
"'fract' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fract' only accept floating-point inputs");
return x - floor(x);
}
@ -286,13 +286,11 @@ namespace detail
template <typename genType>
GLM_FUNC_QUALIFIER genType mod
(
genType const & x,
genType const & x,
genType const & y
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<genType>::is_iec559,
"'mod' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'mod' only accept floating-point inputs");
return x - y * floor(x / y);
}
@ -304,13 +302,11 @@ namespace detail
template <typename genType>
GLM_FUNC_QUALIFIER genType modf
(
genType const & x,
genType const & x,
genType & i
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<genType>::is_iec559,
"'modf' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'modf' only accept floating-point inputs");
return std::modf(x, &i);
}
@ -573,9 +569,7 @@ namespace detail
vecType<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'step' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'step' only accept floating-point inputs");
return mix(vecType<T, P>(1), vecType<T, P>(0), glm::lessThan(x, vecType<T, P>(edge)));
}
@ -589,9 +583,7 @@ namespace detail
genType const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<genType>::is_iec559,
"'smoothstep' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'smoothstep' only accept floating-point inputs");
genType tmp = clamp((x - edge0) / (edge1 - edge0), genType(0), genType(1));
return tmp * tmp * (genType(3) - genType(2) * tmp);
@ -605,9 +597,7 @@ namespace detail
detail::tvec2<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'smoothstep' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
return detail::tvec2<T, P>(
smoothstep(edge0, edge1, x.x),
@ -622,9 +612,7 @@ namespace detail
detail::tvec3<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'smoothstep' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
return detail::tvec3<T, P>(
smoothstep(edge0, edge1, x.x),
@ -640,9 +628,7 @@ namespace detail
detail::tvec4<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'smoothstep' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
return detail::tvec4<T, P>(
smoothstep(edge0, edge1, x.x),
@ -659,9 +645,7 @@ namespace detail
detail::tvec2<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'smoothstep' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
return detail::tvec2<T, P>(
smoothstep(edge0.x, edge1.x, x.x),
@ -676,9 +660,7 @@ namespace detail
detail::tvec3<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'smoothstep' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
return detail::tvec3<T, P>(
smoothstep(edge0.x, edge1.x, x.x),
@ -694,9 +676,7 @@ namespace detail
detail::tvec4<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'smoothstep' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'smoothstep' only accept floating-point inputs");
return detail::tvec4<T, P>(
smoothstep(edge0.x, edge1.x, x.x),
@ -709,9 +689,7 @@ namespace detail
template <typename genType>
GLM_FUNC_QUALIFIER bool isnan(genType const & x)
{
GLM_STATIC_ASSERT(
std::numeric_limits<genType>::is_iec559,
"'isnan' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'isnan' only accept floating-point inputs");
# if(GLM_LANG & GLM_LANG_CXX11_FLAG)
return std::isnan(x);
@ -730,15 +708,25 @@ namespace detail
# endif
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER typename detail::tvec1<T, P>::bool_type isnan
(
detail::tvec1<T, P> const & x
)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
return typename detail::tvec1<T, P>::bool_type(
isnan(x.x));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER typename detail::tvec2<T, P>::bool_type isnan
(
detail::tvec2<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'isnan' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
return typename detail::tvec2<T, P>::bool_type(
isnan(x.x),
@ -751,9 +739,7 @@ namespace detail
detail::tvec3<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'isnan' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
return typename detail::tvec3<T, P>::bool_type(
isnan(x.x),
@ -767,9 +753,7 @@ namespace detail
detail::tvec4<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'isnan' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isnan' only accept floating-point inputs");
return typename detail::tvec4<T, P>::bool_type(
isnan(x.x),
@ -802,15 +786,25 @@ namespace detail
# endif
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER typename detail::tvec1<T, P>::bool_type isinf
(
detail::tvec1<T, P> const & x
)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isinf' only accept floating-point inputs");
return typename detail::tvec1<T, P>::bool_type(
isinf(x.x));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER typename detail::tvec2<T, P>::bool_type isinf
(
detail::tvec2<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'isinf' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isinf' only accept floating-point inputs");
return typename detail::tvec2<T, P>::bool_type(
isinf(x.x),
@ -823,9 +817,7 @@ namespace detail
detail::tvec3<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'isinf' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isinf' only accept floating-point inputs");
return typename detail::tvec3<T, P>::bool_type(
isinf(x.x),
@ -839,9 +831,7 @@ namespace detail
detail::tvec4<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'isinf' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isinf' only accept floating-point inputs");
return typename detail::tvec4<T, P>::bool_type(
isinf(x.x),
@ -912,13 +902,23 @@ namespace detail
int & exp
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<genType>::is_iec559,
"'frexp' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'frexp' only accept floating-point inputs");
return std::frexp(x, exp);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec1<T, P> frexp
(
detail::tvec1<T, P> const & x,
detail::tvec1<int, P> & exp
)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'frexp' only accept floating-point inputs");
return detail::tvec1<T, P>(std::frexp(x.x, exp.x));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec2<T, P> frexp
(
@ -926,9 +926,7 @@ namespace detail
detail::tvec2<int, P> & exp
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'frexp' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'frexp' only accept floating-point inputs");
return detail::tvec2<T, P>(
frexp(x.x, exp.x),
@ -942,9 +940,7 @@ namespace detail
detail::tvec3<int, P> & exp
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'frexp' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'frexp' only accept floating-point inputs");
return detail::tvec3<T, P>(
frexp(x.x, exp.x),
@ -959,9 +955,7 @@ namespace detail
detail::tvec4<int, P> & exp
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'frexp' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'frexp' only accept floating-point inputs");
return detail::tvec4<T, P>(
frexp(x.x, exp.x),
@ -977,13 +971,24 @@ namespace detail
int const & exp
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<genType>::is_iec559,
"'frexp' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'ldexp' only accept floating-point inputs");
return std::ldexp(x, exp);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec1<T, P> ldexp
(
detail::tvec1<T, P> const & x,
detail::tvec1<int, P> const & exp
)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'ldexp' only accept floating-point inputs");
return detail::tvec1<T, P>(
ldexp(x.x, exp.x));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tvec2<T, P> ldexp
(
@ -991,9 +996,7 @@ namespace detail
detail::tvec2<int, P> const & exp
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'ldexp' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'ldexp' only accept floating-point inputs");
return detail::tvec2<T, P>(
ldexp(x.x, exp.x),
@ -1007,9 +1010,7 @@ namespace detail
detail::tvec3<int, P> const & exp
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'ldexp' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'ldexp' only accept floating-point inputs");
return detail::tvec3<T, P>(
ldexp(x.x, exp.x),
@ -1024,9 +1025,7 @@ namespace detail
detail::tvec4<int, P> const & exp
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<T>::is_iec559,
"'ldexp' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'ldexp' only accept floating-point inputs");
return detail::tvec4<T, P>(
ldexp(x.x, exp.x),

View file

@ -29,6 +29,7 @@
#include "func_vector_relational.hpp"
#include "_vectorize.hpp"
#include <limits>
#include <cmath>
#include <cassert>
namespace glm{
@ -47,7 +48,11 @@ namespace detail
template <typename T>
GLM_FUNC_QUALIFIER T operator() (T const & Value) const
{
return static_cast<T>(::std::log(Value)) * static_cast<T>(1.4426950408889634073599246810019);
# if(GLM_LANG & GLM_LANG_CXX11_FLAG)
return std::log2(Value);
# else
return std::log(Value) * static_cast<T>(1.4426950408889634073599246810019);
# endif
}
};
@ -78,6 +83,9 @@ namespace detail
}//namespace detail
// pow
using std::pow;
/*
template <typename genType>
GLM_FUNC_QUALIFIER genType pow
(
@ -91,10 +99,14 @@ namespace detail
return std::pow(x, y);
}
*/
VECTORIZE_VEC_VEC(pow)
// exp
using std::exp;
/*
template <typename genType>
GLM_FUNC_QUALIFIER genType exp
(
@ -107,10 +119,13 @@ namespace detail
return std::exp(x);
}
*/
VECTORIZE_VEC(exp)
// log
using std::log;
/*
template <typename genType>
GLM_FUNC_QUALIFIER genType log
(
@ -123,7 +138,7 @@ namespace detail
return std::log(x);
}
*/
VECTORIZE_VEC(log)
//exp2, ln2 = 0.69314718055994530941723212145818f
@ -195,6 +210,8 @@ namespace detail
}//namespace detail
// sqrt
using std::sqrt;
/*
GLM_FUNC_QUALIFIER float sqrt(float x)
{
# ifdef __CUDACC__ // Wordaround for a CUDA compiler bug up to CUDA6
@ -214,7 +231,7 @@ namespace detail
return detail::compute_sqrt<detail::tvec1, double, highp>::call(x).x;
# endif
}
*/
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> sqrt(vecType<T, P> const & x)
{

View file

@ -39,6 +39,8 @@
#pragma once
#include "setup.hpp"
namespace glm
{
/// @addtogroup core_func_trigonometric
@ -50,7 +52,7 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/radians.xml">GLSL radians man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template <typename genType>
template <typename genType>
GLM_FUNC_DECL genType radians(genType const & degrees);
/// Converts radians to degrees and returns the result.
@ -59,7 +61,7 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/degrees.xml">GLSL degrees man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.1 Angle and Trigonometry Functions</a>
template <typename genType>
template <typename genType>
GLM_FUNC_DECL genType degrees(genType const & radians);
/// The standard trigonometric sine function.

View file

@ -61,6 +61,8 @@ namespace glm
VECTORIZE_VEC(degrees)
// sin
using std::sin;
/*
template <typename genType>
GLM_FUNC_QUALIFIER genType sin
(
@ -71,10 +73,12 @@ namespace glm
return genType(::std::sin(angle));
}
*/
VECTORIZE_VEC(sin)
// cos
using std::cos;
/*
template <typename genType>
GLM_FUNC_QUALIFIER genType cos(genType const & angle)
{
@ -82,10 +86,13 @@ namespace glm
return genType(::std::cos(angle));
}
*/
VECTORIZE_VEC(cos)
// tan
using std::tan;
/*
template <typename genType>
GLM_FUNC_QUALIFIER genType tan
(
@ -96,10 +103,13 @@ namespace glm
return genType(::std::tan(angle));
}
*/
VECTORIZE_VEC(tan)
// asin
using std::asin;
/*
template <typename genType>
GLM_FUNC_QUALIFIER genType asin
(
@ -110,10 +120,12 @@ namespace glm
return genType(::std::asin(x));
}
*/
VECTORIZE_VEC(asin)
// acos
using std::acos;
/*
template <typename genType>
GLM_FUNC_QUALIFIER genType acos
(
@ -122,26 +134,28 @@ namespace glm
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acos' only accept floating-point input");
return genType(::std::acos(x));
return ::std::acos(x);
}
*/
VECTORIZE_VEC(acos)
// atan
template <typename genType>
GLM_FUNC_QUALIFIER genType atan
(
genType const & y,
genType const & y,
genType const & x
)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'atan' only accept floating-point input");
return genType(::std::atan2(y, x));
return ::std::atan2(y, x);
}
VECTORIZE_VEC_VEC(atan)
using std::atan;
/*
template <typename genType>
GLM_FUNC_QUALIFIER genType atan
(
@ -150,12 +164,14 @@ namespace glm
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'atan' only accept floating-point input");
return genType(::std::atan(x));
return ::std::atan(x);
}
*/
VECTORIZE_VEC(atan)
// sinh
using std::sinh;
/*
template <typename genType>
GLM_FUNC_QUALIFIER genType sinh
(
@ -164,12 +180,14 @@ namespace glm
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sinh' only accept floating-point input");
return genType(std::sinh(angle));
return ::std::sinh(angle);
}
*/
VECTORIZE_VEC(sinh)
// cosh
using std::cosh;
/*
template <typename genType>
GLM_FUNC_QUALIFIER genType cosh
(
@ -178,12 +196,14 @@ namespace glm
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'cosh' only accept floating-point input");
return genType(std::cosh(angle));
return ::std::cosh(angle);
}
*/
VECTORIZE_VEC(cosh)
// tanh
using std::tanh;
/*
template <typename genType>
GLM_FUNC_QUALIFIER genType tanh
(
@ -192,54 +212,57 @@ namespace glm
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'tanh' only accept floating-point input");
return genType(std::tanh(angle));
return ::std::tanh(angle);
}
*/
VECTORIZE_VEC(tanh)
// asinh
template <typename genType>
GLM_FUNC_QUALIFIER genType asinh
(
genType const & x
)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asinh' only accept floating-point input");
return (x < genType(0) ? genType(-1) : (x > genType(0) ? genType(1) : genType(0))) * log(abs(x) + sqrt(genType(1) + x * x));
}
# if(GLM_LANG & GLM_LANG_CXX11_FLAG)
using std::asinh;
# else
template <typename genType>
GLM_FUNC_QUALIFIER genType asinh(genType const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asinh' only accept floating-point input");
return (x < static_cast<genType>(0) ? static_cast<genType>(-1) : (x > static_cast<genType>(0) ? static_cast<genType>(1) : static_cast<genType>(0))) * log(abs(x) + sqrt(static_cast<genType>(1) + x * x));
}
# endif
VECTORIZE_VEC(asinh)
// acosh
template <typename genType>
GLM_FUNC_QUALIFIER genType acosh
(
genType const & x
)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acosh' only accept floating-point input");
# if(GLM_LANG & GLM_LANG_CXX11_FLAG)
using std::acosh;
# else
template <typename genType>
GLM_FUNC_QUALIFIER genType acosh(genType const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acosh' only accept floating-point input");
if(x < genType(1))
return genType(0);
return log(x + sqrt(x * x - genType(1)));
}
if(x < static_cast<genType>(1))
return static_cast<genType>(0);
return log(x + sqrt(x * x - static_cast<genType>(1)));
}
# endif
VECTORIZE_VEC(acosh)
// atanh
template <typename genType>
GLM_FUNC_QUALIFIER genType atanh
(
genType const & x
)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'atanh' only accept floating-point input");
# if(GLM_LANG & GLM_LANG_CXX11_FLAG)
using std::atanh;
# else
template <typename genType>
GLM_FUNC_QUALIFIER genType atanh(genType const & x)
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'atanh' only accept floating-point input");
if(abs(x) >= genType(1))
return 0;
return genType(0.5) * log((genType(1) + x) / (genType(1) - x));
}
if(abs(x) >= static_cast<genType>(1))
return 0;
return static_cast<genType>(0.5) * log((static_cast<genType>(1) + x) / (static_cast<genType>(1) - x));
}
# endif
VECTORIZE_VEC(atanh)

View file

@ -10,34 +10,116 @@
#include <glm/common.hpp>
#include <glm/exponential.hpp>
#include <glm/gtc/ulp.hpp>
#include <glm/gtx/vec1.hpp>
namespace inversesqrt
int test_pow()
{
int test()
int Error(0);
float A = glm::pow(10.f, 10.f);
glm::vec1 B = glm::pow(glm::vec1(10.f), glm::vec1(10.f));
glm::vec2 C = glm::pow(glm::vec2(10.f), glm::vec2(10.f));
glm::vec3 D = glm::pow(glm::vec3(10.f), glm::vec3(10.f));
glm::vec4 E = glm::pow(glm::vec4(10.f), glm::vec4(10.f));
return Error;
}
int test_exp()
{
int Error(0);
float A = glm::exp(10.f);
glm::vec1 B = glm::exp(glm::vec1(10.f));
glm::vec2 C = glm::exp(glm::vec2(10.f));
glm::vec3 D = glm::exp(glm::vec3(10.f));
glm::vec4 E = glm::exp(glm::vec4(10.f));
return Error;
}
int test_log()
{
int Error(0);
float A = glm::log(10.f);
glm::vec1 B = glm::log(glm::vec1(10.f));
glm::vec2 C = glm::log(glm::vec2(10.f));
glm::vec3 D = glm::log(glm::vec3(10.f));
glm::vec4 E = glm::log(glm::vec4(10.f));
return Error;
}
int test_exp2()
{
int Error(0);
float A = glm::exp2(10.f);
glm::vec1 B = glm::exp2(glm::vec1(10.f));
glm::vec2 C = glm::exp2(glm::vec2(10.f));
glm::vec3 D = glm::exp2(glm::vec3(10.f));
glm::vec4 E = glm::exp2(glm::vec4(10.f));
return Error;
}
int test_log2()
{
int Error(0);
float A = glm::log2(10.f);
glm::vec1 B = glm::log2(glm::vec1(10.f));
glm::vec2 C = glm::log2(glm::vec2(10.f));
glm::vec3 D = glm::log2(glm::vec3(10.f));
glm::vec4 E = glm::log2(glm::vec4(10.f));
return Error;
}
int test_sqrt()
{
int Error(0);
float A = glm::sqrt(10.f);
glm::vec1 B = glm::sqrt(glm::vec1(10.f));
glm::vec2 C = glm::sqrt(glm::vec2(10.f));
glm::vec3 D = glm::sqrt(glm::vec3(10.f));
glm::vec4 E = glm::sqrt(glm::vec4(10.f));
return Error;
}
int test_inversesqrt()
{
int Error(0);
glm::uint ulp(0);
float diff(0.0f);
for(float f = 0.001f; f < 10.f; f *= 1.001f)
{
int Error(0);
glm::lowp_fvec1 lowp_v = glm::inversesqrt(glm::lowp_fvec1(f));
float defaultp_v = glm::inversesqrt(f);
glm::uint ulp(0);
float diff(0.0f);
for(float f = 0.001f; f < 10.f; f *= 1.001f)
{
glm::lowp_fvec1 lowp_v = glm::inversesqrt(glm::lowp_fvec1(f));
float defaultp_v = glm::inversesqrt(f);
ulp = glm::max(glm::float_distance(lowp_v.x, defaultp_v), ulp);
diff = glm::abs(lowp_v.x - defaultp_v);
}
return Error;
ulp = glm::max(glm::float_distance(lowp_v.x, defaultp_v), ulp);
diff = glm::abs(lowp_v.x - defaultp_v);
}
}//namespace inversesqrt
return Error;
}
int main()
{
int Error(0);
Error += inversesqrt::test();
Error += test_pow();
Error += test_exp();
Error += test_log();
Error += test_exp2();
Error += test_log2();
Error += test_sqrt();
Error += test_inversesqrt();
return Error;
}

View file

@ -7,7 +7,7 @@
// File : test/core/func_trigonometric.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/trigonometric.hpp>
int main()
{

View file

@ -7,6 +7,7 @@
// File : test/gtx/gtx_integer.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/exponential.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/gtx/integer.hpp>
#include <cstdio>