DiFfRG
Loading...
Searching...
No Matches
external_data_interpolator.hh
Go to the documentation of this file.
1#pragma once
2
3// standard library
4#include <functional>
5#include <string>
6#include <vector>
7
8// external libraries
9#include <boost/math/interpolators/barycentric_rational.hpp>
10
11namespace DiFfRG
12{
27 {
28 public:
39 ExternalDataInterpolator(std::vector<std::string> input_files,
40 std::vector<std::function<double(double)>> post_processors, char separator = ',',
41 bool has_header = false, uint x_column = 0, uint order = 1);
42
52 ExternalDataInterpolator(std::vector<std::string> input_files, char separator = ',', bool has_header = false,
53 uint x_column = 0, uint order = 1);
54
60
61 private:
72 void setup(const std::vector<std::string> &input_files,
73 const std::vector<std::function<double(double)>> &post_processors, char separator = ',',
74 bool has_header = false, uint x_column = 0, uint order = 1);
75
83 bool check_consistency(double tolerance) const;
84
85 public:
93 double value(double x, uint i) const;
94
102 double derivative(double x, uint i) const;
103
104 private:
105 std::string input_file;
106 std::vector<std::vector<double>> file_data;
107 std::vector<boost::math::interpolators::barycentric_rational<double>> interpolators;
108
109 double max_x, min_x;
110 };
111} // namespace DiFfRG
This class takes in a .csv file with x-dependent data and interpolates it to a given x on request.
Definition external_data_interpolator.hh:27
ExternalDataInterpolator(std::vector< std::string > input_files, char separator=',', bool has_header=false, uint x_column=0, uint order=1)
Construct a new External Data Interpolator object.
std::string input_file
Definition external_data_interpolator.hh:105
double value(double x, uint i) const
Interpolate the data to a given x.
void setup(const std::vector< std::string > &input_files, const std::vector< std::function< double(double)> > &post_processors, char separator=',', bool has_header=false, uint x_column=0, uint order=1)
Set up the interpolator.
double derivative(double x, uint i) const
Interpolate the derivative of the data to a given x.
bool check_consistency(double tolerance) const
Check whether the interpolator is consistent with the original data. The interpolator checks if it ca...
ExternalDataInterpolator()
Construct an empty External Data Interpolator object.
double max_x
Definition external_data_interpolator.hh:109
ExternalDataInterpolator(std::vector< std::string > input_files, std::vector< std::function< double(double)> > post_processors, char separator=',', bool has_header=false, uint x_column=0, uint order=1)
Construct a new External Data Interpolator object.
std::vector< boost::math::interpolators::barycentric_rational< double > > interpolators
Definition external_data_interpolator.hh:107
std::vector< std::vector< double > > file_data
Definition external_data_interpolator.hh:106
double min_x
Definition external_data_interpolator.hh:109
Definition complex_math.hh:14
unsigned int uint
Definition utils.hh:22