Lines Matching refs:Half
12 #include <Eigen/src/Core/arch/CUDA/Half.h>
14 // Make sure it's possible to forward declare Eigen::half
16 struct half;
19 using Eigen::half;
26 VERIFY_IS_EQUAL(half(1.0f).x, 0x3c00);
27 VERIFY_IS_EQUAL(half(0.5f).x, 0x3800);
28 VERIFY_IS_EQUAL(half(0.33333f).x, 0x3555);
29 VERIFY_IS_EQUAL(half(0.0f).x, 0x0000);
30 VERIFY_IS_EQUAL(half(-0.0f).x, 0x8000);
31 VERIFY_IS_EQUAL(half(65504.0f).x, 0x7bff);
32 VERIFY_IS_EQUAL(half(65536.0f).x, 0x7c00); // Becomes infinity.
35 VERIFY_IS_EQUAL(half(-5.96046e-08f).x, 0x8001);
36 VERIFY_IS_EQUAL(half(5.96046e-08f).x, 0x0001);
37 VERIFY_IS_EQUAL(half(1.19209e-07f).x, 0x0002);
40 float val1 = float(half(__half(0x3c00)));
41 float val2 = float(half(__half(0x3c01)));
42 float val3 = float(half(__half(0x3c02)));
43 VERIFY_IS_EQUAL(half(0.5f * (val1 + val2)).x, 0x3c00);
44 VERIFY_IS_EQUAL(half(0.5f * (val2 + val3)).x, 0x3c02);
47 VERIFY_IS_EQUAL(half(-1).x, 0xbc00);
48 VERIFY_IS_EQUAL(half(0).x, 0x0000);
49 VERIFY_IS_EQUAL(half(1).x, 0x3c00);
50 VERIFY_IS_EQUAL(half(2).x, 0x4000);
51 VERIFY_IS_EQUAL(half(3).x, 0x4200);
54 VERIFY_IS_EQUAL(half(false).x, 0x0000);
55 VERIFY_IS_EQUAL(half(true).x, 0x3c00);
58 VERIFY_IS_EQUAL(float(half(__half(0x0000))), 0.0f);
59 VERIFY_IS_EQUAL(float(half(__half(0x3c00))), 1.0f);
62 VERIFY_IS_APPROX(float(half(__half(0x8001))), -5.96046e-08f);
63 VERIFY_IS_APPROX(float(half(__half(0x0001))), 5.96046e-08f);
64 VERIFY_IS_APPROX(float(half(__half(0x0002))), 1.19209e-07f);
67 VERIFY(!(numext::isinf)(float(half(65504.0f)))); // Largest finite number.
68 VERIFY(!(numext::isnan)(float(half(0.0f))));
69 VERIFY((numext::isinf)(float(half(__half(0xfc00)))));
70 VERIFY((numext::isnan)(float(half(__half(0xfc01)))));
71 VERIFY((numext::isinf)(float(half(__half(0x7c00)))));
72 VERIFY((numext::isnan)(float(half(__half(0x7c01)))));
76 VERIFY((numext::isnan)(float(half(0.0 / 0.0))));
77 VERIFY((numext::isinf)(float(half(1.0 / 0.0))));
78 VERIFY((numext::isinf)(float(half(-1.0 / 0.0))));
81 // Exactly same checks as above, just directly on the half representation.
82 VERIFY(!(numext::isinf)(half(__half(0x7bff))));
83 VERIFY(!(numext::isnan)(half(__half(0x0000))));
84 VERIFY((numext::isinf)(half(__half(0xfc00))));
85 VERIFY((numext::isnan)(half(__half(0xfc01))));
86 VERIFY((numext::isinf)(half(__half(0x7c00))));
87 VERIFY((numext::isnan)(half(__half(0x7c01))));
91 VERIFY((numext::isnan)(half(0.0 / 0.0)));
92 VERIFY((numext::isinf)(half(1.0 / 0.0)));
93 VERIFY((numext::isinf)(half(-1.0 / 0.0)));
99 std::cout << "epsilon = " << NumTraits<half>::epsilon() << " (0x" << std::hex << NumTraits<half>::epsilon().x << ")" << std::endl;
100 std::cout << "highest = " << NumTraits<half>::highest() << " (0x" << std::hex << NumTraits<half>::highest().x << ")" << std::endl;
101 std::cout << "lowest = " << NumTraits<half>::lowest() << " (0x" << std::hex << NumTraits<half>::lowest().x << ")" << std::endl;
102 std::cout << "min = " << (std::numeric_limits<half>::min)() << " (0x" << std::hex << half((std::numeric_limits<half>::min)()).x << ")" << std::endl;
103 std::cout << "denorm min = " << (std::numeric_limits<half>::denorm_min)() << " (0x" << std::hex << half((std::numeric_limits<half>::denorm_min)()).x << ")" << std::endl;
104 std::cout << "infinity = " << NumTraits<half>::infinity() << " (0x" << std::hex << NumTraits<half>::infinity().x << ")" << std::endl;
105 std::cout << "quiet nan = " << NumTraits<half>::quiet_NaN() << " (0x" << std::hex << NumTraits<half>::quiet_NaN().x << ")" << std::endl;
106 std::cout << "signaling nan = " << std::numeric_limits<half>::signaling_NaN() << " (0x" << std::hex << std::numeric_limits<half>::signaling_NaN().x << ")" << std::endl;
108 VERIFY(NumTraits<half>::IsSigned);
110 VERIFY_IS_EQUAL( std::numeric_limits<half>::infinity().x, half(std::numeric_limits<float>::infinity()).x );
111 VERIFY_IS_EQUAL( std::numeric_limits<half>::quiet_NaN().x, half(std::numeric_limits<float>::quiet_NaN()).x );
112 VERIFY_IS_EQUAL( std::numeric_limits<half>::signaling_NaN().x, half(std::numeric_limits<float>::signaling_NaN()).x );
113 VERIFY( (std::numeric_limits<half>::min)() > half(0.f) );
114 VERIFY( (std::numeric_limits<half>::denorm_min)() > half(0.f) );
115 VERIFY( (std::numeric_limits<half>::min)()/half(2) > half(0.f) );
116 VERIFY_IS_EQUAL( (std::numeric_limits<half>::denorm_min)()/half(2), half(0.f) );
121 VERIFY_IS_EQUAL(float(half(2) + half(2)), 4);
122 VERIFY_IS_EQUAL(float(half(2) + half(-2)), 0);
123 VERIFY_IS_APPROX(float(half(0.33333f) + half(0.66667f)), 1.0f);
124 VERIFY_IS_EQUAL(float(half(2.0f) * half(-5.5f)), -11.0f);
125 VERIFY_IS_APPROX(float(half(1.0f) / half(3.0f)), 0.33333f);
126 VERIFY_IS_EQUAL(float(-half(4096.0f)), -4096.0f);
127 VERIFY_IS_EQUAL(float(-half(-4096.0f)), 4096.0f);
132 VERIFY(half(1.0f) > half(0.5f));
133 VERIFY(half(0.5f) < half(1.0f));
134 VERIFY(!(half(1.0f) < half(0.5f)));
135 VERIFY(!(half(0.5f) > half(1.0f)));
137 VERIFY(!(half(4.0f) > half(4.0f)));
138 VERIFY(!(half(4.0f) < half(4.0f)));
140 VERIFY(!(half(0.0f) < half(-0.0f)));
141 VERIFY(!(half(-0.0f) < half(0.0f)));
142 VERIFY(!(half(0.0f) > half(-0.0f)));
143 VERIFY(!(half(-0.0f) > half(0.0f)));
145 VERIFY(half(0.2f) > half(-1.0f));
146 VERIFY(half(-1.0f) < half(0.2f));
147 VERIFY(half(-16.0f) < half(-15.0f));
149 VERIFY(half(1.0f) == half(1.0f));
150 VERIFY(half(1.0f) != half(2.0f));
155 VERIFY(!(half(0.0 / 0.0) == half(0.0 / 0.0)));
156 VERIFY(half(0.0 / 0.0) != half(0.0 / 0.0));
158 VERIFY(!(half(1.0) == half(0.0 / 0.0)));
159 VERIFY(!(half(1.0) < half(0.0 / 0.0)));
160 VERIFY(!(half(1.0) > half(0.0 / 0.0)));
161 VERIFY(half(1.0) != half(0.0 / 0.0));
163 VERIFY(half(1.0) < half(1.0 / 0.0));
164 VERIFY(half(1.0) > half(-1.0 / 0.0));
170 VERIFY_IS_EQUAL(float(numext::abs(half(3.5f))), 3.5f);
171 VERIFY_IS_EQUAL(float(abs(half(3.5f))), 3.5f);
172 VERIFY_IS_EQUAL(float(numext::abs(half(-3.5f))), 3.5f);
173 VERIFY_IS_EQUAL(float(abs(half(-3.5f))), 3.5f);
175 VERIFY_IS_EQUAL(float(numext::floor(half(3.5f))), 3.0f);
176 VERIFY_IS_EQUAL(float(floor(half(3.5f))), 3.0f);
177 VERIFY_IS_EQUAL(float(numext::floor(half(-3.5f))), -4.0f);
178 VERIFY_IS_EQUAL(float(floor(half(-3.5f))), -4.0f);
180 VERIFY_IS_EQUAL(float(numext::ceil(half(3.5f))), 4.0f);
181 VERIFY_IS_EQUAL(float(ceil(half(3.5f))), 4.0f);
182 VERIFY_IS_EQUAL(float(numext::ceil(half(-3.5f))), -3.0f);
183 VERIFY_IS_EQUAL(float(ceil(half(-3.5f))), -3.0f);
185 VERIFY_IS_APPROX(float(numext::sqrt(half(0.0f))), 0.0f);
186 VERIFY_IS_APPROX(float(sqrt(half(0.0f))), 0.0f);
187 VERIFY_IS_APPROX(float(numext::sqrt(half(4.0f))), 2.0f);
188 VERIFY_IS_APPROX(float(sqrt(half(4.0f))), 2.0f);
190 VERIFY_IS_APPROX(float(numext::pow(half(0.0f), half(1.0f))), 0.0f);
191 VERIFY_IS_APPROX(float(pow(half(0.0f), half(1.0f))), 0.0f);
192 VERIFY_IS_APPROX(float(numext::pow(half(2.0f), half(2.0f))), 4.0f);
193 VERIFY_IS_APPROX(float(pow(half(2.0f), half(2.0f))), 4.0f);
195 VERIFY_IS_EQUAL(float(numext::exp(half(0.0f))), 1.0f);
196 VERIFY_IS_EQUAL(float(exp(half(0.0f))), 1.0f);
197 VERIFY_IS_APPROX(float(numext::exp(half(EIGEN_PI))), 20.f + float(EIGEN_PI));
198 VERIFY_IS_APPROX(float(exp(half(EIGEN_PI))), 20.f + float(EIGEN_PI));
200 VERIFY_IS_EQUAL(float(numext::log(half(1.0f))), 0.0f);
201 VERIFY_IS_EQUAL(float(log(half(1.0f))), 0.0f);
202 VERIFY_IS_APPROX(float(numext::log(half(10.0f))), 2.30273f);
203 VERIFY_IS_APPROX(float(log(half(10.0f))), 2.30273f);
205 VERIFY_IS_EQUAL(float(numext::log1p(half(0.0f))), 0.0f);
206 VERIFY_IS_EQUAL(float(log1p(half(0.0f))), 0.0f);
207 VERIFY_IS_APPROX(float(numext::log1p(half(10.0f))), 2.3978953f);
208 VERIFY_IS_APPROX(float(log1p(half(10.0f))), 2.3978953f);
213 VERIFY_IS_APPROX(numext::cos(half(0.0f)), half(cosf(0.0f)));
214 VERIFY_IS_APPROX(cos(half(0.0f)), half(cosf(0.0f)));
215 VERIFY_IS_APPROX(numext::cos(half(EIGEN_PI)), half(cosf(EIGEN_PI)));
216 //VERIFY_IS_APPROX(numext::cos(half(EIGEN_PI/2)), half(cosf(EIGEN_PI/2)));
217 //VERIFY_IS_APPROX(numext::cos(half(3*EIGEN_PI/2)), half(cosf(3*EIGEN_PI/2)));
218 VERIFY_IS_APPROX(numext::cos(half(3.5f)), half(cosf(3.5f)));
220 VERIFY_IS_APPROX(numext::sin(half(0.0f)), half(sinf(0.0f)));
221 VERIFY_IS_APPROX(sin(half(0.0f)), half(sinf(0.0f)));
222 // VERIFY_IS_APPROX(numext::sin(half(EIGEN_PI)), half(sinf(EIGEN_PI)));
223 VERIFY_IS_APPROX(numext::sin(half(EIGEN_PI/2)), half(sinf(EIGEN_PI/2)));
224 VERIFY_IS_APPROX(numext::sin(half(3*EIGEN_PI/2)), half(sinf(3*EIGEN_PI/2)));
225 VERIFY_IS_APPROX(numext::sin(half(3.5f)), half(sinf(3.5f)));
227 VERIFY_IS_APPROX(numext::tan(half(0.0f)), half(tanf(0.0f)));
228 VERIFY_IS_APPROX(tan(half(0.0f)), half(tanf(0.0f)));
229 // VERIFY_IS_APPROX(numext::tan(half(EIGEN_PI)), half(tanf(EIGEN_PI)));
230 // VERIFY_IS_APPROX(numext::tan(half(EIGEN_PI/2)), half(tanf(EIGEN_PI/2)));
231 //VERIFY_IS_APPROX(numext::tan(half(3*EIGEN_PI/2)), half(tanf(3*EIGEN_PI/2)));
232 VERIFY_IS_APPROX(numext::tan(half(3.5f)), half(tanf(3.5f)));
237 typedef Array<half,1,Dynamic> ArrayXh;
241 VERIFY_IS_APPROX( a1+a1, half(2)*a1 );
242 VERIFY( (a1.abs() >= half(0)).all() );
246 a1(i) = half(-10.);
247 VERIFY_IS_EQUAL( a1.minCoeff(), half(-10.) );
248 a1(i) = half(10.);
249 VERIFY_IS_EQUAL( a1.maxCoeff(), half(10.) );