SpECTRE Documentation Coverage Report
Current view: top level - NumericalAlgorithms/Interpolation - InterpolationWeights.hpp Hit Total Coverage
Commit: 3ffcbc8ecf43797401b60bcca17d6040ee06f013 Lines: 3 4 75.0 %
Date: 2026-03-03 02:01:44
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <cstddef>
       7             : #include "Utilities/Gsl.hpp"
       8             : 
       9             : /// \cond
      10             : class DataVector;
      11             : class Matrix;
      12             : /// \endcond
      13             : 
      14             : namespace intrp {
      15             : /*!
      16             :  * \brief Computes the matrix for polynomial interpolation of a non-periodic
      17             :  * function known at the set of points \f$x_{source}\f$ to the set of points
      18             :  * \f$x_{target}\f$
      19             :  *
      20             :  * \details The algorithm is from \cite Fornberg1998.  The returned matrix
      21             :  * \f$M\f$ will have \f$n_{target}\f$ rows and \f$n_{source}\f$ columns so that
      22             :  * \f$f_{target} = M f_{source}\f$
      23             :  *
      24             :  * \note The accuracy of the interpolation will depend upon the number and
      25             :  * distribution of the source points.  It is strongly suggested that you
      26             :  * carefully investigate the accuracy for your use case.
      27             :  */
      28             : template <typename TargetDataType>
      29           1 : Matrix fornberg_interpolation_matrix(const TargetDataType& x_target,
      30             :                                      const DataVector& x_source);
      31             : 
      32             : /*!
      33             :  * \brief Computes the weights for polynomial interpolation of a non-periodic
      34             :  * function known at the set of points \f$x_{source}\f$ to the point
      35             :  * \f$x_{target}\f$
      36             :  *
      37             :  * \details The algorithm is from \cite Fornberg1998. The DataVectors in the
      38             :  * array will be set to the size of \f$x_{source}\f$, where the first index
      39             :  * of the array holds the weights to interpolate a function from the grid
      40             :  * \f$x_{source}\f$ to \f$x_{target}\f$, the second index of the array holds
      41             :  * the weights to interpolate the first derivative of a function, and
      42             :  * so on.
      43             :  *
      44             :  * Calculating for the \f$n\f$-th derivative will yield all lower order
      45             :  * derivatives as well. If you just want the interpolation coefficients, use
      46             :  * `fornberg_interpolation_matrix`.
      47             :  *
      48             :  *
      49             :  * \note The accuracy of the interpolation will depend upon the number and
      50             :  * distribution of the source points.  It is strongly suggested that you
      51             :  * carefully investigate the accuracy for your use case.
      52             :  */
      53             : template <size_t MaxOrder>
      54           1 : void fornberg_derivative_interpolation_weights(
      55             :     gsl::not_null<std::array<DataVector, MaxOrder + 1>*> result,
      56             :     double x_target, const DataVector& x_source);
      57             : 
      58             : /*!
      59             :  * \brief Computes the matrix for interpolating a periodic function known at
      60             :  * the set of \f$n\f$ equally spaced points on the periodic domain \f$[0, 2
      61             :  * \pi]\f$ to the set of points \f$x_{target}\f$
      62             :  *
      63             :  * \details The returned matrix \f$M\f$ will have \f$n_{target}\f$ rows and
      64             :  * \f$n_{source}\f$ columns so that \f$f_{target} = M f_{source}\f$
      65             :  * Formally, this computes the sum
      66             :  * \f[ n w_j = 1 + 2 \sum_{k=1}^{\lfloor (n-1)/2 \rfloor} \cos(k(x - X_j))
      67             :  *     \left[ + \cos\left(\frac{n}{2}(x - X_j)\right) \right] \f]
      68             :  * for each target point \f$x\f$, where \f$ X_j = \frac{2 \pi j}{n}\f$, and
      69             :  * the term in brackets is evaluated only if \f$n\f$ is even.
      70             :  *
      71             :  */
      72             : template <typename TargetDataType>
      73           1 : Matrix fourier_interpolation_matrix(const TargetDataType& x_target,
      74             :                                     size_t n_source_points);
      75             : }  // namespace intrp

Generated by: LCOV version 1.14