Chebyshev Suite
Einstein.ChebyshevSuite.ChebyshevGaussGrid
Einstein.ChebyshevSuite.ChebyshevLobattoGrid
Einstein.ChebyshevSuite.ChebyshevGaussCoeffs2ValsPlan
Einstein.ChebyshevSuite.ChebyshevGaussVals2CoeffsPlan
Einstein.ChebyshevSuite.ChebyshevLobattoCoeffs2ValsPlan
Einstein.ChebyshevSuite.ChebyshevLobattoVals2CoeffsPlan
Einstein.ChebyshevSuite.cheb_filter_matrix
Einstein.ChebyshevSuite.cheb_gauss_angles
Einstein.ChebyshevSuite.cheb_gauss_barycentric_weights
Einstein.ChebyshevSuite.cheb_gauss_coeffs2vals_matrix
Einstein.ChebyshevSuite.cheb_gauss_differentiation_matrix
Einstein.ChebyshevSuite.cheb_gauss_integration_matrix
Einstein.ChebyshevSuite.cheb_gauss_points
Einstein.ChebyshevSuite.cheb_gauss_quadrature_weights
Einstein.ChebyshevSuite.cheb_gauss_vals2coeffs_matrix
Einstein.ChebyshevSuite.cheb_lobatto_angles
Einstein.ChebyshevSuite.cheb_lobatto_barycentric_weights
Einstein.ChebyshevSuite.cheb_lobatto_coeffs2vals_matrix
Einstein.ChebyshevSuite.cheb_lobatto_differentiation_matrix
Einstein.ChebyshevSuite.cheb_lobatto_integration_matrix
Einstein.ChebyshevSuite.cheb_lobatto_points
Einstein.ChebyshevSuite.cheb_lobatto_quadrature_weights
Einstein.ChebyshevSuite.cheb_lobatto_vals2coeffs_matrix
Einstein.ChebyshevSuite.cheb_series_chop
Einstein.ChebyshevSuite.cheb_series_derivative!
Einstein.ChebyshevSuite.cheb_series_evaluate
Einstein.ChebyshevSuite.cheb_series_filter_weights_exp
Einstein.ChebyshevSuite.cheb_series_integrate!
Einstein.ChebyshevSuite.cheb_series_integration_matrix
Einstein.ChebyshevSuite.ChebyshevGaussCoeffs2ValsPlan
— Typecheb_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
Einstein.ChebyshevSuite.ChebyshevGaussVals2CoeffsPlan
— Typecheb_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
Einstein.ChebyshevSuite.ChebyshevLobattoCoeffs2ValsPlan
— Typecheb_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
Einstein.ChebyshevSuite.ChebyshevLobattoVals2CoeffsPlan
— Typecheb_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
Einstein.ChebyshevSuite.cheb_filter_matrix
— Methodcheb_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 weightsS
: Chebyshev synthesis matrix: maps Chebyshev series to function values at Chebyshev grid pointsA
: Chebyshev analysis matrix: maps function values at Chebyshev grid points to Chebyshev seriesnegative_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.
Einstein.ChebyshevSuite.cheb_gauss_angles
— Methodcheb_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
Einstein.ChebyshevSuite.cheb_gauss_barycentric_weights
— Methodcheb_gauss_barycentric_weights([TF=Float64], n::Integer) where {TF<:AbstractFloat}
Compute the barycentric weights for Chebyshev points of the 1st kind.
Arguments
TF
: Type parameter for the weights (defaults to Float64)n
: Number of points
References
See also: BarycentricInterpolation
Einstein.ChebyshevSuite.cheb_gauss_coeffs2vals_matrix
— Methodcheb_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
Einstein.ChebyshevSuite.cheb_gauss_differentiation_matrix
— Methodcheb_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 pointsk::Integer=1
: Order of the derivative (default: 1)
References
Einstein.ChebyshevSuite.cheb_gauss_integration_matrix
— Methodcheb_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
Einstein.ChebyshevSuite.cheb_gauss_points
— Methodcheb_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 pointslower_bound
: (Optional) Lower bound of the mapped intervalupper_bound
: (Optional) Upper bound of the mapped interval
References
Einstein.ChebyshevSuite.cheb_gauss_quadrature_weights
— Methodcheb_gauss_quadrature_weights([TF=Float64], n::Integer) where {TF<:AbstractFloat}
cheb_gauss_quadrature_weights([TF=Float64], n::Integer, domain_width::TF) where {TF<:AbstractFloat}
Compute quadrature weights for Chebyshev points of the 1st kind.
Arguments
TF
: Type parameter for the weights (e.g., Float64)n
: Number of points
References
Einstein.ChebyshevSuite.cheb_gauss_vals2coeffs_matrix
— Methodcheb_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
Einstein.ChebyshevSuite.cheb_lobatto_angles
— Methodcheb_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
Einstein.ChebyshevSuite.cheb_lobatto_barycentric_weights
— Methodcheb_lobatto_barycentric_weights([TF=Float64], n::Integer) where {TF<:AbstractFloat}
Compute the barycentric weights for Chebyshev points of the 2nd kind.
Arguments
TF
: Type parameter for the weights (e.g., Float64)n
: Number of points
References
See also: BarycentricInterpolation
Einstein.ChebyshevSuite.cheb_lobatto_coeffs2vals_matrix
— Methodcheb_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
Einstein.ChebyshevSuite.cheb_lobatto_differentiation_matrix
— Methodcheb_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 pointsk::Integer=1
: Order of the derivative (default: 1)
References
Einstein.ChebyshevSuite.cheb_lobatto_integration_matrix
— Methodcheb_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
Einstein.ChebyshevSuite.cheb_lobatto_points
— Methodcheb_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 pointslower_bound
: (Optional) Lower bound of the mapped intervalupper_bound
: (Optional) Upper bound of the mapped interval
References
Einstein.ChebyshevSuite.cheb_lobatto_quadrature_weights
— Methodcheb_lobatto_quadrature_weights([TF=Float64], n::Integer) where {TF<:AbstractFloat}
cheb_lobatto_quadrature_weights([TF=Float64], n::Integer, domain_width::TF) where {TF<:AbstractFloat}
Compute quadrature weights for Chebyshev points of the 2nd kind.
Arguments
TF
: Type parameter for the weights (e.g., Float64)n
: Number of points
References
Einstein.ChebyshevSuite.cheb_lobatto_vals2coeffs_matrix
— Methodcheb_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
Einstein.ChebyshevSuite.cheb_series_chop
— Methodcheb_series_chop(coeffs::AbstractVector{TF}, tol::TF = eps(TF)) where {TF<:AbstractFloat}
Determine a suitable cutoff index for a coefficient vector using the "standard" chopping rule [AT15].
References
- Aurentz and Trefethen [AT15] Aurentz, J. L., & Trefethen, L. N. (2015). Chopping a Chebyshev series. ACM Transactions on Mathematical Software (TOMS), 41(4), 1-18.
- chebfun/standardChop.m (Implementation in Chebfun, MATLAB)
Einstein.ChebyshevSuite.cheb_series_derivative!
— Methodcheb_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
Einstein.ChebyshevSuite.cheb_series_evaluate
— Methodcheb_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
Einstein.ChebyshevSuite.cheb_series_filter_weights_exp
— Methodcheb_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 precisionn
: Number of grid pointsα
: Filter strength parameterp
: Order of filter
Examples
Einstein.ChebyshevSuite.cheb_series_integrate!
— Methodcheb_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
Einstein.ChebyshevSuite.cheb_series_integration_matrix
— Methodcheb_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
Chebyshev grids of first or second kind
Einstein.ChebyshevSuite.ChebyshevGaussGrid
— ModuleThe ChebyshevGaussGrid
module provides a comprehensive set of tools for working with Chebyshev points of the 1st kind and coefficients of the corresponding 1st-kind Chebyshev series expansion.
The module is designed to work with the standard interval [-1,1] by default, but also supports mapped intervals [a,b] through appropriate scaling transformations.
References
Einstein.ChebyshevSuite.ChebyshevLobattoGrid
— ModuleThe ChebyshevLobattoGrid
module provides a comprehensive set of tools for working with Chebyshev points of the 2nd kind and coefficients of the corresponding 1st-kind Chebyshev series expansion.
The module is designed to work with the standard interval [-1,1] by default, but also supports mapped intervals [a,b] through appropriate scaling transformations.
References