|
MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
|
One-dimensional function y(x) defined using a grid of ordered pairs (x,y) and an interpolation rule. More...
#include <InterpolationGrid.hh>
Public Types | |
| enum class | ExtrapolationMethod { Zero , Endpoint , Continue , Throw } |
| Method to use for computing y(x) when the x value lies beyond the grid boundaries. More... | |
| using | Grid = std::vector<OrderedPair> |
| using | GridConstIterator = typename std::vector<OrderedPair>::const_iterator |
| enum class | InterpolationMethod { Constant = 1 , LinearLinear = 2 , LinearLog = 3 , LogLinear = 4 , LogLog = 5 } |
| Method to use for interpolating between (x,y) grid points. More... | |
| using | OrderedPair = std::pair<FirstNumericType, SecondNumericType> |
Public Member Functions | |
| InterpolationGrid (const Grid &grid, InterpolationMethod interp_method=InterpolationMethod::LinearLinear, ExtrapolationMethod extrap_method=ExtrapolationMethod::Zero) | |
| Create an InterpolationGrid from a vector of ordered pairs. | |
| InterpolationGrid (const std::vector< FirstNumericType > &xs, const std::vector< SecondNumericType > &ys, InterpolationMethod interp_method=InterpolationMethod::LinearLinear, ExtrapolationMethod extrap_method=ExtrapolationMethod::Zero) | |
| Create an InterpolationGrid from vectors of x and y values. | |
| InterpolationGrid (InterpolationMethod interp_method=InterpolationMethod::LinearLinear, ExtrapolationMethod extrap_method=ExtrapolationMethod::Zero) | |
| Create an InterpolationGrid without any grid points. | |
| OrderedPair & | at (size_t j) |
| Get a reference to the jth ordered pair from the grid. | |
| const OrderedPair & | back () const |
| Returns a reference to the last ordered pair. | |
| void | clear () |
| Delete all ordered pairs from the grid. | |
| ExtrapolationMethod | extrapolation_method () const |
| Get the ExtrapolationMethod used by this InterpolationGrid. | |
| const OrderedPair & | front () const |
| Returns a reference to the first ordered pair. | |
| std::function< SecondNumericType(FirstNumericType) > | get_function () |
| Get a std::function object that represents y(x) for this InterpolationGrid. | |
| void | insert (FirstNumericType x, SecondNumericType y) |
| Add a new ordered pair (x, y) to the grid. | |
| SecondNumericType | interpolate (FirstNumericType x) const |
| Compute y(x) using the current InterpolationMethod. | |
| InterpolationMethod | interpolation_method () const |
| Get the InterpolationMethod used by this InterpolationGrid. | |
| GridConstIterator | lower_bound (const GridConstIterator &begin, const GridConstIterator &end, FirstNumericType x) const |
| Returns a const_iterator to the first element of the grid for which the x value is not less than (i.e. greater than or equal to) x. | |
| void | set_extrapolation_method (ExtrapolationMethod method) |
| Set the ExtrapolationMethod to use. | |
| void | set_interpolation_method (InterpolationMethod method) |
| Set the InterpolationMethod to use. | |
| size_t | size () const |
| Get the number of ordered pairs on the grid. | |
| GridConstIterator | upper_bound (const GridConstIterator &begin, const GridConstIterator &end, FirstNumericType x) const |
| Returns a const_iterator to the first element of the grid for which the x value is greater than x. | |
One-dimensional function y(x) defined using a grid of ordered pairs (x,y) and an interpolation rule.
This class implements the one-dimensional interpolation rules described in the ENDF-6 formats manual for a grid of (x,y) pairs.
| FirstNumericType | type for the x values |
| SecondNumericType | type for the y values |
Definition at line 37 of file InterpolationGrid.hh.
| using marley::InterpolationGrid< FirstNumericType, SecondNumericType >::Grid = std::vector<OrderedPair> |
Definition at line 42 of file InterpolationGrid.hh.
| using marley::InterpolationGrid< FirstNumericType, SecondNumericType >::GridConstIterator = typename std::vector<OrderedPair>::const_iterator |
Definition at line 43 of file InterpolationGrid.hh.
| using marley::InterpolationGrid< FirstNumericType, SecondNumericType >::OrderedPair = std::pair<FirstNumericType, SecondNumericType> |
Definition at line 41 of file InterpolationGrid.hh.
|
strong |
Method to use for computing y(x) when the x value lies beyond the grid boundaries.
The table below describes how y(x) is calculated using each of the allowed ExtrapolationMethod settings. In the notation used below, the lowest x value is called \(x_\text{left}\), the greatest x value is called \(x_\text{right}\), and their corresponding y values are called \(y_\text{left}\) and \(y_\text{right}\), respectively. The ExtrapolationMethod is only relevant when \(x < x_\text{left}\) or \(x > x_\text{right}\).
| Method | Description |
|---|---|
| Zero | \(y = 0\) |
| Endpoint | \(y = \begin{cases} y_\text{left} & x < x_\text{left} \\ y_\text{right} & x > x_\text{right} \end{cases}\) |
| Continue | Use the usual InterpolationMethod formula with \(y = \begin{cases} y_1 = y_\text{left} \text{ and } y_2 = y_{\text{left}+1} & x < x_\text{left} \\ y_1 = y_{\text{right}-1} \text{ and } y_2 = y_\text{right} & x > x_\text{right} \end{cases}\) where \(y_{\text{left}+1}\) is the y value corresponding to the second-lowest x value, and \(y_{\text{right}-1}\) is the y value corresponding to the second-highest x value. |
Definition at line 96 of file InterpolationGrid.hh.
|
strong |
Method to use for interpolating between (x,y) grid points.
For \(x_1 \leq x < x_2\), the table below describes how the corresponding y value is calculated using each of the allowed InterpolationMethod settings.
| Method | Description |
|---|---|
| Constant | \(y = y_1\) |
| LinearLinear | \(y = y_1 + \frac{y_2 - y_1}{x_2 - x_1}(x - x_1) \) |
| LinearLog | \(y = \exp\left[\ln(y_1) + \frac{\ln(y_2) - \ln(y_1)}{x_2 - x_1}(x - x_1)\right] \) |
| LogLinear | \(y = y_1 + \frac{y_2 - y_1}{\ln[x_2] - \ln[x_1]}[\ln(x) - \ln(x_1)] \) |
| LogLog | \(y = \exp\left[\ln(y_1) + \frac{\ln(y_2) - \ln(y_1)}{\ln(x_2) - \ln(x_1)}(\ln[x] - \ln[x_1])\right] \) |
Definition at line 63 of file InterpolationGrid.hh.
|
inline |
Create an InterpolationGrid without any grid points.
Definition at line 100 of file InterpolationGrid.hh.
|
inline |
Create an InterpolationGrid from a vector of ordered pairs.
Definition at line 108 of file InterpolationGrid.hh.
|
inline |
Create an InterpolationGrid from vectors of x and y values.
Definition at line 118 of file InterpolationGrid.hh.
|
inline |
Get a reference to the jth ordered pair from the grid.
Definition at line 152 of file InterpolationGrid.hh.
|
inline |
Returns a reference to the last ordered pair.
Definition at line 187 of file InterpolationGrid.hh.
|
inline |
Delete all ordered pairs from the grid.
Definition at line 149 of file InterpolationGrid.hh.
|
inline |
Get the ExtrapolationMethod used by this InterpolationGrid.
Definition at line 198 of file InterpolationGrid.hh.
|
inline |
Returns a reference to the first ordered pair.
Definition at line 184 of file InterpolationGrid.hh.
|
inline |
Get a std::function object that represents y(x) for this InterpolationGrid.
Definition at line 156 of file InterpolationGrid.hh.
| void marley::InterpolationGrid< FirstNumericType, SecondNumericType >::insert | ( | FirstNumericType | x, |
| SecondNumericType | y ) |
Add a new ordered pair (x, y) to the grid.
Definition at line 343 of file InterpolationGrid.hh.
References upper_bound().
| SecondNumericType marley::InterpolationGrid< FirstNumericType, SecondNumericType >::interpolate | ( | FirstNumericType | x | ) | const |
Compute y(x) using the current InterpolationMethod.
Definition at line 269 of file InterpolationGrid.hh.
References interpolate().
Referenced by marley::InterpolationMethod< double >::get_function(), and interpolate().
|
inline |
Get the InterpolationMethod used by this InterpolationGrid.
Definition at line 190 of file InterpolationGrid.hh.
|
inline |
Returns a const_iterator to the first element of the grid for which the x value is not less than (i.e. greater than or equal to) x.
Definition at line 164 of file InterpolationGrid.hh.
|
inline |
Set the ExtrapolationMethod to use.
Definition at line 202 of file InterpolationGrid.hh.
|
inline |
Set the InterpolationMethod to use.
Definition at line 194 of file InterpolationGrid.hh.
|
inline |
Get the number of ordered pairs on the grid.
Definition at line 146 of file InterpolationGrid.hh.
|
inline |
Returns a const_iterator to the first element of the grid for which the x value is greater than x.
Definition at line 174 of file InterpolationGrid.hh.
Referenced by insert().