ExternalDataInterpolator Class Reference#
|
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 |
Detailed Description
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.
Constructor & Destructor Documentation
◆ ExternalDataInterpolator() [1/3]
| 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.
- Parameters
-
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.
◆ ExternalDataInterpolator() [2/3]
| 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.
- Parameters
-
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.
◆ ExternalDataInterpolator() [3/3]
| DiFfRG::ExternalDataInterpolator::ExternalDataInterpolator | ( | ) |
Construct an empty External Data Interpolator object.
Member Function Documentation
◆ check_consistency()
|
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.
- Parameters
-
tolerance The relative precision to use.
- Returns
- true If the interpolator is consistent with the original data.
◆ derivative()
| double DiFfRG::ExternalDataInterpolator::derivative | ( | double | x, |
| uint | i ) const |
Interpolate the derivative of the data to a given x.
- Parameters
-
x The x to interpolate to. i The index of the data to interpolate.
- Returns
- double The interpolated derivative.
◆ setup()
|
private |
Set up the interpolator.
- Parameters
-
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.
◆ value()
| double DiFfRG::ExternalDataInterpolator::value | ( | double | x, |
| uint | i ) const |
Interpolate the data to a given x.
- Parameters
-
x The x to interpolate to. i The index of the data to interpolate.
- Returns
- double The interpolated data.
Member Data Documentation
◆ file_data
|
private |
◆ input_file
|
private |
◆ interpolators
|
private |
◆ max_x
|
private |
◆ min_x
|
private |
The documentation for this class was generated from the following file:
- /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/common/external_data_interpolator.hh
Generated by