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

Generated by: LCOV version 2.0-1