vector_ulp.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. /// Return the next ULP value(s) after the input value(s).
  25. ///
  26. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  27. /// @tparam T Floating-point
  28. /// @tparam Q Value from qualifier enum
  29. ///
  30. /// @see ext_scalar_ulp
  31. template<length_t L, typename T, qualifier Q>
  32. GLM_FUNC_DECL vec<L, T, Q> nextFloat(vec<L, T, Q> const& x);
  33. /// Return the value(s) ULP distance after the input value(s).
  34. ///
  35. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  36. /// @tparam T Floating-point
  37. /// @tparam Q Value from qualifier enum
  38. ///
  39. /// @see ext_scalar_ulp
  40. template<length_t L, typename T, qualifier Q>
  41. GLM_FUNC_DECL vec<L, T, Q> nextFloat(vec<L, T, Q> const& x, int ULPs);
  42. /// Return the value(s) ULP distance after the input value(s).
  43. ///
  44. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  45. /// @tparam T Floating-point
  46. /// @tparam Q Value from qualifier enum
  47. ///
  48. /// @see ext_scalar_ulp
  49. template<length_t L, typename T, qualifier Q>
  50. GLM_FUNC_DECL vec<L, T, Q> nextFloat(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs);
  51. /// Return the previous ULP value(s) before the input value(s).
  52. ///
  53. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  54. /// @tparam T Floating-point
  55. /// @tparam Q Value from qualifier enum
  56. ///
  57. /// @see ext_scalar_ulp
  58. template<length_t L, typename T, qualifier Q>
  59. GLM_FUNC_DECL vec<L, T, Q> prevFloat(vec<L, T, Q> const& x);
  60. /// Return the value(s) ULP distance before the input value(s).
  61. ///
  62. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  63. /// @tparam T Floating-point
  64. /// @tparam Q Value from qualifier enum
  65. ///
  66. /// @see ext_scalar_ulp
  67. template<length_t L, typename T, qualifier Q>
  68. GLM_FUNC_DECL vec<L, T, Q> prevFloat(vec<L, T, Q> const& x, int ULPs);
  69. /// Return the value(s) ULP distance before the input value(s).
  70. ///
  71. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  72. /// @tparam T Floating-point
  73. /// @tparam Q Value from qualifier enum
  74. ///
  75. /// @see ext_scalar_ulp
  76. template<length_t L, typename T, qualifier Q>
  77. GLM_FUNC_DECL vec<L, T, Q> prevFloat(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs);
  78. /// Return the distance in the number of ULP between 2 single-precision floating-point scalars.
  79. ///
  80. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  81. /// @tparam Q Value from qualifier enum
  82. ///
  83. /// @see ext_scalar_ulp
  84. template<length_t L, typename T, qualifier Q>
  85. GLM_FUNC_DECL vec<L, int, Q> floatDistance(vec<L, float, Q> const& x, vec<L, float, Q> const& y);
  86. /// Return the distance in the number of ULP between 2 double-precision floating-point scalars.
  87. ///
  88. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  89. /// @tparam Q Value from qualifier enum
  90. ///
  91. /// @see ext_scalar_ulp
  92. template<length_t L, typename T, qualifier Q>
  93. GLM_FUNC_DECL vec<L, int64, Q> floatDistance(vec<L, double, Q> const& x, vec<L, double, Q> const& y);
  94. /// @}
  95. }//namespace glm
  96. #include "vector_ulp.inl"