DiFfRG
|
This class takes in a .csv file with x-dependent data and interpolates it to a given x on request. More...
#include <external_data_interpolator.hh>
Public Member Functions | |
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. | |
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. | |
ExternalDataInterpolator () | |
Construct an empty External Data Interpolator object. | |
double | value (double x, uint i) const |
Interpolate the data to a given x. | |
double | derivative (double x, uint i) const |
Interpolate the derivative of the data to a given x. | |
Private Member Functions | |
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. | |
bool | check_consistency (double tolerance) const |
Check whether the interpolator is consistent with the original data. The interpolator checks if it can reproduce the original data with a given relative precision. | |
Private Attributes | |
std::string | input_file |
std::vector< std::vector< double > > | file_data |
std::vector< boost::math::interpolators::barycentric_rational< double > > | interpolators |
double | max_x |
double | min_x |
This class takes in a .csv file with x-dependent data and interpolates it to a given x on request.
Data can be read from several files which are identically formatted and will then be concatenated. The choice which column represents the independent x variable can be made by the user when creating the object. After read-in, the data can be post-processed before interpolation. After the object is constructed, this class allows to access both the interpolant and its derivative.
Note, that interpolations beyond the range of the data will return the value at the closest boundary.
Internally, the boost barycentric rational interpolator is used.
DiFfRG::ExternalDataInterpolator::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.
input_files | The .csv file(s) to read the data from. |
post_processors | The post processors to apply to the data. |
separator | The separator used in the .csv file. |
has_header | Whether the .csv file has a header. |
x_column | The column in the .csv file(s) that contains the x values. This counts all columns, including the ones from previous files. |
DiFfRG::ExternalDataInterpolator::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.
input_files | The .csv file(s) to read the data from. |
separator | The separator used in the .csv file. |
has_header | Whether the .csv file has a header. |
x_column | The column in the .csv file(s) that contains the x values. This counts all columns, including the ones from previous files. |
DiFfRG::ExternalDataInterpolator::ExternalDataInterpolator | ( | ) |
Construct an empty External Data Interpolator object.
|
private |
Check whether the interpolator is consistent with the original data. The interpolator checks if it can reproduce the original data with a given relative precision.
tolerance | The relative precision to use. |
double DiFfRG::ExternalDataInterpolator::derivative | ( | double | x, |
uint | i ) const |
Interpolate the derivative of the data to a given x.
x | The x to interpolate to. |
i | The index of the data to interpolate. |
|
private |
Set up the interpolator.
input_files | The .csv file(s) to read the data from. |
post_processors | The post processors to apply to the data. |
separator | The separator used in the .csv file. |
has_header | Whether the .csv file has a header. |
x_column | The column in the .csv file(s) that contains the x values. This counts all columns, including the ones from previous files. |
double DiFfRG::ExternalDataInterpolator::value | ( | double | x, |
uint | i ) const |
Interpolate the data to a given x.
x | The x to interpolate to. |
i | The index of the data to interpolate. |
|
private |
|
private |
|
private |
|
private |
|
private |