Compare commits

...

2 Commits

36 changed files with 453 additions and 304 deletions

View File

@ -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)

View File

@ -1 +1,5 @@
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include "config.hpp"

View File

@ -5,8 +5,10 @@
#ifdef MYXLIB_BUILD_LIBRARIES
#undef MYXLIB_HEADER_ONLY
#define MYXLIB_INLINE inline
#else
#define MYXLIB_HEADER_ONLY
#define MYXLIB_INLINE inline
#endif
#ifdef MYXLIB_HEADER_ONLY

View File

@ -1,7 +1,6 @@
#ifndef MYX_BASE_ENUM_BITWISE_OPERATIONS_HPP_
#define MYX_BASE_ENUM_BITWISE_OPERATIONS_HPP_
#pragma once
#include <type_traits>

View File

@ -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

View File

@ -22,14 +22,14 @@ namespace filesystem {
error "Class CurrentExecutable is supported only in Linux"
#endif
CurrentExecutable::CurrentExecutable() :
MYXLIB_INLINE CurrentExecutable::CurrentExecutable() :
m_procFilePath( QStringLiteral( "/proc/self/exe" ) )
{
m_canonicalFilePath = m_procFilePath.canonicalFilePath();
}
const QFileInfo& CurrentExecutable::canonicalFilePath() const
MYXLIB_INLINE const QFileInfo& CurrentExecutable::canonicalFilePath() const
{
return( m_canonicalFilePath );
}

View File

@ -1,2 +1,5 @@
#include <myx/filesystem/current_executable.hpp>
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <myx/filesystem/current_executable-inl.hpp>

View File

@ -19,9 +19,9 @@ namespace myx {
namespace filesystem {
Paths::Paths() = default;
MYXLIB_INLINE Paths::Paths() = default;
Paths::HierarchyType Paths::getHierarchyType()
MYXLIB_INLINE Paths::HierarchyType Paths::getHierarchyType()
{
QRegExp binUnityRegexp( "/s*bin/unity$" );
QRegExp binRegexp( "/s*bin$" );
@ -170,7 +170,7 @@ Paths::HierarchyType Paths::getHierarchyType()
} // Paths::getHierarchyType
bool Paths::init( const QString& projectDir, const QString& configFileExtension )
MYXLIB_INLINE bool Paths::init( const QString& projectDir, const QString& configFileExtension )
{
m_projectName = projectDir.isEmpty() ? m_currentExecutable.m_canonicalFilePath.fileName()
: projectDir;
@ -214,7 +214,7 @@ bool Paths::init( const QString& projectDir, const QString& configFileExtension
} // Paths::updatePaths
bool Paths::makeDefaultDirectories()
MYXLIB_INLINE bool Paths::makeDefaultDirectories()
{
bool status = true;
@ -226,7 +226,7 @@ bool Paths::makeDefaultDirectories()
}
QString Paths::findConfigFile( const QString& defaultConfigFile )
MYXLIB_INLINE QString Paths::findConfigFile( const QString& defaultConfigFile )
{
if ( !defaultConfigFile.isEmpty() && QFileInfo( defaultConfigFile ).isReadable() )
{
@ -251,103 +251,103 @@ QString Paths::findConfigFile( const QString& defaultConfigFile )
} // Paths::findConfigFile
QDir Paths::executableFileDirectory() const
MYXLIB_INLINE QDir Paths::executableFileDirectory() const
{
return( m_currentExecutable.m_canonicalFilePath.dir() );
}
const QDir& Paths::userConfigDirectory() const
MYXLIB_INLINE const QDir& Paths::userConfigDirectory() const
{
return( m_userConfigDirectory );
}
const QDir& Paths::systemConfigDirectory() const
MYXLIB_INLINE const QDir& Paths::systemConfigDirectory() const
{
return( m_systemConfigDirectory );
}
const QFileInfo& Paths::configFilePath() const
MYXLIB_INLINE const QFileInfo& Paths::configFilePath() const
{
return( m_configFilePath );
}
const QString& Paths::configFileName() const
MYXLIB_INLINE const QString& Paths::configFileName() const
{
return( m_configFileName );
}
const QString& Paths::configFileExtension() const
MYXLIB_INLINE const QString& Paths::configFileExtension() const
{
return( m_configFileExtension );
}
const QDir& Paths::userVarDataDirectory() const
MYXLIB_INLINE const QDir& Paths::userVarDataDirectory() const
{
return( m_userVarDataDirectory );
}
const QDir& Paths::systemVarDataDirectory() const
MYXLIB_INLINE const QDir& Paths::systemVarDataDirectory() const
{
return( m_systemVarDataDirectory );
}
const QDir& Paths::userConstDataDirectory() const
MYXLIB_INLINE const QDir& Paths::userConstDataDirectory() const
{
return( m_userConstDataDirectory );
}
const QDir& Paths::systemConstDataDirectory() const
MYXLIB_INLINE const QDir& Paths::systemConstDataDirectory() const
{
return( m_systemConstDataDirectory );
}
const QDir& Paths::userLogDirectory() const
MYXLIB_INLINE const QDir& Paths::userLogDirectory() const
{
return( m_userLogDirectory );
}
const QDir& Paths::systemLogDirectory() const
MYXLIB_INLINE const QDir& Paths::systemLogDirectory() const
{
return( m_systemLogDirectory );
}
const QDir& Paths::tempDirectory() const
MYXLIB_INLINE const QDir& Paths::tempDirectory() const
{
return( m_tempDirectory );
}
const QDir& Paths::homeDirectory() const
MYXLIB_INLINE const QDir& Paths::homeDirectory() const
{
return( m_homeDirectory );
}
const QString& Paths::projectName() const
MYXLIB_INLINE const QString& Paths::projectName() const
{
return( m_projectName );
}
QString Paths::executableFileName() const
MYXLIB_INLINE QString Paths::executableFileName() const
{
return( m_currentExecutable.m_canonicalFilePath.fileName() );
}
const QFileInfo& Paths::executableFilePath() const
MYXLIB_INLINE const QFileInfo& Paths::executableFilePath() const
{
return( m_currentExecutable.m_canonicalFilePath );
}

View File

@ -1,2 +1,5 @@
#include <myx/filesystem/paths.hpp>
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <myx/filesystem/paths-inl.hpp>

View File

@ -19,9 +19,9 @@ namespace myx {
namespace filesystem {
PathsMT::PathsMT() = default;
MYXLIB_INLINE PathsMT::PathsMT() = default;
PathsMT& PathsMT::instance()
MYXLIB_INLINE PathsMT& PathsMT::instance()
{
volatile PathsMT* localInstance = mInstance.load( std::memory_order_acquire );
if ( localInstance == nullptr )

View File

@ -1,2 +1,5 @@
#include <myx/filesystem/paths_mt.hpp>
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <myx/filesystem/paths_mt-inl.hpp>

View File

@ -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 "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
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

View File

@ -1,3 +1,8 @@
#ifndef MYX_MATH_ALL_HPP_
#define MYX_MATH_ALL_HPP_
#pragma once
#include <myx/math/almost_equal_relative.hpp>
#include <myx/math/almost_equal_relative_and_abs.hpp>
#include <myx/math/almost_equal_ulps.hpp>
@ -6,3 +11,5 @@
#include <myx/math/functions.hpp>
#include <myx/math/radar.hpp>
#include <myx/math/units.hpp>
#endif

View File

@ -0,0 +1,51 @@
#ifndef MYX_MATH_ALMOST_EQUAL_RELATIVE_INL_HPP_
#define MYX_MATH_ALMOST_EQUAL_RELATIVE_INL_HPP_
#pragma once
#ifndef MYXLIB_HEADER_ONLY
#include <myx/math/almost_equal_relative.hpp>
#endif
#include <cmath>
namespace myx {
namespace math {
MYXLIB_INLINE 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 );
}
MYXLIB_INLINE 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
#endif

View File

@ -1,42 +1,5 @@
#include <myx/math/almost_equal_relative.hpp>
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <cmath>
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 <myx/math/almost_equal_relative-inl.hpp>

View File

@ -1,6 +1,10 @@
#ifndef MYX_MATH_ALMOST_EQUAL_RELATIVE_HPP_
#define MYX_MATH_ALMOST_EQUAL_RELATIVE_HPP_
#pragma once
#include <myx/base/config.hpp>
#include <cfloat>
// https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
@ -28,4 +32,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_

View File

@ -0,0 +1,65 @@
#ifndef MYX_MATH_ALMOST_EQUAL_RELATIVE_AND_ABS_INL_HPP_
#define MYX_MATH_ALMOST_EQUAL_RELATIVE_AND_ABS_INL_HPP_
#pragma once
#ifndef MYXLIB_HEADER_ONLY
#include <myx/math/almost_equal_relative_and_abs.hpp>
#endif
#include <cmath>
namespace myx {
namespace math {
MYXLIB_INLINE 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 );
}
MYXLIB_INLINE 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
#endif

View File

@ -1,56 +1,5 @@
#include <myx/math/almost_equal_relative_and_abs.hpp>
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <cmath>
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 <myx/math/almost_equal_relative_and_abs-inl.hpp>

View File

@ -1,6 +1,10 @@
#ifndef MYX_MATH_ALMOST_EQUAL_RELATIVE_AND_ABS_HPP_
#define MYX_MATH_ALMOST_EQUAL_RELATIVE_AND_ABS_HPP_
#pragma once
#include <myx/base/config.hpp>
#include <cfloat>
namespace myx {
@ -28,4 +32,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_

View File

@ -0,0 +1,93 @@
#ifndef MYX_MATH_ALMOST_EQUAL_ULPS_INL_HPP_
#define MYX_MATH_ALMOST_EQUAL_ULPS_INL_HPP_
#pragma once
#ifndef MYXLIB_HEADER_ONLY
#include <myx/math/almost_equal_ulps.hpp>
#endif
#include <myx/math/float_cmp_types.hpp>
#include <cmath>
namespace myx {
namespace math {
MYXLIB_INLINE 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
MYXLIB_INLINE 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
#endif

View File

@ -1,83 +1,5 @@
#include <myx/math/almost_equal_ulps.hpp>
#include <myx/math/float_cmp_types.hpp>
#include <cmath>
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"
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#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 <myx/math/almost_equal_ulps-inl.hpp>

View File

@ -1,6 +1,9 @@
#ifndef MYX_MATH_ALMOST_EQUAL_ULPS_HPP_
#define MYX_MATH_ALMOST_EQUAL_ULPS_HPP_
#pragma once
#include <myx/base/config.hpp>
#include <myx/math/float_cmp_types.hpp>
#include <cmath>
@ -28,4 +31,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_

View File

@ -0,0 +1,87 @@
#ifndef MYX_MATH_ALMOST_EQUAL_ULPS_INL_HPP_
#define MYX_MATH_ALMOST_EQUAL_ULPS_INL_HPP_
#pragma once
#ifndef MYXLIB_HEADER_ONLY
#include <myx/math/almost_equal_ulps_and_abs.hpp>
#endif
#include <myx/math/float_cmp_types.hpp>
#include <cmath>
namespace myx {
namespace math {
MYXLIB_INLINE 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
MYXLIB_INLINE 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
#endif

View File

@ -1,77 +1,5 @@
#include <myx/math/almost_equal_ulps_and_abs.hpp>
#include <myx/math/float_cmp_types.hpp>
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <cmath>
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 <myx/math/almost_equal_ulps_and_abs-inl.hpp>

View File

@ -1,6 +1,10 @@
#ifndef MYX_MATH_ALMOST_EQUAL_ULPS_HPP_
#define MYX_MATH_ALMOST_EQUAL_ULPS_HPP_
#pragma once
#include <myx/base/config.hpp>
namespace myx {
namespace math {
@ -26,4 +30,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_

View File

@ -0,0 +1,18 @@
#ifndef MYX_MATH_CONSTANTS_INL_HPP_
#define MYX_MATH_CONSTANTS_INL_HPP_
#pragma once
#ifndef MYXLIB_HEADER_ONLY
#include <myx/math/constants.hpp>
#endif
namespace myx {
namespace math {
} // namespace math
} // namespace myx
#endif

View File

@ -1,9 +1,5 @@
#include <myx/math/constants.hpp>
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
namespace myx {
namespace math {
} // namespace math
} // namespace myx
#include <myx/math/constants-inl.hpp>

View File

@ -1,6 +1,10 @@
#ifndef MYX_MATH_CONSTANTS_HPP_
#define MYX_MATH_CONSTANTS_HPP_
#pragma once
#include <myx/base/config.hpp>
#include <cmath>
#include <type_traits>
@ -8,11 +12,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_

View File

@ -1,6 +1,8 @@
#ifndef MYX_MATH_FLOAT_CMP_TYPES_HPP_
#define MYX_MATH_FLOAT_CMP_TYPES_HPP_
#pragma once
#include <cstdint>
/**

View File

@ -1,6 +1,8 @@
#ifndef MYX_MATH_FUNCTIONS_HPP_
#define MYX_MATH_FUNCTIONS_HPP_
#pragma once
#include <boost/math/special_functions/pow.hpp>
#include <cmath>
#include <type_traits>

View File

@ -1,6 +1,8 @@
#ifndef MYX_MATH_RADAR_HPP_
#define MYX_MATH_RADAR_HPP_
#pragma once
#include <cmath>
#include <type_traits>

View File

@ -1,6 +1,8 @@
#ifndef MYX_MATH_UNITS_HPP_
#define MYX_MATH_UNITS_HPP_
#pragma once
#include <cmath>
#include <type_traits>
@ -88,5 +90,4 @@ T magnitude_to_decibel( T const& magnitude )
} // namespace myx
#endif // MYX_MATH_UNITS_HPP_

View File

@ -1,6 +1,8 @@
#ifndef MYX_QT_BACKPORTS_HPP_
#define MYX_QT_BACKPORTS_HPP_
#pragma once
#if ( defined ( TARGET_LSB_ID_AstraLinuxSE ) && defined ( TARGET_LSB_CODENAME_smolensk ) )
#define override

View File

@ -17,7 +17,7 @@ namespace myx {
namespace qt {
void append_translators( QTranslatorsList& translators, const QString& appName )
MYXLIB_INLINE void append_translators( QTranslatorsList& translators, const QString& appName )
{
auto* translator = new QTranslator( qApp );

View File

@ -1,2 +1,5 @@
#ifndef MYXLIB_BUILD_LIBRARIES
#error Define MYXLIB_BUILD_LIBRARIES to compile this file.
#endif
#include <myx/qt/translators.hpp>
#include <myx/qt/translators-inl.hpp>

View File

@ -1,5 +1,7 @@
#ifndef MYX_LOG_QT_TRANSLATORS_HPP_
#define MYX_LOG_QT_TRANSLATORS_HPP_
#ifndef MYX_QT_TRANSLATORS_HPP_
#define MYX_QT_TRANSLATORS_HPP_
#pragma once
#include <myx/base/config.hpp>
#include <myx/qt/backports.hpp>
@ -22,4 +24,4 @@ void append_translators( QTranslatorsList& translators, const QString& appName )
#include "translators-inl.hpp"
#endif
#endif // ifndef MYX_LOG_QT_TRANSLATORS_HPP_
#endif // ifndef MYX_QT_TRANSLATORS_HPP_