master
ブランチ master
VulkanExample / dep / include / glm / gtc / ulp.hpp
5.1 KB、155行 生 Blame 履歴
1/// @ref gtc_ulp
2/// @file glm/gtc/ulp.hpp
3///
4/// @see core (dependence)
5///
6/// @defgroup gtc_ulp GLM_GTC_ulp
7/// @ingroup gtc
8///
9/// Include <glm/gtc/ulp.hpp> to use the features of this extension.
10///
11/// Allow the measurement of the accuracy of a function against a reference
12/// implementation. This extension works on floating-point data and provide results
13/// in ULP.
14
15#pragma once
16
17// Dependencies
18#include "../detail/setup.hpp"
19#include "../detail/qualifier.hpp"
20#include "../detail/_vectorize.hpp"
21#include "../ext/scalar_int_sized.hpp"
22
23#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
24# pragma message("GLM: GLM_GTC_ulp extension included")
25#endif
26
27namespace glm
28{
29 /// @addtogroup gtc_ulp
30 /// @{
31
32 /// Return the next ULP value(s) after the input value(s).
33 ///
34 /// @tparam genType A floating-point scalar type.
35 ///
36 /// @see gtc_ulp
37 template<typename genType>
38 GLM_FUNC_DECL genType next_float(genType x);
39
40 /// Return the previous ULP value(s) before the input value(s).
41 ///
42 /// @tparam genType A floating-point scalar type.
43 ///
44 /// @see gtc_ulp
45 template<typename genType>
46 GLM_FUNC_DECL genType prev_float(genType x);
47
48 /// Return the value(s) ULP distance after the input value(s).
49 ///
50 /// @tparam genType A floating-point scalar type.
51 ///
52 /// @see gtc_ulp
53 template<typename genType>
54 GLM_FUNC_DECL genType next_float(genType x, int ULPs);
55
56 /// Return the value(s) ULP distance before the input value(s).
57 ///
58 /// @tparam genType A floating-point scalar type.
59 ///
60 /// @see gtc_ulp
61 template<typename genType>
62 GLM_FUNC_DECL genType prev_float(genType x, int ULPs);
63
64 /// Return the distance in the number of ULP between 2 single-precision floating-point scalars.
65 ///
66 /// @see gtc_ulp
67 GLM_FUNC_DECL int float_distance(float x, float y);
68
69 /// Return the distance in the number of ULP between 2 double-precision floating-point scalars.
70 ///
71 /// @see gtc_ulp
72 GLM_FUNC_DECL int64 float_distance(double x, double y);
73
74 /// Return the next ULP value(s) after the input value(s).
75 ///
76 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
77 /// @tparam T Floating-point
78 /// @tparam Q Value from qualifier enum
79 ///
80 /// @see gtc_ulp
81 template<length_t L, typename T, qualifier Q>
82 GLM_FUNC_DECL vec<L, T, Q> next_float(vec<L, T, Q> const& x);
83
84 /// Return the value(s) ULP distance after the input value(s).
85 ///
86 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
87 /// @tparam T Floating-point
88 /// @tparam Q Value from qualifier enum
89 ///
90 /// @see gtc_ulp
91 template<length_t L, typename T, qualifier Q>
92 GLM_FUNC_DECL vec<L, T, Q> next_float(vec<L, T, Q> const& x, int ULPs);
93
94 /// Return the value(s) ULP distance after the input value(s).
95 ///
96 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
97 /// @tparam T Floating-point
98 /// @tparam Q Value from qualifier enum
99 ///
100 /// @see gtc_ulp
101 template<length_t L, typename T, qualifier Q>
102 GLM_FUNC_DECL vec<L, T, Q> next_float(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs);
103
104 /// Return the previous ULP value(s) before the input value(s).
105 ///
106 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
107 /// @tparam T Floating-point
108 /// @tparam Q Value from qualifier enum
109 ///
110 /// @see gtc_ulp
111 template<length_t L, typename T, qualifier Q>
112 GLM_FUNC_DECL vec<L, T, Q> prev_float(vec<L, T, Q> const& x);
113
114 /// Return the value(s) ULP distance before the input value(s).
115 ///
116 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
117 /// @tparam T Floating-point
118 /// @tparam Q Value from qualifier enum
119 ///
120 /// @see gtc_ulp
121 template<length_t L, typename T, qualifier Q>
122 GLM_FUNC_DECL vec<L, T, Q> prev_float(vec<L, T, Q> const& x, int ULPs);
123
124 /// Return the value(s) ULP distance before the input value(s).
125 ///
126 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
127 /// @tparam T Floating-point
128 /// @tparam Q Value from qualifier enum
129 ///
130 /// @see gtc_ulp
131 template<length_t L, typename T, qualifier Q>
132 GLM_FUNC_DECL vec<L, T, Q> prev_float(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs);
133
134 /// Return the distance in the number of ULP between 2 single-precision floating-point scalars.
135 ///
136 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
137 /// @tparam Q Value from qualifier enum
138 ///
139 /// @see gtc_ulp
140 template<length_t L, typename T, qualifier Q>
141 GLM_FUNC_DECL vec<L, int, Q> float_distance(vec<L, float, Q> const& x, vec<L, float, Q> const& y);
142
143 /// Return the distance in the number of ULP between 2 double-precision floating-point scalars.
144 ///
145 /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
146 /// @tparam Q Value from qualifier enum
147 ///
148 /// @see gtc_ulp
149 template<length_t L, typename T, qualifier Q>
150 GLM_FUNC_DECL vec<L, int64, Q> float_distance(vec<L, double, Q> const& x, vec<L, double, Q> const& y);
151
152 /// @}
153}//namespace glm
154
155#include "ulp.inl"