SpECTRE  v2026.04.01
Loading...
Searching...
No Matches
intrp Namespace Reference

Contains classes and functions for interpolation. More...

Namespaces

namespace  Actions
 Holds Actions for Interpolator and InterpolationTarget.
namespace  callbacks
 Contains callback functions called by InterpolationTargets.
namespace  protocols
 Contains all protocols used in the interpolation framework.
namespace  Tags
 Tags for items held in the DataBox of InterpolationTarget or Interpolator.

Classes

class  BarycentricRational
 A barycentric rational interpolation class. More...
class  BarycentricRationalSpanInterpolator
 Performs a barycentric interpolation with an order in a range fixed at construction; this class can be chosen via the options factory mechanism as a possible SpanInterpolator. More...
class  Cardinal
 Interpolates by doing partial summation in each dimension using one-dimensional interpolation. More...
struct  ComputeExcisionBoundaryVolumeQuantities
 Given the generalized harmonic variables in the volume, computes the quantities that will be interpolated onto an excision boundary. More...
class  CubicSpanInterpolator
 Performs a cubic interpolation; this class can be chosen via the options factory mechanism as a possible SpanInterpolator. More...
class  CubicSpline
 A natural cubic spline interpolation class. More...
struct  InterpolationTarget
 ParallelComponent representing a set of points to be interpolated to and a function to call upon interpolation to those points. More...
class  Irregular
 Interpolates a Variables onto an arbitrary set of points. More...
struct  LinearRegressionResult
class  LinearSpanInterpolator
 Performs a linear interpolation; this class can be chosen via the options factory mechanism as a possible SpanInterpolator More...
class  MultiLinearSpanInterpolation
 Performs linear interpolation in arbitrary dimensions. The class is non-owning and expects a C-ordered array, (n, x, y, z). The variable index, n, varies fastest in memory. Note that this class is intentionally non-pupable. More...
class  RegularGrid
 Interpolate data from a Mesh onto a regular grid of points. More...
class  SpanInterpolator
 Base class for interpolators so that the factory options mechanism can be used. More...
class  ZeroCrossingPredictor
 A class that predicts when a function crosses zero. More...

Typedefs

template<size_t Dimension, size_t NumberOfVariables>
using UniformMultiLinearSpanInterpolation
 Multilinear span interpolation with uniform grid spacing.
template<size_t Dimension, size_t NumberOfVariables>
using GeneralMultiLinearSpanInterpolation
 Multilinear span interpolation with non-uniform grid spacing.

Functions

template<size_t Dim>
bool operator== (const Cardinal< Dim > &lhs, const Cardinal< Dim > &rhs)
template<size_t Dim>
bool operator!= (const Cardinal< Dim > &lhs, const Cardinal< Dim > &rhs)
template<size_t Dim>
bool operator!= (const Irregular< Dim > &lhs, const Irregular< Dim > &rhs)
template<typename T>
LinearRegressionResult linear_regression (const T &x_values, const T &y_values)
 A linear regression function.
template<size_t Degree>
void polynomial_interpolation (gsl::not_null< double * > y, gsl::not_null< double * > error_in_y, double target_x, const gsl::span< const double > &y_values, const gsl::span< const double > &x_values)
 Interpolate y_values to target_x from tabulated x_values using a polynomial interpolant of degree Degree.
double predicted_zero_crossing_value (const std::vector< double > &x_values, const std::vector< double > &y_values)
 Predicts the zero crossing of a function.
DataVector predicted_zero_crossing_value (const std::deque< double > &x_values, const std::deque< DataVector > &y_values)
 Predicts the zero crossing of multiple functions.
template<size_t Dim>
bool operator!= (const RegularGrid< Dim > &lhs, const RegularGrid< Dim > &rhs)
bool operator!= (const ZeroCrossingPredictor &, const ZeroCrossingPredictor &)
template<size_t Order, typename T>
std::array< double, Order+1 > linear_least_squares (const T &x_values, const T &y_values)
 A linear least squares solver.
template<size_t Order, typename T>
std::vector< std::array< double, Order+1 > > linear_least_squares (const T &x_values, const std::vector< T > &y_values)
 A linear least squares solver.

Detailed Description

Contains classes and functions for interpolation.

Typedef Documentation

◆ GeneralMultiLinearSpanInterpolation

template<size_t Dimension, size_t NumberOfVariables>
using intrp::GeneralMultiLinearSpanInterpolation
Initial value:
Performs linear interpolation in arbitrary dimensions. The class is non-owning and expects a C-ordere...
Definition MultiLinearSpanInterpolation.hpp:35

Multilinear span interpolation with non-uniform grid spacing.

◆ UniformMultiLinearSpanInterpolation

template<size_t Dimension, size_t NumberOfVariables>
using intrp::UniformMultiLinearSpanInterpolation
Initial value:

Multilinear span interpolation with uniform grid spacing.

Function Documentation

◆ polynomial_interpolation()

template<size_t Degree>
void intrp::polynomial_interpolation ( gsl::not_null< double * > y,
gsl::not_null< double * > error_in_y,
double target_x,
const gsl::span< const double > & y_values,
const gsl::span< const double > & x_values )

Interpolate y_values to target_x from tabulated x_values using a polynomial interpolant of degree Degree.

error_in_y is an estimate of the error of the interpolated value. Note that at least in the tests this is a significant overestimate of the errors (several orders of magnitude). However, this could be because in the test the polynomial can be represented exactly when all terms are present, but incurs significant errors when the largest degree term is omitted.

◆ predicted_zero_crossing_value() [1/2]

DataVector intrp::predicted_zero_crossing_value ( const std::deque< double > & x_values,
const std::deque< DataVector > & y_values )

Predicts the zero crossing of multiple functions.

For the ith element of the DataVector inside y_values, calls predicted_zero_crossing_value(x_values,y_values[:][i]), where we have used python-like notation.

◆ predicted_zero_crossing_value() [2/2]

double intrp::predicted_zero_crossing_value ( const std::vector< double > & x_values,
const std::vector< double > & y_values )

Predicts the zero crossing of a function.

Fits a linear function to a set of y_values at different x_values and uses the fit to predict what x_value the y_value zero will be crossed.

predicted_zero_crossing treats x=0 in a special way: All of the x_values must be non-positive; one of the x_values is typically (but is not required to be) zero. In typical usage, x is time, and x=0 is the current time, and we are interested in whether the function crosses zero in the past or in the future. If it cannot be determined (within the error bars of the fit) whether the zero crossing occurs for x < 0 versus x > 0, then we return zero. Otherwise we return the best-fit x for when the function crosses zero.

Details

We fit to a straight line: y = intercept + slope*x. So our best guess is that the function will cross zero at x_best_fit = -intercept/slope.

However, the data are assumed to be noisy. The fit gives us error bars for the slope and the intercept. Given the error bars, we can compute four limiting crossing values x0, x1, x2, and x3 by using the maximum and minimum possible values of slope and intercept. For example, if we assume slope<0 and intercept>0, then the earliest possible crossing consistent with the error bars is x3=(-intercept+delta_intercept)/(slope-delta_slope) and the latest possible crossing consistent with the error bars is x0=(-intercept-delta_intercept)/(slope+delta_slope).

We compute all four crossing values and demand that all of them are either at x>0 (i.e. in the future if x is time) or at x<0 (i.e. in the past if x is time). Otherwise we conclude that we cannot determine even the sign of the crossing value, so we return zero.