Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_math.h


Ignore:
Timestamp:
Nov 3, 2026, 10:53:35 AM (3 weeks ago)
Author:
stuerze
Message:

deprecated functions exchanged libs updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_math.h

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1313#include "qwt_global.h"
    1414
    15 #if defined(_MSC_VER)
    1615/*
    17   Microsoft says:
    18 
    19   Define _USE_MATH_DEFINES before including math.h to expose these macro
    20   definitions for common math constants.  These are placed under an #ifdef
    21   since these commonly-defined names are not part of the C/C++ standards.
    22 */
    23 #define _USE_MATH_DEFINES 1
    24 #endif
    25 
    26 #include <qmath.h>
    27 #include "qwt_global.h"
     16   Microsoft says:
     17
     18   Define _USE_MATH_DEFINES before including math.h to expose these macro
     19   definitions for common math constants.  These are placed under an #ifdef
     20   since these commonly-defined names are not part of the C/C++ standards.
     21 */
     22
     23#ifndef _USE_MATH_DEFINES
     24#define _USE_MATH_DEFINES
     25#define undef_USE_MATH_DEFINES
     26#endif
     27
     28#include <cmath>
     29
     30#ifdef undef_USE_MATH_DEFINES
     31#undef _USE_MATH_DEFINES
     32#undef undef_USE_MATH_DEFINES
     33#endif
     34
     35#ifndef M_E
     36#define M_E ( 2.7182818284590452354 )
     37#endif
     38
     39#ifndef M_LOG2E
     40#define M_LOG2E ( 1.4426950408889634074 )
     41#endif
     42
     43#ifndef M_LOG10E
     44#define M_LOG10E ( 0.43429448190325182765 )
     45#endif
     46
     47#ifndef M_LN2
     48#define M_LN2 ( 0.69314718055994530942 )
     49#endif
     50
     51#ifndef M_LN10
     52#define M_LN10 ( 2.30258509299404568402 )
     53#endif
     54
     55#ifndef M_PI
     56#define M_PI ( 3.14159265358979323846 )
     57#endif
    2858
    2959#ifndef M_PI_2
    30 // For Qt <= 4.8.4 M_PI_2 is not known by MinGW-w64
    31 // when compiling with -std=c++11
    32 #define M_PI_2 (1.57079632679489661923)
    33 #endif
    34 
    35 #ifndef LOG_MIN
    36 //! Minimum value for logarithmic scales
    37 #define LOG_MIN 1.0e-100
    38 #endif
    39 
    40 #ifndef LOG_MAX
    41 //! Maximum value for logarithmic scales
    42 #define LOG_MAX 1.0e100
    43 #endif
    44 
    45 QWT_EXPORT double qwtGetMin( const double *array, int size );
    46 QWT_EXPORT double qwtGetMax( const double *array, int size );
     60#define M_PI_2 ( 1.57079632679489661923 )
     61#endif
     62
     63#ifndef M_PI_4
     64#define M_PI_4 ( 0.78539816339744830962 )
     65#endif
     66
     67#ifndef M_1_PI
     68#define M_1_PI ( 0.31830988618379067154 )
     69#endif
     70
     71#ifndef M_2_PI
     72#define M_2_PI ( 0.63661977236758134308 )
     73#endif
     74
     75#ifndef M_2_SQRTPI
     76#define M_2_SQRTPI ( 1.12837916709551257390 )
     77#endif
     78
     79#ifndef M_SQRT2
     80#define M_SQRT2 ( 1.41421356237309504880 )
     81#endif
     82
     83#ifndef M_SQRT1_2
     84#define M_SQRT1_2 ( 0.70710678118654752440 )
     85#endif
     86
     87#if defined( QT_WARNING_PUSH )
     88    /*
     89        early Qt versions not having QT_WARNING_PUSH is full of warnings
     90        so that we do not care of suppressing those from below
     91     */
     92    QT_WARNING_PUSH
     93    QT_WARNING_DISABLE_CLANG("-Wdouble-promotion")
     94    QT_WARNING_DISABLE_GCC("-Wdouble-promotion")
     95#endif
     96
     97/*
     98    On systems, where qreal is a float you often run into
     99    compiler issues with qMin/qMax.
     100 */
     101
     102//! \return Minimum of a and b.
     103QWT_CONSTEXPR inline float qwtMinF( float a, float b )
     104{
     105    return ( a < b ) ? a : b;
     106}
     107
     108//! \return Minimum of a and b.
     109QWT_CONSTEXPR inline double qwtMinF( double a, double b )
     110{
     111    return ( a < b ) ? a : b;
     112}
     113
     114//! \return Minimum of a and b.
     115QWT_CONSTEXPR inline qreal qwtMinF( float a, double b )
     116{
     117    return ( a < b ) ? a : b;
     118}
     119
     120//! \return Minimum of a and b.
     121QWT_CONSTEXPR inline qreal qwtMinF( double a, float b )
     122{
     123    return ( a < b ) ? a : b;
     124}
     125
     126//! \return Maximum of a and b.
     127QWT_CONSTEXPR inline float qwtMaxF( float a, float b )
     128{
     129    return ( a < b ) ? b : a;
     130}
     131
     132//! \return Maximum of a and b.
     133QWT_CONSTEXPR inline double qwtMaxF( double a, double b )
     134{
     135    return ( a < b ) ? b : a;
     136}
     137
     138//! \return Maximum of a and b.
     139QWT_CONSTEXPR inline qreal qwtMaxF( float a, double b )
     140{
     141    return ( a < b ) ? b : a;
     142}
     143
     144//! \return Maximum of a and b.
     145QWT_CONSTEXPR inline qreal qwtMaxF( double a, float b )
     146{
     147    return ( a < b ) ? b : a;
     148}
     149
     150#if defined( QT_WARNING_POP )
     151    QT_WARNING_POP
     152#endif
    47153
    48154QWT_EXPORT double qwtNormalizeRadians( double radians );
    49155QWT_EXPORT double qwtNormalizeDegrees( double degrees );
     156QWT_EXPORT quint32 qwtRand();
    50157
    51158/*!
    52   \brief Compare 2 values, relative to an interval
    53 
    54   Values are "equal", when :
    55   \f$\cdot value2 - value1 <= abs(intervalSize * 10e^{-6})\f$
    56 
    57   \param value1 First value to compare
    58   \param value2 Second value to compare
    59   \param intervalSize interval size
    60 
    61   \return 0: if equal, -1: if value2 > value1, 1: if value1 > value2
    62 */
     159   \brief Compare 2 values, relative to an interval
     160
     161   Values are "equal", when :
     162   \f$\cdot value2 - value1 <= abs(intervalSize * 10e^{-6})\f$
     163
     164   \param value1 First value to compare
     165   \param value2 Second value to compare
     166   \param intervalSize interval size
     167
     168   \return 0: if equal, -1: if value2 > value1, 1: if value1 > value2
     169 */
    63170inline int qwtFuzzyCompare( double value1, double value2, double intervalSize )
    64171{
    … …  
    72179
    73180    return 0;
    74 }
    75 
    76 
    77 inline bool qwtFuzzyGreaterOrEqual( double d1, double d2 )
    78 {
    79     return ( d1 >= d2 ) || qFuzzyCompare( d1, d2 );
    80 }
    81 
    82 inline bool qwtFuzzyLessOrEqual( double d1, double d2 )
    83 {
    84     return ( d1 <= d2 ) || qFuzzyCompare( d1, d2 );
    85181}
    86182
    … …  
    135231}
    136232
     233/* !
     234   \brief Calculate a value of a cubic polynomial
     235
     236   \param x Value
     237   \param a Cubic coefficient
     238   \param b Quadratic coefficient
     239   \param c Linear coefficient
     240   \param d Constant offset
     241
     242   \return Value of the polyonom for x
     243 */
     244inline double qwtCubicPolynomial( double x,
     245    double a, double b, double c, double d )
     246{
     247    return ( ( ( a * x ) + b ) * x + c ) * x + d;
     248}
     249
    137250//! Translate degrees into radians
    138251inline double qwtRadians( double degrees )
    … …  
    147260}
    148261
    149 #endif
     262/*!
     263    The same as qCeil, but avoids including qmath.h
     264    \return Ceiling of value.
     265 */
     266inline int qwtCeil( qreal value )
     267{
     268    using std::ceil;
     269    return int( ceil( value ) );
     270}
     271/*!
     272    The same as qFloor, but avoids including qmath.h
     273    \return Floor of value.
     274 */
     275inline int qwtFloor( qreal value )
     276{
     277    using std::floor;
     278    return int( floor( value ) );
     279}
     280
     281#endif
Note: See TracChangeset for help on using the changeset viewer.