Commit dbc2560a authored by Nabil Chouika's avatar Nabil Chouika
Browse files

NumA utils documentation partons/core/partons#4

parent 055454af
......@@ -16,26 +16,57 @@ namespace NumA {
/**
* @class Differences
*
* @brief
* @brief Class defining absolute and relative differences for comparison of real numbers (double).
*/
class Differences {
public:
/**
* Default constructor (differences equal to 0).
*/
Differences();
/**
* Constructor.
* @param absoluteDifference Absolute difference.
* @param relativeDifference Relative difference.
*/
Differences(const double absoluteDifference,
const double relativeDifference);
/**
* Default destructor.
*/
virtual ~Differences();
/**
*
* @return Pre-formatted string with the differences.
*/
std::string toString() const;
/**
*
* @return Absolute difference.
*/
double getAbsoluteDifference() const;
/**
*
* @return Relative difference.
*/
double getRelativeDifference() const;
/**
*
* @param absoluteDifference Absolute difference.
*/
void setAbsoluteDifference(double absoluteDifference);
/**
*
* @param relativeDifference Relative difference.
*/
void setRelativeDifference(double relativeDifference);
private:
double m_absoluteDifference;
double m_relativeDifference;
double m_absoluteDifference; ///< Absolute difference.
double m_relativeDifference; ///< Relative difference.
};
} // namespace NumA
......
......@@ -13,24 +13,51 @@ namespace NumA {
/**
* @class Errors
*
* @brief
* @brief Class for defining estimations of absolute and relative errors.
*/
class Errors {
public:
/**
* Default constructor (errors equal to 0).
*/
Errors();
/**
* Constructor.
* @param absolute Absolute error.
* @param relative Relative error.
*/
Errors(const double absolute, const double relative);
/**
* Default destructor.
*/
virtual ~Errors();
// ##### GETTERS & SETTERS #####
/**
*
* @return Absolute error.
*/
double getAbsolute() const;
/**
*
* @param absolute Absolute error.
*/
void setAbsolute(double absolute);
/**
*
* @return Relative error.
*/
double getRelative() const;
/**
*
* @param relative Relative error.
*/
void setRelative(double relative);
private:
double m_absolute;
double m_relative;
double m_absolute; ///< Absolute error.
double m_relative; ///< Relative error.
};
} /* namespace NumA */
......
......@@ -17,21 +17,38 @@ namespace NumA {
/**
* @class Interval
*
* @brief Class defining an interval (with given bounds and step).
*/
template<typename T>
class Interval {
public:
/**
* Type of interval.
*/
enum StepMode {
NORMAL = 0, LOG = 1
NORMAL = 0, ///< Linear interval.
LOG = 1 ///< Logarithmic interval.
};
/**
* Constructor.
* @param lowerBound Lower bound of the interval.
* @param upperBound Upper bound of the interval.
* @param step Value of the step.
* @param stepMode Type of interval.
*/
Interval(T lowerBound, T upperBound, T step = 1,
Interval::StepMode stepMode = NORMAL) :
m_lowerBound(lowerBound), m_upperBound(upperBound), m_step(step), m_stepMode(
stepMode) {
}
/**
*
* @return Nodes of interval.
*/
std::vector<T> computeSteps() const {
std::vector<T> steps;
......@@ -61,6 +78,14 @@ public:
return steps;
}
/**
* Static function that computes the nodes of an interval for a chosen number of nodes.
* @param lowerBound Lower bound of the interval.
* @param upperBound Upper bound of the interval.
* @param num Number of nodes.
* @param stepMode Type of interval.
* @return Nodes.
*/
static std::vector<T> computeNodes(T lowerBound, T upperBound, size_t num =
10, Interval::StepMode stepMode = NORMAL) {
T node = lowerBound;
......@@ -89,36 +114,60 @@ public:
return nodes;
}
/**
*
* @return Lower bound of the interval.
*/
T getLowerBound() const {
return m_lowerBound;
}
/**
*
* @param lowerBound Lower bound of the interval.
*/
void setLowerBound(T lowerBound) {
this->m_lowerBound = lowerBound;
}
/**
*
* @return Step.
*/
T getStep() const {
return m_step;
}
/**
*
* @param step Value of the step.
*/
void setStep(T step) {
this->m_step = step;
}
/**
*
* @return Upper bound of the interval.
*/
T getUpperBound() const {
return m_upperBound;
}
/**
*
* @param upperBound Upper bound of the interval.
*/
void setUpperBound(T upperBound) {
this->m_upperBound = upperBound;
}
private:
T m_lowerBound;
T m_upperBound;
T m_step;
T m_lowerBound; ///< Lower bound of the interval.
T m_upperBound; ///< Upper bound of the interval.
T m_step; ///< Step.
Interval::StepMode m_stepMode;
Interval::StepMode m_stepMode; ///< Type of interval.
};
} /* namespace NumA */
......
......@@ -13,11 +13,21 @@ namespace NumA {
/**
* @class MathUtils
*
* @brief
* @brief Miscellaneous utilities (mathematical functions, etc).
*/
class MathUtils {
public:
/**
* Degree-radian conversion.
* @param degree Angle in degree.
* @return Angle in radian.
*/
static double convertDegreeToRadian(double degree);
/**
* DiLograrithm function.
* @param x
* @return \f$ Li_2\left(x\right) \f$.
*/
static double DiLog(double x);
};
......
......@@ -15,29 +15,60 @@ namespace NumA {
/**
* @class Tolerances
*
* @brief Define absolute and relative tolerance for comparison of real numbers (double) and check they are positive.
* @brief Define absolute and relative tolerances for comparison of real numbers (double) and check if they are positive.
*/
class Tolerances {
public:
/**
* Default constructor (tolerances equal to 0).
*/
Tolerances();
/**
* Constructor.
* @param absoluteTolerance Absolute tolerance.
* @param relativeTolerance Relative tolerance.
*/
Tolerances(double absoluteTolerance, double relativeTolerance);
/**
* Default destructor.
*/
virtual ~Tolerances();
/**
*
* @return Pre-formatted string with the tolerances.
*/
std::string toString() const;
// ##### GETTERS & SETTERS #####
/**
*
* @return Absolute tolerance.
*/
double getAbsoluteTolerance() const;
/**
*
* @return Relative tolerance.
*/
double getRelativeTolerance() const;
/**
*
* @param absoluteTolerance Absolute tolerance.
*/
void setAbsoluteTolerance(double absoluteTolerance);
/**
*
* @param relativeTolerance Relative tolerance.
*/
void setRelativeTolerance(double relativeTolerance);
private:
double m_absoluteTolerance;
double m_relativeTolerance;
double m_absoluteTolerance; ///< Absolute tolerance.
double m_relativeTolerance; ///< Relative tolerance.
void testPositivity(const double &tolerance) const;
void testPositivity(const double &tolerance) const; ///< Positivity test.
};
} // namespace NumA
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment