Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
partons
core
numa
Commits
fd33dd33
Commit
fd33dd33
authored
Jun 09, 2017
by
Nabil Chouika
Browse files
NumA utils documentation partons/core/partons#4
parent
055454af
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
fd33dd33
/.externalToolBuilders/
/.settings/
/lib/
/NumA++.doxyfile.bak
NumA++.doxyfile
View file @
fd33dd33
This diff is collapsed.
Click to expand it.
include/NumA/utils/Differences.h
View file @
fd33dd33
...
...
@@ -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
...
...
include/NumA/utils/Errors.h
View file @
fd33dd33
...
...
@@ -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 */
...
...
include/NumA/utils/Interval.h
View file @
fd33dd33
...
...
@@ -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 */
...
...
include/NumA/utils/MathUtils.h
View file @
fd33dd33
...
...
@@ -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
);
};
...
...
include/NumA/utils/Tolerances.h
View file @
fd33dd33
...
...
@@ -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 tolerance
s
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment