BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
IAxis.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Base/Axis/IAxis.cpp
6 //! @brief Implements interface IAxis.
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 #include "Base/Axis/IAxis.h"
16 #include "Base/Axis/Bin.h"
17 
18 IAxis::~IAxis() = default;
19 
20 bool IAxis::equals(const IAxis& other) const
21 {
22  return axisName() == other.axisName();
23 }
24 
25 std::vector<double> IAxis::binCenters() const
26 {
27  throw std::runtime_error("IAxis::binCenters() -> Error. Not implemented.");
28 }
29 
30 std::vector<double> IAxis::binBoundaries() const
31 {
32  throw std::runtime_error("IAxis::binBoundaries() -> Error. Not implemented.");
33 }
34 
35 void IAxis::clip(double /*lower*/, double /*upper*/)
36 {
37  throw std::runtime_error("IAxis::clip() -> Error. Not implemented.");
38 }
39 
40 void IAxis::clip(const std::pair<double, double> bounds)
41 {
42  return clip(bounds.first, bounds.second);
43 }
44 
45 bool IAxis::contains(double value) const
46 {
47  return value >= min() && value < max();
48 }
49 
50 std::pair<double, double> IAxis::bounds() const
51 {
52  return {min(), max()};
53 }
54 
55 double IAxis::span() const
56 {
57  return max() - min();
58 }
59 
60 double IAxis::center() const
61 {
62  return (max() + min()) / 2;
63 }
Defines structs Bin1D, Bin1DCVector.
Defines interface IAxis.
Abstract base class for one-dimensional axes.
Definition: IAxis.h:27
double span() const
Returns distance from first to last point.
Definition: IAxis.cpp:55
virtual bool contains(double value) const
Returns true if axis contains given point.
Definition: IAxis.cpp:45
virtual std::vector< double > binCenters() const
Definition: IAxis.cpp:25
virtual std::vector< double > binBoundaries() const
Definition: IAxis.cpp:30
virtual bool equals(const IAxis &other) const
Definition: IAxis.cpp:20
virtual double max() const =0
Returns value of last point of axis.
virtual ~IAxis()
virtual double min() const =0
Returns value of first point of axis.
std::pair< double, double > bounds() const
Returns lower and upper bound in a pair. first is lower, second is upper.
Definition: IAxis.cpp:50
std::string axisName() const
Returns the label of the axis.
Definition: IAxis.h:61
virtual void clip(double lower, double upper)
Clips this axis to the given values.
Definition: IAxis.cpp:35
double center() const
Returns midpoint of axis.
Definition: IAxis.cpp:60