⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 floatspecs.h

📁 This library defines basic operation on polynomials, and contains also 3 different roots (zeroes)-fi
💻 H
字号:
#ifndef FLOATSPECS_H
#define FLOATSPECS_H
/** 
*       This program has been developed by Micha雔 Roy.  
*	You have the author's permission to incorporate this code 
*       into your product, royalty free.  

*       The author specifically disclaims all warranties, express or
*       implied, and all liability, including consequential and
*       other indirect damages, for the use of this code, 
*       including liability for infringement of any proprietary
*       rights, and including the warranties of merchantability
*       and fitness for a particular purpose.  And he does not 
*       assume any responsibility for any errors which may 
*       appear in this code nor any responsibility to update it.
*
*   (c) 2005, Michael Roy.  tika1966@yahoo.com
*/
/** 
*   @file floatspecs.h
*
*   FloatSpecs class definition
*
*   @author Michael Roy <a href="mailto:tika1966@yahoo.com">tika1966@yahoo.com</a>
*   @version 1.0
*/

#include <float.h>

/** 
*   defines useful constants for floating-point calculus. 
*
*
*/
template < class Float >
class FloatSpecs {
public:
    Float ETA;      /**< smallest positive floating-point number such that 
                    *    \f$1+\mbox{ETA}>1\f$ */
    Float BASE;     /**< The base of the floating-point number system used */
    Float INFINY;   /**< The largest floating-point number */
    Float SMALNO;   /**< The smallest positive floating-point number */
    Float ARE;      /**< Addition rounding error */
    Float MRE;      /**< Multiplication rounding error */
    Float LOG_BASE; /**< ln(BASE) */

public:
    /** constructor */
    FloatSpecs() {
        initConstants();
    }

private:

    /** Initializes the floating-point constants. */
    void initConstants() {
        getFPSpecs(ETA, INFINY, SMALNO, BASE);
        ARE = ETA;
        MRE = 2 * sqrt(Float(2.0)) * ETA;
        LOG_BASE = log(BASE);
    }

    /** Loads specs for \c float data type. */
    static inline void getFPSpecs(float & eta, float & infiny, float & smalno, float & base) {
        base = FLT_RADIX;
        eta = FLT_EPSILON;
        infiny = FLT_MAX;
        smalno = FLT_MIN;
    }

    /** Loads specs for \c double data type. */
    static inline void getFPSpecs(double & eta, double & infiny, double & smalno, double & base) {
        base = DBL_RADIX;
        eta = DBL_EPSILON;
        infiny = DBL_MAX;
        smalno = DBL_MIN;
    }

    /** Loads specs for \c long \c double data type. */
    static inline void getFPSpecs(long double & eta, long double & infiny, long double & smalno, long double & base) {
        base = LDBL_RADIX;
        eta = LDBL_EPSILON;
        infiny = LDBL_MAX;
        smalno = LDBL_MIN;
    }
};

#endif //FLOATSPECS_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -