NuTo
Numerics Tool
Interpolation.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <array>
4 #include <vector>
5 #include <functional>
6 
7 namespace NuTo
8 {
9 namespace Math
10 {
12 {
13 public:
15  Interpolation(std::vector<std::array<double, 2>> data, unsigned numNeighborPoints);
16 
17  virtual ~Interpolation() = default;
19  virtual double operator()(double x) const = 0;
20 
22  virtual double derivative(double x) const = 0;
23 
25  std::function<double(double)> f = [this](double x) { return operator()(x); };
26 
28  std::function<double(double)> df = [this](double x) { return derivative(x); };
29 
30 protected:
31  std::vector<std::array<double, 2>> mData;
32 
34 
35  unsigned bisection(double x) const;
36 };
37 } // namespace Math
38 } // namespace NuTo
virtual ~Interpolation()=default
Interpolation(std::vector< std::array< double, 2 >> data, unsigned numNeighborPoints)
create interpolation object; call with data array
Definition: Interpolation.cpp:10
virtual double operator()(double x) const =0
return interpolated value at x; order is the order of the derivative
unsigned bisection(double x) const
Definition: Interpolation.cpp:21
std::function< double(double)> f
function object
Definition: Interpolation.h:25
std::vector< std::array< double, 2 > > mData
Definition: Interpolation.h:31
unsigned mNumNeighborPoints
Definition: Interpolation.h:33
Definition: Exception.h:6
virtual double derivative(double x) const =0
calculate first derivative at x
std::function< double(double)> df
derivative function object
Definition: Interpolation.h:28