From dd26ba4f430ff10afc857af195c735ee1c2a7be8 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Thu, 19 Nov 2020 10:44:57 +0100
Subject: [PATCH] Further sort, rename, comment namespaces

---
 Base/Const/PhysicalConstants.h                |  4 +++
 Base/Math/Numeric.cpp                         |  2 --
 Base/Math/Numeric.h                           |  2 +-
 Base/Math/Precomputed.h                       | 21 +++++++++------
 Fit/Adapter/MinimizerAdapter.cpp              |  2 +-
 Fit/Adapter/Report.cpp                        |  4 +--
 Fit/Adapter/Report.h                          |  2 +-
 Sample/HardParticle/PolyhedralComponents.cpp  |  2 +-
 Sample/Lattice/BakeLattice.h                  |  2 ++
 .../Core/Detector/PrecomputedTest.cpp         |  2 +-
 auto/Wrap/doxygenBase.i                       | 26 ++++++++++---------
 auto/Wrap/doxygenFit.i                        | 14 +++++-----
 12 files changed, 47 insertions(+), 36 deletions(-)

diff --git a/Base/Const/PhysicalConstants.h b/Base/Const/PhysicalConstants.h
index a1b88610016..557c8366ee4 100644
--- a/Base/Const/PhysicalConstants.h
+++ b/Base/Const/PhysicalConstants.h
@@ -15,8 +15,11 @@
 #ifndef BORNAGAIN_BASE_CONST_PHYSICALCONSTANTS_H
 #define BORNAGAIN_BASE_CONST_PHYSICALCONSTANTS_H
 
+//! Physical constants.
+
 namespace PhysConsts
 {
+
 constexpr double m_n = 1.67492749804e-27;  //!< Neutron mass, kg
 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
@@ -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,
                                            //!< \f$\mu_n = \gamma \cdot \mu_N\f$
 constexpr double g_factor_n = -3.82608545; //!< neutron g-factor
+
 } // namespace PhysConsts
 
 #endif // BORNAGAIN_BASE_CONST_PHYSICALCONSTANTS_H
diff --git a/Base/Math/Numeric.cpp b/Base/Math/Numeric.cpp
index 55f48c22a19..2f0e69690c7 100644
--- a/Base/Math/Numeric.cpp
+++ b/Base/Math/Numeric.cpp
@@ -17,8 +17,6 @@
 #include <cmath>
 #include <limits>
 
-//! Floating-point epsilon, tolerances, almost-equal.
-
 namespace Numeric
 {
 
diff --git a/Base/Math/Numeric.h b/Base/Math/Numeric.h
index 1311f2a32b2..5effb0950f5 100644
--- a/Base/Math/Numeric.h
+++ b/Base/Math/Numeric.h
@@ -17,7 +17,7 @@
 
 #include <limits>
 
-//! Floating-point epsilon, tolerances, almost-equal.
+//! Floating-point approximations.
 
 namespace Numeric
 {
diff --git a/Base/Math/Precomputed.h b/Base/Math/Precomputed.h
index e3ed8713517..07059101624 100644
--- a/Base/Math/Precomputed.h
+++ b/Base/Math/Precomputed.h
@@ -3,7 +3,7 @@
 //  BornAgain: simulate and fit scattering at grazing incidence
 //
 //! @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
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -19,9 +19,8 @@
 #include <utility>
 #include <vector>
 
-//! Compile-time generated std::array of reciprocal factorials
-namespace Precomputed
-{
+namespace Math::internal {
+
 template <size_t N> struct ReciprocalFactorial {
     static constexpr double value = ReciprocalFactorial<N - 1>::value / N;
 };
@@ -31,16 +30,22 @@ template <> struct ReciprocalFactorial<0> {
 };
 
 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...};
 };
 
+} // 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>>
-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
diff --git a/Fit/Adapter/MinimizerAdapter.cpp b/Fit/Adapter/MinimizerAdapter.cpp
index 5039c044058..ec9865cd0d2 100644
--- a/Fit/Adapter/MinimizerAdapter.cpp
+++ b/Fit/Adapter/MinimizerAdapter.cpp
@@ -56,7 +56,7 @@ MinimizerResult MinimizerAdapter::minimize(Parameters parameters)
     MinimizerResult result;
     result.setParameters(parameters);
     result.setMinValue(minValue());
-    result.setReport(report::reportToString(*this));
+    result.setReport(internal::reportToString(*this));
     result.setNumberOfCalls(m_adapter->numberOfCalls());
     result.setNumberOfGradientCalls(m_adapter->numberOfGradientCalls());
 
diff --git a/Fit/Adapter/Report.cpp b/Fit/Adapter/Report.cpp
index 6eee327a860..297a6e1647d 100644
--- a/Fit/Adapter/Report.cpp
+++ b/Fit/Adapter/Report.cpp
@@ -71,10 +71,10 @@ std::string reportStatus(const MinimizerAdapter& minimizer)
 } // namespace
 
 //  ************************************************************************************************
