+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "nncc/foundation/math/Float.h"
-
-#include <cmath>
-#include <cfloat>
-#include <algorithm>
-
-namespace nncc
-{
-namespace foundation
-{
-namespace math
-{
-
-bool relative_epsilon_equal(float lhs, float rhs, unsigned tolerance)
-{
- if (std::isnan(lhs) && std::isnan(rhs))
- {
- return true;
- }
-
- const auto delta = std::fabs(lhs - rhs);
- const auto max = std::max(std::fabs(lhs), std::fabs(rhs));
-
- return delta <= (max * FLT_EPSILON * tolerance);
-}
-
-bool absolute_epsilon_equal(float lhs, float rhs, float tolerance)
-{
- if (std::isnan(lhs) && std::isnan(rhs))
- {
- return true;
- }
-
- const auto diff = std::fabs(lhs - rhs);
-
- return diff <= tolerance;
-}
-
-} // namespace math
-} // namespace foundation
-} // namespace nncc
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <nncc/foundation/math/Float.h>
-
-#include <cmath>
-
-#include <gtest/gtest.h>
-
-TEST(FOUNDATION_MATH_FLOAT, relative_epsilon_equal_nan_nan)
-{
- ASSERT_TRUE(nncc::foundation::math::relative_epsilon_equal(NAN, NAN));
-}
-
-TEST(FOUNDATION_MATH_FLOAT, relative_epsilon_equal_num_pos)
-{
- ASSERT_TRUE(nncc::foundation::math::relative_epsilon_equal(1.0f, 1.0f));
-}
-
-TEST(FOUNDATION_MATH_FLOAT, relative_epsilon_equal_num_neg)
-{
- ASSERT_FALSE(nncc::foundation::math::relative_epsilon_equal(1.0f, 2.0f));
-}
-
-TEST(FOUNDATION_MATH_FLOAT, relative_epsilon_equal_tolerance_pos)
-{
- ASSERT_TRUE(nncc::foundation::math::relative_epsilon_equal(1.0f, 1.0f + FLT_EPSILON, 2));
-}
-
-TEST(FOUNDATION_MATH_FLOAT, relative_epsilon_equal_tolerance_neg)
-{
- ASSERT_FALSE(nncc::foundation::math::relative_epsilon_equal(1.0f, 1.0f + 3 * FLT_EPSILON, 2));
-}
-
-TEST(FOUNDATION_MATH_FLOAT, absolute_epsilon_equal_nan_nan)
-{
- ASSERT_TRUE(nncc::foundation::math::absolute_epsilon_equal(NAN, NAN));
-}
-
-TEST(FOUNDATION_MATH_FLOAT, absolute_epsilon_equal_num_pos)
-{
- ASSERT_TRUE(nncc::foundation::math::absolute_epsilon_equal(1.0f, 1.0f));
-}
-
-TEST(FOUNDATION_MATH_FLOAT, absolute_epsilon_equal_num_neg)
-{
- ASSERT_FALSE(nncc::foundation::math::absolute_epsilon_equal(1.0f, 2.0f, 0.001f));
-}
-
-TEST(FOUNDATION_MATH_FLOAT, absolute_epsilon_equal_tolerance_pos)
-{
- ASSERT_TRUE(nncc::foundation::math::absolute_epsilon_equal(1.0f, 1.0f + 0.0001f, 0.001f));
-}
-
-TEST(FOUNDATION_MATH_FLOAT, absolute_epsilon_equal_tolerance_neg)
-{
- ASSERT_FALSE(nncc::foundation::math::absolute_epsilon_equal(1.0f, 1.0f + 0.01f, 0.001f));
-}