From a3c6ce465c98733b7a4f8e6e0a4b2c9e0aba7f2c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Wed, 12 Dec 2018 19:12:46 +0900 Subject: [PATCH] [nncc/foundation] Remove math functions (#2638) These math functions are deprecated by "nike" library. Signed-off-by: Jonghyun Park --- libs/foundation/src/math/Float.cpp | 57 -------------------------- libs/foundation/src/math/Float.test.cpp | 71 --------------------------------- 2 files changed, 128 deletions(-) delete mode 100644 libs/foundation/src/math/Float.cpp delete mode 100644 libs/foundation/src/math/Float.test.cpp diff --git a/libs/foundation/src/math/Float.cpp b/libs/foundation/src/math/Float.cpp deleted file mode 100644 index 417d113..0000000 --- a/libs/foundation/src/math/Float.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 -#include -#include - -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 diff --git a/libs/foundation/src/math/Float.test.cpp b/libs/foundation/src/math/Float.test.cpp deleted file mode 100644 index 4cd62a1..0000000 --- a/libs/foundation/src/math/Float.test.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 - -#include - -#include - -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)); -} -- 2.7.4