SpanInterpolator.hpp
2 // See LICENSE.txt for details.
3
4 #pragma once
5
6 #include <complex>
7 #include <cstddef>
8
9 #include "DataStructures/ComplexModalVector.hpp"
10 #include "DataStructures/DataVector.hpp"
11 #include "DataStructures/ModalVector.hpp"
12 #include "Options/Options.hpp"
14 #include "Utilities/Gsl.hpp"
15
16 namespace intrp {
17
18 class LinearSpanInterpolator;
19 class CubicSpanInterpolator;
20 class BarycentricRationalSpanInterpolator;
21
22 /// \brief Base class for interpolators so that the factory options
23 /// mechanism can be used.
24 ///
25 /// \details The virtual functions in this class demand only that the real
26 /// interpolate function, get_clone function, and
27 /// required_number_of_points_before_and_after function be overridden in the
28 /// derived class. The interpolate for complex values can just be used from
29 /// this base class, which calls the real version for each component. If it is
30 /// possible to make a specialized complex version that avoids allocations, that
31 /// is probably more efficient.
32 class SpanInterpolator : public PUP::able {
33  public:
34  using creatable_classes =
37
38  WRAPPED_PUPable_abstract(SpanInterpolator); // NOLINT
39
40  /// Produce a std::unique_ptr that points to a copy of *this
41  virtual std::unique_ptr<SpanInterpolator> get_clone() const noexcept = 0;
42
43  /// Perform the interpolation of function represented by values at
44  /// source_points to the requested target_point, returning the
45  /// interpolation result.
46  virtual double interpolate(const gsl::span<const double>& source_points,
47  const gsl::span<const double>& values,
48  double target_point) const noexcept = 0;
49
50  /// Perform the interpolation of function represented by complex values at
51  /// source_points to the requested target_point, returning the
52  /// (complex) interpolation result.
54  const gsl::span<const double>& source_points,
55  const gsl::span<const std::complex<double>>& values,
56  double target_point) const noexcept;
57
58  /// The number of domain points that should be both before and after the
59  /// requested target point for best interpolation. For instance, for a linear
60  /// interpolator, this function would return 1 to request that the target is
61  /// between the two domain points passed to source_points.
62  virtual size_t required_number_of_points_before_and_after() const
63  noexcept = 0;
64 };
65 } // namespace intrp
Base class for interpolators so that the factory options mechanism can be used.
Definition: SpanInterpolator.hpp:32
virtual double interpolate(const gsl::span< const double > &source_points, const gsl::span< const double > &values, double target_point) const noexcept=0
Perform the interpolation of function represented by values at source_points to the requested target_...
Defines classes and functions for making classes creatable from input files.
Defines macros to allow serialization of abstract template base classes.
Performs a cubic interpolation; this class can be chosen via the options factory mechanism as a possi...
Definition: CubicSpanInterpolator.hpp:25
Create a span/view on a range, which is cheap to copy (one pointer).
Definition: Gsl.hpp:291
virtual size_t required_number_of_points_before_and_after() const noexcept=0
The number of domain points that should be both before and after the requested target point for best ...
Performs a linear interpolation; this class can be chosen via the options factory mechanism as a poss...
Definition: LinearSpanInterpolator.hpp:21
virtual std::unique_ptr< SpanInterpolator > get_clone() const noexcept=0
Produce a std::unique_ptr that points to a copy of *this.
Performs a barycentric interpolation with an order in a range fixed at construction; this class can b...
Definition: BarycentricRationalSpanInterpolator.hpp:24
Defines functions and classes from the GSL.