UFO
src/ufo/utils/PiecewiseLinearInterpolation.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 Met Office UK
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  */
7 
8 #ifndef UFO_UTILS_PIECEWISELINEARINTERPOLATION_H_
9 #define UFO_UTILS_PIECEWISELINEARINTERPOLATION_H_
10 
11 #include <vector>
12 
13 namespace ufo {
14 
15 /// \brief Represents a piecewise linear interpolation of a set of data points.
17 {
18  public:
19  /// \brief Create an object representing a piecewise linear interpolation of the data points
20  /// (sortedAbscissas[i], ordinates[i]).
21  ///
22  /// Both arguments must have the same length and be non-empty. The elements of \p sortedAbscissas
23  /// must be sorted.
24  PiecewiseLinearInterpolation(std::vector<double> sortedAbscissas,
25  std::vector<double> ordinates);
26 
27  /// \brief Evaluate the interpolated function at \p abscissa.
28  double operator()(double abscissa) const;
29 
30  /// \brief Convenience function interpolating the data points (sortedAbscissas[i], ordinates[i])
31  /// at \p abscissa without creating a PiecewiseLinearInterpolation object.
32  static double interpolate(const std::vector<double> &sortedAbscissas,
33  const std::vector<double> &ordinates,
34  double abscissa);
35 
36  private:
37  std::vector<double> abscissas_;
38  std::vector<double> ordinates_;
39 };
40 
41 } // namespace ufo
42 
43 #endif // UFO_UTILS_PIECEWISELINEARINTERPOLATION_H_
Represents a piecewise linear interpolation of a set of data points.
static double interpolate(const std::vector< double > &sortedAbscissas, const std::vector< double > &ordinates, double abscissa)
Convenience function interpolating the data points (sortedAbscissas[i], ordinates[i]) at abscissa wit...
double operator()(double abscissa) const
Evaluate the interpolated function at abscissa.
PiecewiseLinearInterpolation(std::vector< double > sortedAbscissas, std::vector< double > ordinates)
Create an object representing a piecewise linear interpolation of the data points (sortedAbscissas[i]...
Definition: RunCRTM.h:27