From d6143953f620deec6999b4eec91177b40659c8d7 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Wed, 22 Apr 2020 20:24:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 +- src/myx/filesystem/CMakeLists.txt | 2 - src/myx/filesystem/current_executable.cpp | 1 - src/myx/filesystem/paths.cpp | 1 - src/myx/filesystem/paths_mt.cpp | 1 - src/myx/math/CMakeLists.txt | 10 ++- src/myx/math/almost_equal_relative-inl.hpp | 44 ++++++++++ src/myx/math/almost_equal_relative.cpp | 43 +--------- src/myx/math/almost_equal_relative.hpp | 6 ++ .../almost_equal_relative_and_abs-inl.hpp | 58 +++++++++++++ .../math/almost_equal_relative_and_abs.cpp | 57 +----------- .../math/almost_equal_relative_and_abs.hpp | 6 ++ src/myx/math/almost_equal_ulps-inl.hpp | 86 +++++++++++++++++++ src/myx/math/almost_equal_ulps.cpp | 84 +----------------- src/myx/math/almost_equal_ulps.hpp | 5 ++ .../math/almost_equal_ulps_and_abs-inl.hpp | 80 +++++++++++++++++ src/myx/math/almost_equal_ulps_and_abs.cpp | 78 +---------------- src/myx/math/almost_equal_ulps_and_abs.hpp | 6 ++ src/myx/math/constants-inl.hpp | 11 +++ src/myx/math/constants.cpp | 10 +-- src/myx/math/constants.hpp | 7 +- 21 files changed, 322 insertions(+), 276 deletions(-) create mode 100644 src/myx/math/almost_equal_relative-inl.hpp create mode 100644 src/myx/math/almost_equal_relative_and_abs-inl.hpp create mode 100644 src/myx/math/almost_equal_ulps-inl.hpp create mode 100644 src/myx/math/almost_equal_ulps_and_abs-inl.hpp create mode 100644 src/myx/math/constants-inl.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c6ef79e..05281a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,7 @@ add_subdirectory(src/myx/base) add_subdirectory(src/myx/filesystem) add_subdirectory(src/myx/qt) add_subdirectory(src/myx/math) -add_subdirectory(src/myx/redis) +# add_subdirectory(src/myx/redis) # Примеры if(MYXLIB_BUILD_EXAMPLES OR MYXLIB_BUILD_EXAMPLES_HO) diff --git a/src/myx/filesystem/CMakeLists.txt b/src/myx/filesystem/CMakeLists.txt index b38ea82..5ac2d98 100644 --- a/src/myx/filesystem/CMakeLists.txt +++ b/src/myx/filesystem/CMakeLists.txt @@ -3,12 +3,10 @@ set(TRGT filesystem) # cmake-format: off # Список файлов исходных текстов -if(NOT MYXLIB_HEADER_ONLY) set(TRGT_cpp ${CMAKE_CURRENT_SOURCE_DIR}/current_executable.cpp ${CMAKE_CURRENT_SOURCE_DIR}/paths.cpp ${CMAKE_CURRENT_SOURCE_DIR}/paths_mt.cpp) -endif() # Список заголовочных файлов set(TRGT_hpp diff --git a/src/myx/filesystem/current_executable.cpp b/src/myx/filesystem/current_executable.cpp index ecbbf76..53c42a4 100644 --- a/src/myx/filesystem/current_executable.cpp +++ b/src/myx/filesystem/current_executable.cpp @@ -1,2 +1 @@ -#include #include diff --git a/src/myx/filesystem/paths.cpp b/src/myx/filesystem/paths.cpp index f8027f4..cbe3512 100644 --- a/src/myx/filesystem/paths.cpp +++ b/src/myx/filesystem/paths.cpp @@ -1,2 +1 @@ -#include #include diff --git a/src/myx/filesystem/paths_mt.cpp b/src/myx/filesystem/paths_mt.cpp index d02def6..d093dae 100644 --- a/src/myx/filesystem/paths_mt.cpp +++ b/src/myx/filesystem/paths_mt.cpp @@ -1,2 +1 @@ -#include #include diff --git a/src/myx/math/CMakeLists.txt b/src/myx/math/CMakeLists.txt index 266b98c..6cbd061 100644 --- a/src/myx/math/CMakeLists.txt +++ b/src/myx/math/CMakeLists.txt @@ -3,7 +3,7 @@ set(TRGT math) # cmake-format: off # Список файлов исходных текстов -set(TRGT_sources +set(TRGT_cpp ${CMAKE_CURRENT_SOURCE_DIR}/almost_equal_relative.cpp ${CMAKE_CURRENT_SOURCE_DIR}/almost_equal_relative_and_abs.cpp ${CMAKE_CURRENT_SOURCE_DIR}/almost_equal_ulps.cpp @@ -14,10 +14,15 @@ set(TRGT_sources set(TRGT_hpp ${CMAKE_CURRENT_SOURCE_DIR}/all.hpp ${CMAKE_CURRENT_SOURCE_DIR}/almost_equal_relative.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/almost_equal_relative-inl.hpp ${CMAKE_CURRENT_SOURCE_DIR}/almost_equal_relative_and_abs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/almost_equal_relative_and_abs-inl.hpp ${CMAKE_CURRENT_SOURCE_DIR}/almost_equal_ulps.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/almost_equal_ulps-inl.hpp ${CMAKE_CURRENT_SOURCE_DIR}/almost_equal_ulps_and_abs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/almost_equal_ulps_and_abs-inl.hpp ${CMAKE_CURRENT_SOURCE_DIR}/constants.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/constants-inl.hpp ${CMAKE_CURRENT_SOURCE_DIR}/float_cmp_types.hpp ${CMAKE_CURRENT_SOURCE_DIR}/functions.hpp ${CMAKE_CURRENT_SOURCE_DIR}/radar.hpp @@ -27,13 +32,14 @@ set(TRGT_headers ${TRGT_hpp}) # cmake-format: on add_library(${TRGT}-header-only INTERFACE) +target_sources(${TRGT}-header-only INTERFACE ${TRGT_headers}) target_include_directories( ${TRGT}-header-only SYSTEM INTERFACE "$" "$") if(MYXLIB_BUILD_LIBRARIES) - add_common_library(${TRGT} OUTPUT_NAME myx-${TRGT} SOURCES ${TRGT_sources} ${TRGT_headers}) + add_common_library(${TRGT} OUTPUT_NAME myx-${TRGT} SOURCES ${TRGT_cpp} ${TRGT_headers}) common_target_properties(${TRGT}) # Создание цели для проверки утилитой clang-tidy diff --git a/src/myx/math/almost_equal_relative-inl.hpp b/src/myx/math/almost_equal_relative-inl.hpp new file mode 100644 index 0000000..fa2a225 --- /dev/null +++ b/src/myx/math/almost_equal_relative-inl.hpp @@ -0,0 +1,44 @@ +#ifndef MYXLIB_HEADER_ONLY +#include +#endif + +#include + +namespace myx { + +namespace math { + +bool almost_equal_relative( const float a, const float b, + const float maxRelDiff ) +{ + float diff = fabsf( a - b ); + float aN = fabsf( a ); + float bN = fabsf( b ); + float largest = ( bN > aN ) ? bN : aN; + + if ( diff <= largest * maxRelDiff ) + { + return( true ); + } + return( false ); +} + + +bool almost_equal_relative( const double a, const double b, + const double maxRelDiff ) +{ + double diff = fabs( a - b ); + double aN = fabs( a ); + double bN = fabs( b ); + double largest = ( bN > aN ) ? bN : aN; + + if ( diff <= largest * maxRelDiff ) + { + return( true ); + } + return( false ); +} + +} // namespace math + +} // namespace myx diff --git a/src/myx/math/almost_equal_relative.cpp b/src/myx/math/almost_equal_relative.cpp index 824c337..bc79e13 100644 --- a/src/myx/math/almost_equal_relative.cpp +++ b/src/myx/math/almost_equal_relative.cpp @@ -1,42 +1 @@ -#include - -#include - -namespace myx { - -namespace math { - -bool almost_equal_relative( const float a, const float b, - const float maxRelDiff ) -{ - float diff = fabsf( a - b ); - float aN = fabsf( a ); - float bN = fabsf( b ); - float largest = ( bN > aN ) ? bN : aN; - - if ( diff <= largest * maxRelDiff ) - { - return( true ); - } - return( false ); -} - - -bool almost_equal_relative( const double a, const double b, - const double maxRelDiff ) -{ - double diff = fabs( a - b ); - double aN = fabs( a ); - double bN = fabs( b ); - double largest = ( bN > aN ) ? bN : aN; - - if ( diff <= largest * maxRelDiff ) - { - return( true ); - } - return( false ); -} - -} // namespace math - -} // namespace myx +#include diff --git a/src/myx/math/almost_equal_relative.hpp b/src/myx/math/almost_equal_relative.hpp index a294761..3fd15ae 100644 --- a/src/myx/math/almost_equal_relative.hpp +++ b/src/myx/math/almost_equal_relative.hpp @@ -1,6 +1,8 @@ #ifndef MYX_MATH_ALMOST_EQUAL_RELATIVE_HPP_ #define MYX_MATH_ALMOST_EQUAL_RELATIVE_HPP_ +#include + #include // https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ @@ -28,4 +30,8 @@ bool almost_equal_relative( double a, double b, } // namespace myx +#ifdef MYXLIB_HEADER_ONLY +#include "almost_equal_relative-inl.hpp" +#endif + #endif // MYX_MATH_ALMOST_EQUAL_RELATIVE_HPP_ diff --git a/src/myx/math/almost_equal_relative_and_abs-inl.hpp b/src/myx/math/almost_equal_relative_and_abs-inl.hpp new file mode 100644 index 0000000..79981f4 --- /dev/null +++ b/src/myx/math/almost_equal_relative_and_abs-inl.hpp @@ -0,0 +1,58 @@ +#ifndef MYXLIB_HEADER_ONLY +#include +#endif + +#include + +namespace myx { + +namespace math { + +bool almost_equal_relative_and_abs( const float a, const float b, + const float maxAbsDiff, const float maxRelDiff ) +{ + // Check if the numbers are really close -- needed + // when comparing numbers near zero. + float diff = fabsf( a - b ); + if ( diff <= maxAbsDiff ) + { + return( true ); + } + + float aN = fabsf( a ); + float bN = fabsf( b ); + float largest = ( bN > aN ) ? bN : aN; + + if ( diff <= largest * maxRelDiff ) + { + return( true ); + } + return( false ); +} + + +bool almost_equal_relative_and_abs( const double a, const double b, + const double maxAbsDiff, const double maxRelDiff ) +{ + // Check if the numbers are really close -- needed + // when comparing numbers near zero. + double diff = fabs( a - b ); + if ( diff <= maxAbsDiff ) + { + return( true ); + } + + double aN = fabs( a ); + double bN = fabs( b ); + double largest = ( bN > aN ) ? bN : aN; + + if ( diff <= largest * maxRelDiff ) + { + return( true ); + } + return( false ); +} + +} // namespace math + +} // namespace myx diff --git a/src/myx/math/almost_equal_relative_and_abs.cpp b/src/myx/math/almost_equal_relative_and_abs.cpp index e3b0401..531587a 100644 --- a/src/myx/math/almost_equal_relative_and_abs.cpp +++ b/src/myx/math/almost_equal_relative_and_abs.cpp @@ -1,56 +1 @@ -#include - -#include - -namespace myx { - -namespace math { - -bool almost_equal_relative_and_abs( const float a, const float b, - const float maxAbsDiff, const float maxRelDiff ) -{ - // Check if the numbers are really close -- needed - // when comparing numbers near zero. - float diff = fabsf( a - b ); - if ( diff <= maxAbsDiff ) - { - return( true ); - } - - float aN = fabsf( a ); - float bN = fabsf( b ); - float largest = ( bN > aN ) ? bN : aN; - - if ( diff <= largest * maxRelDiff ) - { - return( true ); - } - return( false ); -} - - -bool almost_equal_relative_and_abs( const double a, const double b, - const double maxAbsDiff, const double maxRelDiff ) -{ - // Check if the numbers are really close -- needed - // when comparing numbers near zero. - double diff = fabs( a - b ); - if ( diff <= maxAbsDiff ) - { - return( true ); - } - - double aN = fabs( a ); - double bN = fabs( b ); - double largest = ( bN > aN ) ? bN : aN; - - if ( diff <= largest * maxRelDiff ) - { - return( true ); - } - return( false ); -} - -} // namespace math - -} // namespace myx +#include diff --git a/src/myx/math/almost_equal_relative_and_abs.hpp b/src/myx/math/almost_equal_relative_and_abs.hpp index a4fc095..078a7cd 100644 --- a/src/myx/math/almost_equal_relative_and_abs.hpp +++ b/src/myx/math/almost_equal_relative_and_abs.hpp @@ -1,6 +1,8 @@ #ifndef MYX_MATH_ALMOST_EQUAL_RELATIVE_AND_ABS_HPP_ #define MYX_MATH_ALMOST_EQUAL_RELATIVE_AND_ABS_HPP_ +#include + #include namespace myx { @@ -28,4 +30,8 @@ bool almost_equal_relative_and_abs( double a, double b, } // namespace myx +#ifdef MYXLIB_HEADER_ONLY +#include "almost_equal_relative_and_abs-inl.hpp" +#endif + #endif // MYX_MATH_ALMOST_EQUAL_RELATIVE_AND_ABS_HPP_ diff --git a/src/myx/math/almost_equal_ulps-inl.hpp b/src/myx/math/almost_equal_ulps-inl.hpp new file mode 100644 index 0000000..702ed8f --- /dev/null +++ b/src/myx/math/almost_equal_ulps-inl.hpp @@ -0,0 +1,86 @@ +#ifndef MYXLIB_HEADER_ONLY +#include +#endif + +#include + +#include + +namespace myx { + +namespace math { + +bool almost_equal_ulps( const float a, const float b, + const int maxUlpsDiff ) +{ + FloatCmp uA( a ); + FloatCmp uB( b ); + + // Если знаки разные, то числа не равны. + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) + if ( uA.negative() != uB.negative() ) + { + // Кроме случая, когда +0==-0 + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" + #endif + if ( a == b ) // -V550 + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif + { + return( true ); + } + return( false ); + } + + // Разница в младших битах. + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) + auto ulpsDiff = std::abs( uA.i - uB.i ); + if ( ulpsDiff <= maxUlpsDiff ) + { + return( true ); + } + return( false ); +} // almost_equal_ulps + + +bool almost_equal_ulps( const double a, const double b, + const int maxUlpsDiff ) +{ + DoubleCmp uA( a ); + DoubleCmp uB( b ); + + // Если знаки разные, то числа не равны. + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) + if ( uA.negative() != uB.negative() ) + { + // Кроме случая, когда +0==-0 + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" + #endif + if ( a == b ) // -V550 + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif + { + return( true ); + } + return( false ); + } + + // Разница в младших битах. + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) + auto ulpsDiff = std::abs( uA.i - uB.i ); + if ( ulpsDiff <= maxUlpsDiff ) + { + return( true ); + } + return( false ); +} // almost_equal_ulps + +} // namespace math + +} // namespace myx diff --git a/src/myx/math/almost_equal_ulps.cpp b/src/myx/math/almost_equal_ulps.cpp index 9beb2d6..772dffd 100644 --- a/src/myx/math/almost_equal_ulps.cpp +++ b/src/myx/math/almost_equal_ulps.cpp @@ -1,83 +1 @@ -#include -#include - -#include - -namespace myx { - -namespace math { - -bool almost_equal_ulps( const float a, const float b, - const int maxUlpsDiff ) -{ - FloatCmp uA( a ); - FloatCmp uB( b ); - - // Если знаки разные, то числа не равны. - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) - if ( uA.negative() != uB.negative() ) - { - // Кроме случая, когда +0==-0 - #ifdef __GNUC__ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wfloat-equal" - #endif - if ( a == b ) // -V550 - #ifdef __GNUC__ - #pragma GCC diagnostic pop - #endif - { - return( true ); - } - return( false ); - } - - // Разница в младших битах. - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) - auto ulpsDiff = std::abs( uA.i - uB.i ); - if ( ulpsDiff <= maxUlpsDiff ) - { - return( true ); - } - return( false ); -} // almost_equal_ulps - - -bool almost_equal_ulps( const double a, const double b, - const int maxUlpsDiff ) -{ - DoubleCmp uA( a ); - DoubleCmp uB( b ); - - // Если знаки разные, то числа не равны. - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) - if ( uA.negative() != uB.negative() ) - { - // Кроме случая, когда +0==-0 - #ifdef __GNUC__ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wfloat-equal" - #endif - if ( a == b ) // -V550 - #ifdef __GNUC__ - #pragma GCC diagnostic pop - #endif - { - return( true ); - } - return( false ); - } - - // Разница в младших битах. - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) - auto ulpsDiff = std::abs( uA.i - uB.i ); - if ( ulpsDiff <= maxUlpsDiff ) - { - return( true ); - } - return( false ); -} // almost_equal_ulps - -} // namespace math - -} // namespace myx +#include diff --git a/src/myx/math/almost_equal_ulps.hpp b/src/myx/math/almost_equal_ulps.hpp index afdb99d..5d4cc75 100644 --- a/src/myx/math/almost_equal_ulps.hpp +++ b/src/myx/math/almost_equal_ulps.hpp @@ -1,6 +1,7 @@ #ifndef MYX_MATH_ALMOST_EQUAL_ULPS_HPP_ #define MYX_MATH_ALMOST_EQUAL_ULPS_HPP_ +#include #include #include @@ -28,4 +29,8 @@ bool almost_equal_ulps( double a, double b, } // namespace myx +#ifdef MYXLIB_HEADER_ONLY +#include "almost_equal_ulps-inl.hpp" +#endif + #endif // MYX_MATH_ALMOST_EQUAL_ULPS_HPP_ diff --git a/src/myx/math/almost_equal_ulps_and_abs-inl.hpp b/src/myx/math/almost_equal_ulps_and_abs-inl.hpp new file mode 100644 index 0000000..bca19ec --- /dev/null +++ b/src/myx/math/almost_equal_ulps_and_abs-inl.hpp @@ -0,0 +1,80 @@ +#ifndef MYXLIB_HEADER_ONLY +#include +#endif + +#include + +#include + +namespace myx { + +namespace math { + +bool almost_equal_ulps_and_abs( const float a, const float b, + const float maxAbsDiff, const int maxUlpsDiff ) +{ + // Check if the numbers are really close -- needed + // when comparing numbers near zero. + float absDiff = fabsf( a - b ); + if ( absDiff <= maxAbsDiff ) + { + return( true ); + } + + FloatCmp uA( a ); + FloatCmp uB( b ); + + // Different signs means they do not match. + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) + if ( uA.negative() != uB.negative() ) + { + return( false ); + } + + // Find the difference in ULPs. + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) + int ulpsDiff = std::abs( uA.i - uB.i ); + if ( ulpsDiff <= maxUlpsDiff ) + { + return( true ); + } + + return( false ); +} // almost_equal_ulps_and_abs + + +bool almost_equal_ulps_and_abs( const double a, const double b, + const double maxAbsDiff, const int maxUlpsDiff ) +{ + // Check if the numbers are really close -- needed + // when comparing numbers near zero. + double absDiff = fabs( a - b ); + if ( absDiff <= maxAbsDiff ) + { + return( true ); + } + + DoubleCmp uA( a ); + DoubleCmp uB( b ); + + // Different signs means they do not match. + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) + if ( uA.negative() != uB.negative() ) + { + return( false ); + } + + // Find the difference in ULPs. + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) + auto ulpsDiff = std::abs( uA.i - uB.i ); + if ( ulpsDiff <= maxUlpsDiff ) + { + return( true ); + } + + return( false ); +} // almost_equal_ulps_and_abs + +} // namespace math + +} // namespace myx diff --git a/src/myx/math/almost_equal_ulps_and_abs.cpp b/src/myx/math/almost_equal_ulps_and_abs.cpp index 09c98f6..a4cfadb 100644 --- a/src/myx/math/almost_equal_ulps_and_abs.cpp +++ b/src/myx/math/almost_equal_ulps_and_abs.cpp @@ -1,77 +1 @@ -#include -#include - -#include - -namespace myx { - -namespace math { - -bool almost_equal_ulps_and_abs( const float a, const float b, - const float maxAbsDiff, const int maxUlpsDiff ) -{ - // Check if the numbers are really close -- needed - // when comparing numbers near zero. - float absDiff = fabsf( a - b ); - if ( absDiff <= maxAbsDiff ) - { - return( true ); - } - - FloatCmp uA( a ); - FloatCmp uB( b ); - - // Different signs means they do not match. - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) - if ( uA.negative() != uB.negative() ) - { - return( false ); - } - - // Find the difference in ULPs. - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) - int ulpsDiff = std::abs( uA.i - uB.i ); - if ( ulpsDiff <= maxUlpsDiff ) - { - return( true ); - } - - return( false ); -} // almost_equal_ulps_and_abs - - -bool almost_equal_ulps_and_abs( const double a, const double b, - const double maxAbsDiff, const int maxUlpsDiff ) -{ - // Check if the numbers are really close -- needed - // when comparing numbers near zero. - double absDiff = fabs( a - b ); - if ( absDiff <= maxAbsDiff ) - { - return( true ); - } - - DoubleCmp uA( a ); - DoubleCmp uB( b ); - - // Different signs means they do not match. - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) - if ( uA.negative() != uB.negative() ) - { - return( false ); - } - - // Find the difference in ULPs. - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) - auto ulpsDiff = std::abs( uA.i - uB.i ); - if ( ulpsDiff <= maxUlpsDiff ) - { - return( true ); - } - - return( false ); -} // almost_equal_ulps_and_abs - -} // namespace math - -} // namespace myx +#include diff --git a/src/myx/math/almost_equal_ulps_and_abs.hpp b/src/myx/math/almost_equal_ulps_and_abs.hpp index abf3ee4..f141795 100644 --- a/src/myx/math/almost_equal_ulps_and_abs.hpp +++ b/src/myx/math/almost_equal_ulps_and_abs.hpp @@ -1,6 +1,8 @@ #ifndef MYX_MATH_ALMOST_EQUAL_ULPS_HPP_ #define MYX_MATH_ALMOST_EQUAL_ULPS_HPP_ +#include + namespace myx { namespace math { @@ -26,4 +28,8 @@ bool almost_equal_ulps_and_abs( double a, double b, } // namespace myx +#ifdef MYXLIB_HEADER_ONLY +#include "almost_equal_ulps_and_abs-inl.hpp" +#endif + #endif // MYX_MATH_ALMOST_EQUAL_ULPS_HPP_ diff --git a/src/myx/math/constants-inl.hpp b/src/myx/math/constants-inl.hpp new file mode 100644 index 0000000..eb22bee --- /dev/null +++ b/src/myx/math/constants-inl.hpp @@ -0,0 +1,11 @@ +#ifndef MYXLIB_HEADER_ONLY +#include +#endif + +namespace myx { + +namespace math { + +} // namespace math + +} // namespace myx diff --git a/src/myx/math/constants.cpp b/src/myx/math/constants.cpp index 0d35cd7..5351b8f 100644 --- a/src/myx/math/constants.cpp +++ b/src/myx/math/constants.cpp @@ -1,9 +1 @@ -#include - -namespace myx { - -namespace math { - -} // namespace math - -} // namespace myx +#include diff --git a/src/myx/math/constants.hpp b/src/myx/math/constants.hpp index bd2c991..05f16e8 100644 --- a/src/myx/math/constants.hpp +++ b/src/myx/math/constants.hpp @@ -1,6 +1,8 @@ #ifndef MYX_MATH_CONSTANTS_HPP_ #define MYX_MATH_CONSTANTS_HPP_ +#include + #include #include @@ -8,11 +10,14 @@ namespace myx { namespace math { -const auto ImpedanceOfFreeSpace = 376.7303136675757; +const auto ImpedanceOfFreeSpace = (M_PI * 119.9169832); } // namespace math } // namespace myx +#ifdef MYXLIB_HEADER_ONLY +#include "constants-inl.hpp" +#endif #endif // MYX_MATH_CONSTANTS_HPP_