Skip to content
Snippets Groups Projects
Commit dd26ba4f authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

Further sort, rename, comment namespaces

parent 7d86e03b
No related branches found
No related tags found
No related merge requests found
...@@ -15,8 +15,11 @@ ...@@ -15,8 +15,11 @@
#ifndef BORNAGAIN_BASE_CONST_PHYSICALCONSTANTS_H #ifndef BORNAGAIN_BASE_CONST_PHYSICALCONSTANTS_H
#define BORNAGAIN_BASE_CONST_PHYSICALCONSTANTS_H #define BORNAGAIN_BASE_CONST_PHYSICALCONSTANTS_H
//! Physical constants.
namespace PhysConsts namespace PhysConsts
{ {
constexpr double m_n = 1.67492749804e-27; //!< Neutron mass, kg constexpr double m_n = 1.67492749804e-27; //!< Neutron mass, kg
constexpr double h_bar = 1.054571817e-34; //!< Reduced Plank constant, J s constexpr double h_bar = 1.054571817e-34; //!< Reduced Plank constant, J s
constexpr double mu_N = 5.0507837461e-27; //!< Nuclear magneton (\f$ \mu_N \f$), J/T constexpr double mu_N = 5.0507837461e-27; //!< Nuclear magneton (\f$ \mu_N \f$), J/T
...@@ -25,6 +28,7 @@ constexpr double r_e = 2.8179403262e-15; //!< Thomson scattering length (\f$ r ...@@ -25,6 +28,7 @@ constexpr double r_e = 2.8179403262e-15; //!< Thomson scattering length (\f$ r
constexpr double gamma_n = 1.91304272; //!< \f$\gamma\f$ factor for neutron magnetic moment, constexpr double gamma_n = 1.91304272; //!< \f$\gamma\f$ factor for neutron magnetic moment,
//!< \f$\mu_n = \gamma \cdot \mu_N\f$ //!< \f$\mu_n = \gamma \cdot \mu_N\f$
constexpr double g_factor_n = -3.82608545; //!< neutron g-factor constexpr double g_factor_n = -3.82608545; //!< neutron g-factor
} // namespace PhysConsts } // namespace PhysConsts
#endif // BORNAGAIN_BASE_CONST_PHYSICALCONSTANTS_H #endif // BORNAGAIN_BASE_CONST_PHYSICALCONSTANTS_H
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
#include <cmath> #include <cmath>
#include <limits> #include <limits>
//! Floating-point epsilon, tolerances, almost-equal.
namespace Numeric namespace Numeric
{ {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <limits> #include <limits>
//! Floating-point epsilon, tolerances, almost-equal. //! Floating-point approximations.
namespace Numeric namespace Numeric
{ {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// BornAgain: simulate and fit scattering at grazing incidence // BornAgain: simulate and fit scattering at grazing incidence
// //
//! @file Base/Math/Precomputed.h //! @file Base/Math/Precomputed.h
//! @brief Defines namespace Precomputed, providing precomputed constants //! @brief Defines namespace Math::Precomputed, providing precomputed constants
//! //!
//! @homepage http://www.bornagainproject.org //! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING) //! @license GNU General Public License v3 or higher (see COPYING)
...@@ -19,9 +19,8 @@ ...@@ -19,9 +19,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
//! Compile-time generated std::array of reciprocal factorials namespace Math::internal {
namespace Precomputed
{
template <size_t N> struct ReciprocalFactorial { template <size_t N> struct ReciprocalFactorial {
static constexpr double value = ReciprocalFactorial<N - 1>::value / N; static constexpr double value = ReciprocalFactorial<N - 1>::value / N;
}; };
...@@ -31,16 +30,22 @@ template <> struct ReciprocalFactorial<0> { ...@@ -31,16 +30,22 @@ template <> struct ReciprocalFactorial<0> {
}; };
template <template <size_t> class F, size_t... I> template <template <size_t> class F, size_t... I>
constexpr std::array<double, sizeof...(I)> GenerateArrayHelper(std::index_sequence<I...>) constexpr std::array<double, sizeof...(I)> generateArrayHelper(std::index_sequence<I...>)
{ {
return {F<I>::value...}; return {F<I>::value...};
}; };
} // namespace Math::internal
namespace Math
{
//! Returns a compile-time generated std::array of reciprocal factorials.
template <size_t N, typename Indices = std::make_index_sequence<N>> template <size_t N, typename Indices = std::make_index_sequence<N>>
constexpr std::array<double, N> GenerateReciprocalFactorialArray() constexpr std::array<double, N> generateReciprocalFactorialArray()
{ {
return GenerateArrayHelper<ReciprocalFactorial>(Indices{}); return internal::generateArrayHelper<internal::ReciprocalFactorial>(Indices{});
}; };
} // namespace Precomputed } // namespace Math
#endif // BORNAGAIN_BASE_MATH_PRECOMPUTED_H #endif // BORNAGAIN_BASE_MATH_PRECOMPUTED_H
...@@ -56,7 +56,7 @@ MinimizerResult MinimizerAdapter::minimize(Parameters parameters) ...@@ -56,7 +56,7 @@ MinimizerResult MinimizerAdapter::minimize(Parameters parameters)
MinimizerResult result; MinimizerResult result;
result.setParameters(parameters); result.setParameters(parameters);
result.setMinValue(minValue()); result.setMinValue(minValue());
result.setReport(report::reportToString(*this)); result.setReport(internal::reportToString(*this));
result.setNumberOfCalls(m_adapter->numberOfCalls()); result.setNumberOfCalls(m_adapter->numberOfCalls());
result.setNumberOfGradientCalls(m_adapter->numberOfGradientCalls()); result.setNumberOfGradientCalls(m_adapter->numberOfGradientCalls());
......
...@@ -71,10 +71,10 @@ std::string reportStatus(const MinimizerAdapter& minimizer) ...@@ -71,10 +71,10 @@ std::string reportStatus(const MinimizerAdapter& minimizer)
} // namespace } // namespace
// ************************************************************************************************ // ************************************************************************************************
// namespace report // implement API
// ************************************************************************************************ // ************************************************************************************************
std::string report::reportToString(const MinimizerAdapter& minimizer) std::string mumufit::internal::reportToString(const MinimizerAdapter& minimizer)
{ {
std::ostringstream result; std::ostringstream result;
......
...@@ -21,7 +21,7 @@ class MinimizerAdapter; ...@@ -21,7 +21,7 @@ class MinimizerAdapter;
//! Utility functions to generate reports //! Utility functions to generate reports
namespace report namespace mumufit::internal
{ {
//! Reports results of minimization in the form of multi-line string //! Reports results of minimization in the form of multi-line string
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
namespace namespace
{ {
const double eps = 2e-16; const double eps = 2e-16;
constexpr auto ReciprocalFactorialArray = Precomputed::GenerateReciprocalFactorialArray<171>(); constexpr auto ReciprocalFactorialArray = Math::generateReciprocalFactorialArray<171>();
} // namespace } // namespace
// ************************************************************************************************ // ************************************************************************************************
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
class Lattice3D; class Lattice3D;
//! Functions that instantiate objects. To be used like constructors.
namespace bake namespace bake
{ {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
namespace namespace
{ {
constexpr auto ReciprocalFactorialArray = Precomputed::GenerateReciprocalFactorialArray<171>(); constexpr auto ReciprocalFactorialArray = Math::generateReciprocalFactorialArray<171>();
} }
class PrecomputedTest : public ::testing::Test class PrecomputedTest : public ::testing::Test
......
...@@ -884,12 +884,12 @@ C++ includes: Integrator.h ...@@ -884,12 +884,12 @@ C++ includes: Integrator.h
"; ";
// File: structPrecomputed_1_1ReciprocalFactorial.xml // File: structMath_1_1internal_1_1ReciprocalFactorial.xml
%feature("docstring") Precomputed::ReciprocalFactorial ""; %feature("docstring") Math::internal::ReciprocalFactorial "";
// File: structPrecomputed_1_1ReciprocalFactorial_3_010_01_4.xml // File: structMath_1_1internal_1_1ReciprocalFactorial_3_010_01_4.xml
%feature("docstring") Precomputed::ReciprocalFactorial< 0 > " %feature("docstring") Math::internal::ReciprocalFactorial< 0 > "
"; ";
...@@ -1354,6 +1354,11 @@ Error function of real-valued argument. ...@@ -1354,6 +1354,11 @@ Error function of real-valued argument.
%feature("docstring") Math::Bessel::GeneratePoissonRandom "double Math::GeneratePoissonRandom(double average) %feature("docstring") Math::Bessel::GeneratePoissonRandom "double Math::GeneratePoissonRandom(double average)
"; ";
%feature("docstring") Math::Bessel::generateReciprocalFactorialArray "constexpr std::array<double, N> Math::generateReciprocalFactorialArray()
Returns a compile-time generated std::array of reciprocal factorials.
";
// File: namespaceMath_1_1Bessel.xml // File: namespaceMath_1_1Bessel.xml
%feature("docstring") Math::Bessel::J0 "double Math::Bessel::J0(double x) %feature("docstring") Math::Bessel::J0 "double Math::Bessel::J0(double x)
...@@ -1392,6 +1397,11 @@ Complex Bessel function J1(x)/x. ...@@ -1392,6 +1397,11 @@ Complex Bessel function J1(x)/x.
"; ";
// File: namespaceMath_1_1internal.xml
%feature("docstring") Math::internal::generateArrayHelper "constexpr std::array<double, sizeof...(I)> Math::internal::generateArrayHelper(std::index_sequence< I... >)
";
// File: namespaceNumeric.xml // File: namespaceNumeric.xml
%feature("docstring") Numeric::GetAbsoluteDifference "double Numeric::GetAbsoluteDifference(double a, double b) %feature("docstring") Numeric::GetAbsoluteDifference "double Numeric::GetAbsoluteDifference(double a, double b)
...@@ -1412,14 +1422,6 @@ Returns the difference of the logarithm; input values are truncated at the minim ...@@ -1412,14 +1422,6 @@ Returns the difference of the logarithm; input values are truncated at the minim
// File: namespacePhysConsts.xml // File: namespacePhysConsts.xml
// File: namespacePrecomputed.xml
%feature("docstring") Precomputed::GenerateArrayHelper "constexpr std::array<double, sizeof...(I)> Precomputed::GenerateArrayHelper(std::index_sequence< I... >)
";
%feature("docstring") Precomputed::GenerateReciprocalFactorialArray "constexpr std::array<double, N> Precomputed::GenerateReciprocalFactorialArray()
";
// File: namespacePyEmbeddedUtils.xml // File: namespacePyEmbeddedUtils.xml
%feature("docstring") PyEmbeddedUtils::toString "std::string PyEmbeddedUtils::toString(PyObject *obj) %feature("docstring") PyEmbeddedUtils::toString "std::string PyEmbeddedUtils::toString(PyObject *obj)
......
...@@ -1399,6 +1399,13 @@ Internal state of a WallclockTimer object. ...@@ -1399,6 +1399,13 @@ Internal state of a WallclockTimer object.
// File: namespacemumufit.xml // File: namespacemumufit.xml
// File: namespacemumufit_1_1internal.xml
%feature("docstring") mumufit::internal::reportToString "std::string mumufit::internal::reportToString(const MinimizerAdapter &minimizer)
Reports results of minimization in the form of multi-line string.
";
// File: namespacemumufit_1_1stringUtils.xml // File: namespacemumufit_1_1stringUtils.xml
%feature("docstring") mumufit::stringUtils::matchesPattern "bool mumufit::stringUtils::matchesPattern(const std::string &text, const std::string &wildcardPattern) %feature("docstring") mumufit::stringUtils::matchesPattern "bool mumufit::stringUtils::matchesPattern(const std::string &text, const std::string &wildcardPattern)
...@@ -1458,13 +1465,6 @@ Returns horizontal line of 80 characters length with section name in it. ...@@ -1458,13 +1465,6 @@ Returns horizontal line of 80 characters length with section name in it.
"; ";
// File: namespacereport.xml
%feature("docstring") report::reportToString "std::string report::reportToString(const MinimizerAdapter &minimizer)
Reports results of minimization in the form of multi-line string.
";
// File: namespaceROOT.xml // File: namespaceROOT.xml
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment