Chebyshev Suite

Einstein.ChebyshevSuite.ChebyshevGaussCoeffs2ValsPlanType
cheb_gauss_coeffs2vals(coeffs::AbstractVector{TFC}) where {TFC<:Union{AbstractFloat,Complex{<:AbstractFloat}}}
cheb_gauss_coeffs2vals_plan([TFC=Float64], n::Integer)(coeffs::AbstractVector{TFC}) where {TFC<:Union{AbstractFloat,Complex{<:AbstractFloat}}}

Convert Chebyshev coefficients to values at Chebyshev points of the 1st kind.

Performance Guide

For best performance, especially in loops or repeated calls:

plan = cheb_gauss_coeffs2vals_plan(Float64, n)
values = plan * coeffs

References

source
Einstein.ChebyshevSuite.ChebyshevGaussVals2CoeffsPlanType
cheb_gauss_vals2coeffs(vals::AbstractVector{TF}) where {TF<:AbstractFloat}
cheb_gauss_vals2coeffs_plan([TFC=Float64], n::Integer)(vals::AbstractVector{TFC}) where {TFC<:Union{AbstractFloat,Complex{<:AbstractFloat}}}

Convert values at Chebyshev points of the 1st kind into Chebyshev coefficients.

Performance Guide

For best performance, especially in loops or repeated calls:

plan = cheb_gauss_vals2coeffs_plan(Float64, n)
coeffs = plan * values

References

source
Einstein.ChebyshevSuite.ChebyshevLobattoCoeffs2ValsPlanType
cheb_lobatto_coeffs2vals(coeffs::AbstractVector{TFC}) where {TFC<:Union{AbstractFloat,Complex{<:AbstractFloat}}}
cheb_lobatto_coeffs2vals_plan([TFC=Float64], n::Integer)(coeffs::AbstractVector{TFC}) where {TFC<:Union{AbstractFloat,Complex{<:AbstractFloat}}}

Convert Chebyshev coefficients to values at Chebyshev points of the 2nd kind.

Performance Guide

For best performance, especially in loops or repeated calls:

plan = cheb_lobatto_coeffs2vals_plan(Float64, n)
values = plan * coeffs

References

source
Einstein.ChebyshevSuite.ChebyshevLobattoVals2CoeffsPlanType
cheb_lobatto_vals2coeffs(vals::AbstractVector{TFC}) where {TFC<:Union{AbstractFloat,Complex{<:AbstractFloat}}}
cheb_lobatto_vals2coeffs_plan([TFC=Float64], n::Integer)(vals::AbstractVector{TFC}) where {TFC<:Union{AbstractFloat,Complex{<:AbstractFloat}}}

Convert values at Chebyshev points of the 2nd kind into Chebyshev coefficients.

Performance Guide

For best performance, especially in loops or repeated calls:

plan = cheb_lobatto_vals2coeffs_plan(Float64, n)
coeffs = plan * values

References

source
Einstein.ChebyshevSuite.cheb_filter_matrixMethod
cheb_filter_matrix(weights::AbstractVector{TF}, S::AbstractMatrix{TF}, A::AbstractMatrix{TF}; negsum::Bool=true) where TF<:AbstractFloat

Construct a filter matrix using precomputed weights and operators for Chebyshev collocation methods, optionally applying the 'negative sum trick', which seems make the simulation more stable according to my tests.

Arguments

  • weights: Vector of filter weights
  • S: Chebyshev synthesis matrix: maps Chebyshev series to function values at Chebyshev grid points
  • A: Chebyshev analysis matrix: maps function values at Chebyshev grid points to Chebyshev series
  • negative_sum_trick: Boolean flag for negative sum trick (default: true)

The function applies the weights through diagonal scaling and implements the negative sum trick for diagonal elements when negative_sum_trick is true.

source
Einstein.ChebyshevSuite.cheb_gauss_anglesMethod
cheb_gauss_angles(TF, n) where {TF<:AbstractFloat}

Compute angles for Chebyshev points of the 1st kind:

\[\theta_k = \frac{(2k + 1)\pi}{2n}, \quad k = n-1,\ldots,0\]

Arguments

  • TF: Type parameter for the angles (e.g., Float64)
  • n: Number of points
source
Einstein.ChebyshevSuite.cheb_gauss_coeffs2vals_matrixMethod
cheb_gauss_coeffs2vals_matrix([TF=Float64], n::Integer) where {TF<:AbstractFloat}

Construct the synthesis matrix S that transforms Chebyshev coefficients to function values at Chebyshev points of the 1st kind.

Arguments

  • TF: Element type (defaults to Float64)
  • n: Number of points/coefficients
source
Einstein.ChebyshevSuite.cheb_gauss_differentiation_matrixMethod
cheb_gauss_differentiation_matrix([TR=Float64], n::Integer, k::Integer=1) where {TR<:AbstractFloat}
cheb_gauss_differentiation_matrix([TR=Float64], n::Integer, domain_width::TR, k::Integer=1) where {TR<:AbstractFloat}

Construct a Chebyshev differentiation that maps function values at n Chebyshev points of the 1st kind to values of the k-th derivative of the interpolating polynomial at those points.

Arguments

  • TR: Element type (defaults to Float64)
  • n::Integer: Number of Chebyshev points
  • k::Integer=1: Order of the derivative (default: 1)

References

source
Einstein.ChebyshevSuite.cheb_gauss_integration_matrixMethod
cheb_gauss_integration_matrix([TF=Float64], n::Integer) where {TF<:AbstractFloat}
cheb_gauss_integration_matrix([TF=Float64], n::Integer, domain_width::TF) where {TF<:AbstractFloat}

Compute Chebyshev integration matrix that maps function values at n Chebyshev points of the 1st kind to values of the integral of the interpolating polynomial at those points, with the convention that the first value is zero.

References

source
Einstein.ChebyshevSuite.cheb_gauss_pointsMethod
cheb_gauss_points([TF=Float64], n::Integer) where {TF<:AbstractFloat}
cheb_gauss_points([TF=Float64], n::Integer, lower_bound::TF, upper_bound::TF) where {TF<:AbstractFloat}

Generate Chebyshev points of the 2nd kind.

For the standard interval [-1,1]:

\[x_k = -\cos\left(\frac{(2k + 1)\pi}{2n}\right), \quad k = 0,1,\ldots,n-1\]

For mapped interval [lowerbound,upperbound]:

\[x_{\mathrm{mapped}} = \frac{x_{\mathrm{max}} + x_{\mathrm{min}}}{2} + \frac{x_{\mathrm{min}} - x_{\mathrm{max}}}{2}x_k\]

Arguments

  • TF: Type parameter for the grid points (e.g., Float64)
  • n: Number of points
  • lower_bound: (Optional) Lower bound of the mapped interval
  • upper_bound: (Optional) Upper bound of the mapped interval

References

source
Einstein.ChebyshevSuite.cheb_gauss_vals2coeffs_matrixMethod
cheb_gauss_vals2coeffs_matrix([TF=Float64], n::Integer) where {TF<:AbstractFloat}

Construct the analysis matrix A that transforms function values at Chebyshev points of the 1st kind to Chebyshev coefficients.

Arguments

  • TF: Element type (defaults to Float64)
  • n: Number of points/coefficients
source
Einstein.ChebyshevSuite.cheb_lobatto_anglesMethod
cheb_lobatto_angles(TF, n) where {TF<:AbstractFloat}

Compute angles for Chebyshev points of the 2nd kind:

\[\theta_k = \frac{k\pi}{n-1}, \quad k = n-1,\ldots,0\]

Arguments

  • TF: Type parameter for the angles (e.g., Float64)
  • n: Number of points
source
Einstein.ChebyshevSuite.cheb_lobatto_coeffs2vals_matrixMethod
cheb_lobatto_coeffs2vals_matrix([TF=Float64], n::Integer) where {TF<:AbstractFloat}

Construct the synthesis matrix S that transforms Chebyshev coefficients to function values at Chebyshev points of the 2nd kind.

Arguments

  • TF: Element type (defaults to Float64)
  • n: Number of points/coefficients
source
Einstein.ChebyshevSuite.cheb_lobatto_differentiation_matrixMethod
cheb_lobatto_differentiation_matrix([TR=Float64], n::Integer, k::Integer=1) where {TR<:AbstractFloat}
cheb_lobatto_differentiation_matrix([TR=Float64], n::Integer, domain_width::TR, k::Integer=1) where {TR<:AbstractFloat}

Construct a Chebyshev differentiation that maps function values at n Chebyshev points of the 2nd kind to values of the k-th derivative of the interpolating polynomial at those points.

Arguments

  • TR: Element type (defaults to Float64)
  • n::Integer: Number of Chebyshev points
  • k::Integer=1: Order of the derivative (default: 1)

References

source
Einstein.ChebyshevSuite.cheb_lobatto_integration_matrixMethod
cheb_lobatto_integration_matrix([TF=Float64], n::Integer) where {TF<:AbstractFloat}
cheb_lobatto_integration_matrix([TF=Float64], n::Integer, domain_width::TF) where {TF<:AbstractFloat}

Compute Chebyshev integration matrix that maps function values at n Chebyshev points of the 2st kind to values of the integral of the interpolating polynomial at those points, with the convention that the first value is zero.

References

source
Einstein.ChebyshevSuite.cheb_lobatto_pointsMethod
cheb_lobatto_points([TF=Float64], n::Integer) where {TF<:AbstractFloat}
cheb_lobatto_points([TF=Float64], n::Integer, lower_bound::TF, upper_bound::TF) where {TF<:AbstractFloat}

Generate Chebyshev points of the 1st kind.

For the standard interval [-1,1]:

\[x_k = -\cos\left(\frac{k\pi}{n-1}\right), \quad k = 0,1,\ldots,n-1\]

For mapped interval [lowerbound,upperbound]:

\[x_{\mathrm{mapped}} = \frac{x_{\mathrm{max}} + x_{\mathrm{min}}}{2} + \frac{x_{\mathrm{min}} - x_{\mathrm{max}}}{2}x_k\]

Arguments

  • TF: Type parameter for the grid points (e.g., Float64)
  • n: Number of points
  • lower_bound: (Optional) Lower bound of the mapped interval
  • upper_bound: (Optional) Upper bound of the mapped interval

References

source
Einstein.ChebyshevSuite.cheb_lobatto_vals2coeffs_matrixMethod
cheb_lobatto_vals2coeffs_matrix([TF=Float64], n::Integer) where {TF<:AbstractFloat}

Construct the analysis matrix A that transforms function values at Chebyshev points of the 2nd kind to Chebyshev coefficients.

Arguments

  • TF: Element type (defaults to Float64)
  • n: Number of points/coefficients
source
Einstein.ChebyshevSuite.cheb_series_derivative!Method
cheb_series_derivative!(coeffs::AbstractVector{TFC}) where {TFC<:Union{AbstractFloat,Complex{<:AbstractFloat}}}
cheb_series_derivative!(coeffs_der::AbstractVector{TFC}, coeffs::AbstractVector{TFC}) where {TFC<:Union{AbstractFloat,Complex{<:AbstractFloat}}}
cheb_series_derivative(coeffs::AbstractVector{TFC}) where {TFC<:Union{AbstractFloat,Complex{<:AbstractFloat}}}

Compute derivatives of coefficients of Chebyshev series.

Arguments

  • coeffs: Input vector of Chebyshev coefficients with length n

References

source
Einstein.ChebyshevSuite.cheb_series_evaluateMethod
cheb_series_evaluate(coeffs::AbstractVector{TFC}, x::TF) where {TF<:AbstractFloat,TFC<:Union{TF,Complex{TF}}
cheb_series_evaluate(coeffs::AbstractVector{TFC}, x::AbstractVector{TF}) where {TF<:AbstractFloat,TFC<:Union{TF,Complex{TF}}

Evaluate Chebyshev coefficients at point(s) using Clenshaw's algorithm.

Performance Notes

  • Clenshaw's algorithm: O(n) operations per point
  • [TODO] NDCT: O(n log n) operations for many points simultaneously

References

source
Einstein.ChebyshevSuite.cheb_series_filter_weights_expMethod
cheb_series_filter_weights_exp([TF=Float64], n::Integer, a::Integer, p::Integer) where {TF<:AbstractFloat}

Compute exponential filter weights for Chebyshev series [SLS09].

\[w_k = e^{-\alpha\left(k / n\right)^{2 p}}, \quad k = 0, \ldots, n-1\]

Arguments

  • TF: Type parameter for floating-point precision
  • n: Number of grid points
  • α: Filter strength parameter
  • p: Order of filter

Examples

  • \[\alpha = 36\]

    and $p = 32$ for weak filter [SLS09, HWB16]
  • \[\alpha = 40\]

    and $p = 8$ for strong filter [Rip23]
source
Einstein.ChebyshevSuite.cheb_series_integrate!Method
cheb_series_integrate(df::AbstractVector{TFC}) where {TFC<:Union{AbstractFloat,Complex{<:AbstractFloat}}}
cheb_series_integrate!(f::AbstractVector{TFC}, df::AbstractVector{TFC}) where {TFC<:Union{AbstractFloat,Complex{<:AbstractFloat}}}

Compute the indefinite integral of a function $f'(x)$ given its Chebyshev series, with the constant of integration chosen such that $f(-1) = 0$.

Mathematical Details

If the input function $f'(x)$ is represented by a Chebyshev series of length $n$:

\[f'(x) = \sum_{r=0}^{n-1} c_r T_r(x)\]

its integral $f(x)$ is represented by a Chebyshev series of length $n+1$:

\[f(x) = \sum_{r=0}^{n} b_r T_r(x)\]

where:

  • \[b_0\]

    is determined from the constant of integration as:

\[b_0 = \sum_{r=1}^{n} (-1)^{r+1} b_r\]

  • The other coefficients are given by:

\[b_1 = c_0 - c_2/2 b_r = (c_{r-1} - c_{r+1})/(2r) \text{ for } r > 1\]

with $c_{n+1} = c_{n+2} = 0$.

Arguments

  • df: Vector of Chebyshev series coefficients of $f'$
  • f: Vector of Chebyshev series coefficients of $f$

References

source
Einstein.ChebyshevSuite.cheb_series_integration_matrixMethod
cheb_series_integration_matrix([TR=Float64], n::Integer) where {TR<:AbstractFloat}
cheb_series_integration_matrix([TR=Float64], n::Integer, domain_width::TR) where {TR<:AbstractFloat}

Generate the Chebyshev coefficient integration matrix that maps Chebyshev coefficients to the coefficients of the integral of the interpolating polynomial.

Arguments

  • TR: Type parameter for the matrix elements (e.g., Float64)
  • n: Size of the matrix (n×n)
  • domain_width: (Optional) Width of the integration interval

References

source

Chebyshev grids of first or second kind