-//  namespace report
+//  implement API
 //  ************************************************************************************************
 
-std::string report::reportToString(const MinimizerAdapter& minimizer)
+std::string mumufit::internal::reportToString(const MinimizerAdapter& minimizer)
 {
     std::ostringstream result;
 
diff --git a/Fit/Adapter/Report.h b/Fit/Adapter/Report.h
index eecd0e7aa9b..bfde8ad29cb 100644
--- a/Fit/Adapter/Report.h
+++ b/Fit/Adapter/Report.h
@@ -21,7 +21,7 @@ class MinimizerAdapter;
 
 //! Utility functions to generate reports
 
-namespace report
+namespace mumufit::internal
 {
 
 //! Reports results of minimization in the form of multi-line string
diff --git a/Sample/HardParticle/PolyhedralComponents.cpp b/Sample/HardParticle/PolyhedralComponents.cpp
index dcb0d8834fb..50f59f63beb 100644
--- a/Sample/HardParticle/PolyhedralComponents.cpp
+++ b/Sample/HardParticle/PolyhedralComponents.cpp
@@ -21,7 +21,7 @@
 namespace
 {
 const double eps = 2e-16;
-constexpr auto ReciprocalFactorialArray = Precomputed::GenerateReciprocalFactorialArray<171>();
+constexpr auto ReciprocalFactorialArray = Math::generateReciprocalFactorialArray<171>();
 } // namespace
 
 //  ************************************************************************************************
diff --git a/Sample/Lattice/BakeLattice.h b/Sample/Lattice/BakeLattice.h
index beb7ea75ea2..4ebbf577cc7 100644
--- a/Sample/Lattice/BakeLattice.h
+++ b/Sample/Lattice/BakeLattice.h
@@ -17,6 +17,8 @@
 
 class Lattice3D;
 
+//! Functions that instantiate objects. To be used like constructors.
+
 namespace bake
 {
 
diff --git a/Tests/UnitTests/Core/Detector/PrecomputedTest.cpp b/Tests/UnitTests/Core/Detector/PrecomputedTest.cpp
index f78d12df4f7..4bb6e29dae3 100644
--- a/Tests/UnitTests/Core/Detector/PrecomputedTest.cpp
+++ b/Tests/UnitTests/Core/Detector/PrecomputedTest.cpp
@@ -4,7 +4,7 @@
 
 namespace
 {
-constexpr auto ReciprocalFactorialArray = Precomputed::GenerateReciprocalFactorialArray<171>();
+constexpr auto ReciprocalFactorialArray = Math::generateReciprocalFactorialArray<171>();
 }
 
 class PrecomputedTest : public ::testing::Test
diff --git a/auto/Wrap/doxygenBase.i b/auto/Wrap/doxygenBase.i
index a22bbd50c6c..b76bdda5c1e 100644
--- a/auto/Wrap/doxygenBase.i
+++ b/auto/Wrap/doxygenBase.i
@@ -884,12 +884,12 @@ C++ includes: Integrator.h
 ";
 
 
-// File: structPrecomputed_1_1ReciprocalFactorial.xml
-%feature("docstring") Precomputed::ReciprocalFactorial "";
+// File: structMath_1_1internal_1_1ReciprocalFactorial.xml
+%feature("docstring") Math::internal::ReciprocalFactorial "";
 
 
-// File: structPrecomputed_1_1ReciprocalFactorial_3_010_01_4.xml
-%feature("docstring") Precomputed::ReciprocalFactorial< 0 > "
+// File: structMath_1_1internal_1_1ReciprocalFactorial_3_010_01_4.xml
+%feature("docstring") Math::internal::ReciprocalFactorial< 0 > "
 ";
 
 
@@ -1354,6 +1354,11 @@ Error function of real-valued argument.
 %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
 %feature("docstring")  Math::Bessel::J0 "double Math::Bessel::J0(double 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
 %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
 // 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
 %feature("docstring")  PyEmbeddedUtils::toString "std::string PyEmbeddedUtils::toString(PyObject *obj)
 
diff --git a/auto/Wrap/doxygenFit.i b/auto/Wrap/doxygenFit.i
index ecb39797ef5..e0a95658f88 100644
--- a/auto/Wrap/doxygenFit.i
+++ b/auto/Wrap/doxygenFit.i
@@ -1399,6 +1399,13 @@ Internal state of a  WallclockTimer object.
 // 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
 %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.
 ";
 
 
-// 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
 
 
-- 
GitLab