File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -219,4 +219,18 @@ TEST(QSharedMathTest, InverseSquareRoot)
219219 EXPECT_THAT (Q_rsqrt (1e6 ), RsqrtEq (1e-3 ));
220220}
221221
222+ TEST (QSharedMathTest, FastInverseSquareRoot)
223+ {
224+ constexpr float relativeTolerance = 6.50196699e-4 ;
225+ auto RsqrtEq = [=](float expected) { return FloatNear (expected, expected * relativeTolerance); };
226+
227+ EXPECT_THAT (Q_rsqrt_fast (1e-6 ), RsqrtEq (1e3 ));
228+ EXPECT_THAT (Q_rsqrt_fast (0.036 ), RsqrtEq (5.270463 ));
229+ EXPECT_THAT (Q_rsqrt_fast (0.2 ), RsqrtEq (2.236068 ));
230+ EXPECT_THAT (Q_rsqrt_fast (1 ), RsqrtEq (1 ));
231+ EXPECT_THAT (Q_rsqrt_fast (3 ), RsqrtEq (0.5773503 ));
232+ EXPECT_THAT (Q_rsqrt_fast (29.1 ), RsqrtEq (0.1853760 ));
233+ EXPECT_THAT (Q_rsqrt_fast (1e6 ), RsqrtEq (1e-3 ));
234+ }
235+
222236} // namespace
You can’t perform that action at this time.
0 commit comments