vector_ulp.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /// @ref ext_vector_ulp
  2. /// @file glm/ext/vector_ulp.hpp
  3. ///
  4. /// @defgroup ext_vector_ulp GLM_EXT_vector_ulp
  5. /// @ingroup ext
  6. ///
  7. /// Allow the measurement of the accuracy of a function against a reference
  8. /// implementation. This extension works on floating-point data and provide results
  9. /// in ULP.
  10. ///
  11. /// Include <glm/ext/vector_ulp.hpp> to use the features of this extension.
  12. ///
  13. /// @see ext_scalar_ulp
  14. /// @see ext_scalar_relational
  15. /// @see ext_vector_relational
  16. #pragma once
  17. // Dependencies
  18. #include "../ext/scalar_ulp.hpp"
  19. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  20. # pragma message("GLM: GLM_EXT_vector_ulp extension included")
  21. #endif
  22. namespace glm
  23. {
  24. /// @addtogroup ext_vector_ulp
  25. /// @{
  26. /// Return the next ULP value(s) after the input value(s).
  27. ///
  28. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  29. /// @tparam T Floating-point
  30. /// @tparam Q Value from qualifier enum
  31. ///
  32. /// @see ext_scalar_ulp
  33. template<length_t L, typename T, qualifier Q>
  34. GLM_FUNC_DECL vec<L, T, Q> nextFloat(vec<L, T, Q> const& x);
  35. /// Return the value(s) ULP distance after the input value(s).
  36. ///
  37. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  38. /// @tparam T Floating-point
  39. /// @tparam Q Value from qualifier enum
  40. ///
  41. /// @see ext_scalar_ulp
  42. template<length_t L, typename T, qualifier Q>
  43. GLM_FUNC_DECL vec<L, T, Q> nextFloat(vec<L, T, Q> const& x, int ULPs);
  44. /// Return the value(s) ULP distance after the input value(s).
  45. ///
  46. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  47. /// @tparam T Floating-point
  48. /// @tparam Q Value from qualifier enum
  49. ///
  50. /// @see ext_scalar_ulp
  51. template<length_t L, typename T, qualifier Q>
  52. GLM_FUNC_DECL vec<L, T, Q> nextFloat(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs);
  53. /// Return the previous ULP value(s) before the input value(s).
  54. ///
  55. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  56. /// @tparam T Floating-point
  57. /// @tparam Q Value from qualifier enum
  58. ///
  59. /// @see ext_scalar_ulp
  60. template<length_t L, typename T, qualifier Q>
  61. GLM_FUNC_DECL vec<L, T, Q> prevFloat(vec<L, T, Q> const& x);
  62. /// Return the value(s) ULP distance before the input value(s).
  63. ///
  64. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  65. /// @tparam T Floating-point
  66. /// @tparam Q Value from qualifier enum
  67. ///
  68. /// @see ext_scalar_ulp
  69. template<length_t L, typename T, qualifier Q>
  70. GLM_FUNC_DECL vec<L, T, Q> prevFloat(vec<L, T, Q> const& x, int ULPs);
  71. /// Return the value(s) ULP distance before the input value(s).
  72. ///
  73. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  74. /// @tparam T Floating-point
  75. /// @tparam Q Value from qualifier enum
  76. ///
  77. /// @see ext_scalar_ulp
  78. template<length_t L, typename T, qualifier Q>
  79. GLM_FUNC_DECL vec<L, T, Q> prevFloat(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs);
  80. /// Return the distance in the number of ULP between 2 single-precision floating-point scalars.
  81. ///
  82. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  83. /// @tparam Q Value from qualifier enum
  84. ///
  85. /// @see ext_scalar_ulp
  86. template<length_t L, typename T, qualifier Q>
  87. GLM_FUNC_DECL vec<L, int, Q> floatDistance(vec<L, float, Q> const& x, vec<L, float, Q> const& y);
  88. /// Return the distance in the number of ULP between 2 double-precision floating-point scalars.
  89. ///
  90. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  91. /// @tparam Q Value from qualifier enum
  92. ///
  93. /// @see ext_scalar_ulp
  94. template<length_t L, typename T, qualifier Q>
  95. GLM_FUNC_DECL vec<L, int64, Q> floatDistance(vec<L, double, Q> const& x, vec<L, double, Q> const& y);
  96. /// @}
  97. }//namespace glm
  98. #include "vector_ulp.inl"