BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
DiffUtil.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Histo/DiffUtil.h
6 //! @brief Defines namespace DataUtils.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_DEVICE_HISTO_DIFFUTIL_H
16 #define BORNAGAIN_DEVICE_HISTO_DIFFUTIL_H
17 
18 #include <memory>
19 #include <vector>
20 
21 class Datafield;
22 class SimulationResult;
23 
24 namespace DiffUtil {
25 
26 //! Returns relative difference between two data sets sum(dat[i] - ref[i])/ref[i]).
27 double meanRelVecDiff(const std::vector<double>& dat, const std::vector<double>& ref);
28 
29 //! Returns Datafield representing relative difference of two histograms.
30 Datafield* relativeDifferenceField(const Datafield& dat, const Datafield& ref);
31 
32 //! Returns sum of relative differences between each pair of elements:
33 //! (a, b) -> 2*abs(a - b)/(a + b) ( and zero if a-b=0 )
34 double meanRelativeDifference(const SimulationResult& dat, const SimulationResult& ref);
35 
36 //! Returns true is relative difference is below threshold; prints informative output
37 bool checkRelativeDifference(const std::vector<double>& dat, const std::vector<double>& ref,
38  double threshold);
39 } // namespace DiffUtil
40 
41 #endif // BORNAGAIN_DEVICE_HISTO_DIFFUTIL_H
Stores radiation power per bin.
Definition: Datafield.h:30
Wrapper around Datafield that also provides unit conversions.
Datafield * relativeDifferenceField(const Datafield &dat, const Datafield &ref)
Returns Datafield representing relative difference of two histograms.
Definition: DiffUtil.cpp:39
double meanRelVecDiff(const std::vector< double > &dat, const std::vector< double > &ref)
Returns relative difference between two data sets sum(dat[i] - ref[i])/ref[i]).
Definition: DiffUtil.cpp:28
bool checkRelativeDifference(const std::vector< double > &dat, const std::vector< double > &ref, double threshold)
Returns true is relative difference is below threshold; prints informative output.
Definition: DiffUtil.cpp:64
double meanRelativeDifference(const SimulationResult &dat, const SimulationResult &ref)
Returns sum of relative differences between each pair of elements: (a, b) -> 2*abs(a - b)/(a + b) ( a...
Definition: DiffUtil.cpp:50