Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:48:24

0001 #ifndef TOLERANCES_H_
0002 #define TOLERANCES_H_
0003 
0004 /**
0005  * @file Tolerances.h
0006  * @author: Hervé MOUTARDE (SPhN / CEA Saclay)
0007  * @date 3 July 2015
0008  * @version 1.0
0009  */
0010 
0011 #include <string>
0012 
0013 namespace NumA {
0014 
0015 /**
0016  * @class Tolerances
0017  *
0018  * @brief Define absolute and relative tolerances for comparison of real numbers (double) and check if they are positive.
0019  */
0020 class Tolerances {
0021 public:
0022     /**
0023      * Default constructor (tolerances equal to 0).
0024      */
0025     Tolerances();
0026     /**
0027      * Constructor.
0028      * @param absoluteTolerance Absolute tolerance.
0029      * @param relativeTolerance Relative tolerance.
0030      */
0031     Tolerances(double absoluteTolerance, double relativeTolerance);
0032     /**
0033      * Default destructor.
0034      */
0035     virtual ~Tolerances();
0036 
0037     /**
0038      *
0039      * @return Pre-formatted string with the tolerances.
0040      */
0041     std::string toString() const;
0042 
0043     // ##### GETTERS & SETTERS #####
0044 
0045     /**
0046      *
0047      * @return Absolute tolerance.
0048      */
0049     double getAbsoluteTolerance() const;
0050     /**
0051      *
0052      * @return Relative tolerance.
0053      */
0054     double getRelativeTolerance() const;
0055 
0056     /**
0057      *
0058      * @param absoluteTolerance Absolute tolerance.
0059      */
0060     void setAbsoluteTolerance(double absoluteTolerance);
0061     /**
0062      *
0063      * @param relativeTolerance Relative tolerance.
0064      */
0065     void setRelativeTolerance(double relativeTolerance);
0066 
0067 private:
0068     double m_absoluteTolerance; ///< Absolute tolerance.
0069     double m_relativeTolerance; ///< Relative tolerance.
0070 
0071     void testPositivity(const double &tolerance) const; ///< Positivity test.
0072 };
0073 
0074 } // namespace NumA
0075 
0076 #endif /* TOLERANCES_H_ */