SpectralKit
This is a very simple package for building blocks of spectral methods. Its intended audience is users who are familiar with the theory and practice of these methods, and prefer to assemble their code from modular building blocks, potentially reusing calculations. If you need an introduction, a book like Boyd (2001): Chebyshev and Fourier spectral methods is a good place to start.
This package was designed primarily for solving functional equations, as usually encountered in economics when solving discrete and continuous-time problems. Key features include
- evaluation of univariate and multivatiate basis functions, including Smolyak combinations,
- transformed to the relevant domains of interest, eg $[a,b] × [0,∞)$,
- (partial) derivatives, with correct limits at endpoints,
- allocation-free, thread safe linear combinations for the above with a given set of coefficients,
- using static arrays extensively to avoid allocation and unroll some loops.
While there is some functionality in this package to fit approximations to existing functions, it does not use optimized algorithms (DCT) for that, as it was optimized for mapping a set of coefficients to residuals of functional equations at gridpoints.
Also, while the package should interoperate seamlessly with most AD frameworks, only the derivative API (explained below) is guaranteed to have correct derivatives of limits near infinity.
Concepts
In this package,
A basis is a finite family of functions for approximating other functions. The
dimension
of a basis tells you how many functions are in there, whiledomain
can be used to query its domain.A
grid
is vector of suggested gridpoints for evaluating the function to be approximated that has useful theoretical properties. You can contruct acollocation_matrix
using this grid (or any other set of points). Grids are associated with bases at the time of their construction: a basis with the same set of functions can have different grids.basis_at
returns an iterator for evaluating basis functions at an arbitrary point inside their domain. This iterator is meant to be heavily optimized and non-allocating.linear_combination
is a convenience wrapper for obtaining a linear combination of basis functions at a given point.
Univariate basis example
We construct a basis of Chebyshev polynomials on $[0, 4]$. This requires a transformation since their canonical domain is $[-1,1]$. Other transformations include SemiInfRational
for $[A, \infty]$ intervals and InfRational
for $[-\infty, \infty]$ intervals.
We display the domian and the dimension (number of basis functions).
julia> using SpectralKit
julia> basis = Chebyshev(InteriorGrid(), 5) ∘ BoundedLinear(0, 4)
SpectralKit.TransformedBasis{Chebyshev{InteriorGrid}, BoundedLinear{Float64}}(Chebyshev polynomials (1st kind), InteriorGrid(), dimension: 5, (0.0,4.0) ↔ domain [linear transformation])
julia> domain(basis)
[0.0,4.0]
julia> dimension(basis)
5
We have chosen an interior grid, shown below. We collect
the result for the purpose of this tutorial, since grid
returns an iterable to avoid allocations.
julia> collect(grid(basis))
5-element Vector{Float64}: +
SpectralKit · SpectralKit.jl source+union(∂(2, 1), ∂(1, 2))SpectralKit
This is a very simple package for building blocks of spectral methods. Its intended audience is users who are familiar with the theory and practice of these methods, and prefer to assemble their code from modular building blocks, potentially reusing calculations. If you need an introduction, a book like Boyd (2001): Chebyshev and Fourier spectral methods is a good place to start.
This package was designed primarily for solving functional equations, as usually encountered in economics when solving discrete and continuous-time problems. Key features include
- evaluation of univariate and multivatiate basis functions, including Smolyak combinations,
- transformed to the relevant domains of interest, eg $[a,b] × [0,∞)$,
- (partial) derivatives, with correct limits at endpoints,
- allocation-free, thread safe linear combinations for the above with a given set of coefficients,
- using static arrays extensively to avoid allocation and unroll some loops.
While there is some functionality in this package to fit approximations to existing functions, it does not use optimized algorithms (DCT) for that, as it was optimized for mapping a set of coefficients to residuals of functional equations at gridpoints.
Also, while the package should interoperate seamlessly with most AD frameworks, only the derivative API (explained below) is guaranteed to have correct derivatives of limits near infinity.
Concepts
In this package,
A basis is a finite family of functions for approximating other functions. The
dimension
of a basis tells you how many functions are in there, whiledomain
can be used to query its domain.A
grid
is vector of suggested gridpoints for evaluating the function to be approximated that has useful theoretical properties. You can contruct acollocation_matrix
using this grid (or any other set of points). Grids are associated with bases at the time of their construction: a basis with the same set of functions can have different grids.
basis_at
returns an iterator for evaluating basis functions at an arbitrary point inside their domain. This iterator is meant to be heavily optimized and non-allocating.linear_combination
is a convenience wrapper for obtaining a linear combination of basis functions at a given point.Univariate basis example
We construct a basis of Chebyshev polynomials on $[0, 4]$. This requires a transformation since their canonical domain is $[-1,1]$. Other transformations include
SemiInfRational
for $[A, \infty]$ intervals andInfRational
for $[-\infty, \infty]$ intervals.We display the domian and the dimension (number of basis functions).
julia> using SpectralKit
julia> basis = Chebyshev(InteriorGrid(), 5) ∘ BoundedLinear(0, 4)
SpectralKit.TransformedBasis{Chebyshev{InteriorGrid}, BoundedLinear{Float64}}(Chebyshev polynomials (1st kind), InteriorGrid(), dimension: 5, (0.0,4.0) ↔ domain [linear transformation])
julia> domain(basis)
[0.0,4.0]
julia> dimension(basis)
5
We have chosen an interior grid, shown below. We
collect
the result for the purpose of this tutorial, sincegrid
returns an iterable to avoid allocations.julia> collect(grid(basis))
5-element Vector{Float64}: 3.9021130325903073 3.1755705045849463 2.0 @@ -58,14 +58,14 @@ 1.0 + 0.0⋅Δ -1.0 + 0.0⋅Δ 1.0 + -0.0⋅Δ - -1.0 + 0.0⋅Δ
Constructing bases
Grid specifications
SpectralKit.EndpointGrid
— Type sourcestruct EndpointGrid <: SpectralKit.AbstractGrid
Grid that includes endpoints (eg Gauss-Lobatto).
Note For small dimensions may fall back to a grid that does not contain endpoints.
SpectralKit.InteriorGrid
— Type sourcestruct InteriorGrid <: SpectralKit.AbstractGrid
Grid with interior points (eg Gauss-Chebyshev).
SpectralKit.InteriorGrid2
— Type sourcestruct InteriorGrid2 <: SpectralKit.AbstractGrid
Grid with interior points that results in smaller grids than
InteriorGrid
when nested. Equivalent to anEndpointGrid
with endpoints dropped.Domains and transformations
A transformation maps values between a domain, usually specified by the basis, and the (co)domain that is specified by a transformation. Transformations are not required to be subtypes of anything, but need to support
SpectralKit.transform_to
— Function source
transform_to(domain, transformation, x)
Transform
x
todomain
usingtransformation
.
domain
can be replaced bybasis
for a shortcut which usesdomain(basis)
.Transformations to infinity make sure that $\pm\infty$ is mapped to the limit for values and derivatives.
SpectralKit.transform_from
— Function source
transform_from(domain, transformation, x)
Transform
x
fromdomain
usingtransformation
.
domain
can be replaced bybasis
for a shortcut which usesdomain(basis)
.Transformations to infinity make sure that $\pm\infty$ is mapped to the limit for values and derivatives.
SpectralKit.domain
— Function source
domain(basis)
The domain of a function basis.
domain(transformation)
The (co)domain of a transformation. The “other” domain (codomain, depending on the mapping) is provided explicitly for transformations, and should be compatible with the
domain
of the basis.See
domain_kind
for the interface supported by domains.In most cases you do not need to specify a domain directly: transformations specify their domains (eg from $(0, ∞)$), and the codomain is determined by a basis. However, the following can be used to construct and query some concrete domains.
SpectralKit.domain_kind
— Function sourcedomain_kind(x) -
Return the kind of a domain type (preferred) or value. Errors for objects/types which are not domains. Also works for domains of transformations.
The following return values are possible:
:univariate
, the bounds of which can be accessed usingminimum
,maximum
, and
extrema
,
:multivariate
, which supportslength
,getindex
([]
), and conversion withTuple
.SpectralKit.coordinate_domains
— Function sourcecoordinate_domains(domains) -
Create domains which are the product of univariate domains. The result support
length
, indexing with integers, andTuple
for conversion. sourcecoordinate_domains(domains) -
sourcecoordinate_domains(_, domain) -
Create a coordinate domain which is the product of
domain
repeatedN
times. sourcecoordinate_domains(N, domain) -
Bases are defined on a canonical domain, such as $[-1, 1]$ for Chebyshev polynomials. Transformations map other uni- and multivariate sets into these domains.
SpectralKit.BoundedLinear
— Type sourcestruct BoundedLinear{T<:Real} <: SpectralKit.AbstractUnivariateTransformation
Transform the domain to
y ∈ (a, b)
, using $y = x ⋅ s + m$.
m
ands
are calculated and checked by the constructor;a < b
is enforced.SpectralKit.InfRational
— Type sourceInfRational(A, L) -
The domain transformed to
(-Inf, Inf)
using $y = A + L ⋅ x / √(1 - x^2)$, withL > 0
.Example mappings (for domain $(-1,1)$)
- $0 ↦ A$
- $±0.5 ↦ A ± L / √3$
SpectralKit.SemiInfRational
— Type sourceSemiInfRational(A, L) -
The domian transformed to
[A, Inf)
(whenL > 0
) or(-Inf,A]
(whenL < 0
) using $y = A + L ⋅ (1 + x) / (1 - x)$.When used with Chebyshev polynomials, also known as a “rational Chebyshev” basis.
Example mappings for the domain $(-1,1)$
- $-1/2 ↦ A + L / 3$
- $0 ↦ A + L$
- $1/2 ↦ A + 3 ⋅ L$
SpectralKit.coordinate_transformations
— Functioncoordinate_transformations(transformations) + -1.0 + 0.0⋅Δ
Constructing bases
Grid specifications
SpectralKit.EndpointGrid
— Type sourcestruct EndpointGrid <: SpectralKit.AbstractGrid
Grid that includes endpoints (eg Gauss-Lobatto).
Note For small dimensions may fall back to a grid that does not contain endpoints.
SpectralKit.InteriorGrid
— Type sourcestruct InteriorGrid <: SpectralKit.AbstractGrid
Grid with interior points (eg Gauss-Chebyshev).
SpectralKit.InteriorGrid2
— Type sourcestruct InteriorGrid2 <: SpectralKit.AbstractGrid
Grid with interior points that results in smaller grids than
InteriorGrid
when nested. Equivalent to anEndpointGrid
with endpoints dropped.Domains and transformations
A transformation maps values between a domain, usually specified by the basis, and the (co)domain that is specified by a transformation. Transformations are not required to be subtypes of anything, but need to support
SpectralKit.transform_to
— Function source
transform_to(domain, transformation, x)
Transform
x
todomain
usingtransformation
.
domain
can be replaced bybasis
for a shortcut which usesdomain(basis)
.Transformations to infinity make sure that $\pm\infty$ is mapped to the limit for values and derivatives.
SpectralKit.transform_from
— Function source
transform_from(domain, transformation, x)
Transform
x
fromdomain
usingtransformation
.
domain
can be replaced bybasis
for a shortcut which usesdomain(basis)
.Transformations to infinity make sure that $\pm\infty$ is mapped to the limit for values and derivatives.
SpectralKit.domain
— Function source
domain(basis)
The domain of a function basis.
domain(transformation)
The (co)domain of a transformation. The “other” domain (codomain, depending on the mapping) is provided explicitly for transformations, and should be compatible with the
domain
of the basis.See
domain_kind
for the interface supported by domains.In most cases you do not need to specify a domain directly: transformations specify their domains (eg from $(0, ∞)$), and the codomain is determined by a basis. However, the following can be used to construct and query some concrete domains.
SpectralKit.domain_kind
— Function sourcedomain_kind(x) +
Return the kind of a domain type (preferred) or value. Errors for objects/types which are not domains. Also works for domains of transformations.
The following return values are possible:
:univariate
, the bounds of which can be accessed usingminimum
,maximum
, and
extrema
,
:multivariate
, which supportslength
,getindex
([]
), and conversion withTuple
.SpectralKit.coordinate_domains
— Function sourcecoordinate_domains(domains) +
Create domains which are the product of univariate domains. The result support
length
, indexing with integers, andTuple
for conversion. sourcecoordinate_domains(domains) +
sourcecoordinate_domains(_, domain) +
Create a coordinate domain which is the product of
domain
repeatedN
times. sourcecoordinate_domains(N, domain) +
Bases are defined on a canonical domain, such as $[-1, 1]$ for Chebyshev polynomials. Transformations map other uni- and multivariate sets into these domains.
SpectralKit.BoundedLinear
— Type sourcestruct BoundedLinear{T<:Real} <: SpectralKit.AbstractUnivariateTransformation
Transform the domain to
y ∈ (a, b)
, using $y = x ⋅ s + m$.
m
ands
are calculated and checked by the constructor;a < b
is enforced.SpectralKit.InfRational
— Type sourceInfRational(A, L) +
The domain transformed to
(-Inf, Inf)
using $y = A + L ⋅ x / √(1 - x^2)$, withL > 0
.Example mappings (for domain $(-1,1)$)
- $0 ↦ A$
- $±0.5 ↦ A ± L / √3$
SpectralKit.SemiInfRational
— Type sourceSemiInfRational(A, L) +
The domian transformed to
[A, Inf)
(whenL > 0
) or(-Inf,A]
(whenL < 0
) using $y = A + L ⋅ (1 + x) / (1 - x)$.When used with Chebyshev polynomials, also known as a “rational Chebyshev” basis.
Example mappings for the domain $(-1,1)$
- $-1/2 ↦ A + L / 3$
- $0 ↦ A + L$
- $1/2 ↦ A + 3 ⋅ L$
SpectralKit.coordinate_transformations
— Function sourcecoordinate_transformations(transformations)
Wrapper for coordinate-wise transformations. To extract components, convert to Tuple.
julia> using StaticArrays julia> ct = coordinate_transformations(BoundedLinear(0, 2), SemiInfRational(2, 3)) @@ -83,9 +83,9 @@ (1.4, 11.0) julia> y = transform_to(dom, ct, x) -(0.3999999999999999, 0.5)
Univariate bases
Currently, only Chebyshev polynomials are implemented. Univariate bases operate on real numbers.
SpectralKit.Chebyshev
— Type sourcestruct Chebyshev{K<:SpectralKit.AbstractGrid} <: SpectralKit.UnivariateBasis
The first
N
Chebyhev polynomials of the first kind, defined on[-1,1]
.Multivariate bases
Multivariate bases operate on tuples or vectors (
StaticArrays.SVector
is preferred for performance, but all<:AbstractVector
types should work).SpectralKit.SmolyakParameters
— Type sourceSmolyakParameters(B) +(0.3999999999999999, 0.5)
Univariate bases
Currently, only Chebyshev polynomials are implemented. Univariate bases operate on real numbers.
SpectralKit.Chebyshev
— Type sourcestruct Chebyshev{K<:SpectralKit.AbstractGrid} <: SpectralKit.UnivariateBasis
The first
N
Chebyhev polynomials of the first kind, defined on[-1,1]
.Multivariate bases
Multivariate bases operate on tuples or vectors (
StaticArrays.SVector
is preferred for performance, but all<:AbstractVector
types should work).SpectralKit.SmolyakParameters
— Type sourceSmolyakParameters(B) SmolyakParameters(B, M) -
Parameters for Smolyak grids that are independent of the dimension of the domain.
Polynomials are organized into blocks (of eg
1, 2, 2, 4, 8, 16, …
) polynomials (and corresponding gridpoints), indexed with a block indexb
that starts at0
.B ≥ ∑ bᵢ
and0 ≤ bᵢ ≤ M
constrain the number of blocks along each dimensioni
.
M > B
is not an error, but will be normalized toM = B
with a warning.SpectralKit.smolyak_basis
— Function sourcesmolyak_basis( +
Parameters for Smolyak grids that are independent of the dimension of the domain.
Polynomials are organized into blocks (of eg
1, 2, 2, 4, 8, 16, …
) polynomials (and corresponding gridpoints), indexed with a block indexb
that starts at0
.B ≥ ∑ bᵢ
and0 ≤ bᵢ ≤ M
constrain the number of blocks along each dimensioni
.
M > B
is not an error, but will be normalized toM = B
with a warning.SpectralKit.smolyak_basis
— Function sourcesmolyak_basis( univariate_family, grid_kind, smolyak_parameters, @@ -100,17 +100,17 @@ 81 julia> domain(basis) -[-1,1]²
Properties
Grids nest: increasing arguments of
SmolyakParameters
result in a refined grid that contains points of the cruder grid.Using bases
Introspection
SpectralKit.is_function_basis
— Function source
is_function_basis(::Type{F})
is_function_basis(f::F)
Test if the argument (value or type) is a function basis, supporting the following interface:
domain
for querying the domain,
dimension
for the dimension,
basis_at
for function evaluation,
grid
to obtain collocation points.
length
andgetindex
for multivariate bases(domain_kind(domain(basis)) == :multivariate)
, getindex returns a compatible marginal basis
linear_combination
andcollocation_matrix
are also supported, building on the above.Can be used on both types (preferred) and values (for convenience).
SpectralKit.dimension
— Function source
dimension(basis)
Return the dimension of
basis
, a positiveInt
.SpectralKit.transformation
— Function sourcetransformation(basis) -
Return the transformation of transformed bases, or
nothing
it not applicable.See also
domain
.Evaluation
SpectralKit.basis_at
— Function source
basis_at(basis, x)
Return an iterable with known element type and length (
Base.HasEltype()
,Base.HasLength()
) of basis functions inbasis
evaluated atx
.Univariate bases operate on real numbers, while for multivariate bases,
Tuple
s orStaticArrays.SVector
are preferred for performance, though all<:AbstractVector
types should work.Methods are type stable.
Note Consequences are undefined when evaluating outside the domain.
SpectralKit.linear_combination
— Function sourcelinear_combination(basis, θ, x) -
Evaluate the linear combination of $∑ θₖ⋅fₖ(x)$ of function basis $f₁, …$ at
x
, for the given order.The length of
θ
should equaldimension(θ)
. sourcelinear_combination(basis, θ) -
Return a callable that calculates
linear_combination(basis, θ, x)
when called withx
.You can use
linear_combination(basis, θ) ∘ transformation
for domain transformations, though working withbasis ∘ transformation
may be preferred.Grids and collocation
SpectralKit.grid
— Function source
grid([T], basis)
Return an iterator for the grid recommended for collocation, with
dimension(basis)
elements.
T
for the element type of grid coordinates, and defaults toFloat64
. Methods are type stable.SpectralKit.collocation_matrix
— Function sourcecollocation_matrix(basis) +[-1,1]²
Properties
Grids nest: increasing arguments of
SmolyakParameters
result in a refined grid that contains points of the cruder grid.Using bases
Introspection
SpectralKit.is_function_basis
— Function source
is_function_basis(::Type{F})
is_function_basis(f::F)
Test if the argument (value or type) is a function basis, supporting the following interface:
domain
for querying the domain,
dimension
for the dimension,
basis_at
for function evaluation,
grid
to obtain collocation points.
length
andgetindex
for multivariate bases(domain_kind(domain(basis)) == :multivariate)
, getindex returns a compatible marginal basis
linear_combination
andcollocation_matrix
are also supported, building on the above.Can be used on both types (preferred) and values (for convenience).
SpectralKit.dimension
— Function source
dimension(basis)
Return the dimension of
basis
, a positiveInt
.SpectralKit.transformation
— Function sourcetransformation(basis) +
Return the transformation of transformed bases, or
nothing
it not applicable.See also
domain
.Evaluation
SpectralKit.basis_at
— Function source
basis_at(basis, x)
Return an iterable with known element type and length (
Base.HasEltype()
,Base.HasLength()
) of basis functions inbasis
evaluated atx
.Univariate bases operate on real numbers, while for multivariate bases,
Tuple
s orStaticArrays.SVector
are preferred for performance, though all<:AbstractVector
types should work.Methods are type stable.
Note Consequences are undefined when evaluating outside the domain.
SpectralKit.linear_combination
— Function sourcelinear_combination(basis, θ, x) +
Evaluate the linear combination of $∑ θₖ⋅fₖ(x)$ of function basis $f₁, …$ at
x
, for the given order.The length of
θ
should equaldimension(θ)
. sourcelinear_combination(basis, θ) +
Return a callable that calculates
linear_combination(basis, θ, x)
when called withx
.You can use
linear_combination(basis, θ) ∘ transformation
for domain transformations, though working withbasis ∘ transformation
may be preferred.Grids and collocation
SpectralKit.grid
— Function source
grid([T], basis)
Return an iterator for the grid recommended for collocation, with
dimension(basis)
elements.
T
for the element type of grid coordinates, and defaults toFloat64
. Methods are type stable.SpectralKit.collocation_matrix
— Function sourcecollocation_matrix(basis) collocation_matrix(basis, x) -
Convenience function to obtain a “collocation matrix” at points
x
, which is assumed to have a concreteeltype
. The default isx = grid(basis)
, specialized methods may exist for this when it makes sense.The collocation matrix may not be an
AbstractMatrix
, all it needs to support isC \ y
for compatible vectorsy = f.(x)
.Methods are type stable. The elements of
x
can be derivatives, see𝑑
.Augment coordinates for a wider basis
SpectralKit.augment_coefficients
— Function source
augment_coefficients(basis1, basis2, θ1)
Return a set of coefficients
θ2
forbasis2
such thatlinear_combination(basis1, θ1, x) == linear_combination(basis2, θ2, x)
for any
x
in the domain. In practice this means padding with zeros.Throw a
ArgumentError
if the bases are incompatible with each other orx
, or this is not possible. Methods may not be defined for incompatible bases, compatibility between bases can be checked withis_subset_basis
.SpectralKit.is_subset_basis
— Function sourceis_subset_basis(basis1, basis2) -
Return a
Bool
indicating whether coefficients inbasis1
can be augmented tobasis2
withaugment_coefficients
.Note
true
does not mean that coefficients frombasis1
can just be padded with zeros, since they may be in different positions. Always useaugment_coefficients
.Derivatives
Note API for derivatives is still experimental and subject to change.
For univariate functions, use
𝑑
. For multivariate functions, use partial derivatives with∂
.SpectralKit.𝑑
— Constant sourceA callable that calculates the value and the derivative of the argument. Higher-order derivatives can be obtained by using an exponent, or multiplication.
julia> 𝑑(2.0) +
Convenience function to obtain a “collocation matrix” at points
x
, which is assumed to have a concreteeltype
. The default isx = grid(basis)
, specialized methods may exist for this when it makes sense.The collocation matrix may not be an
AbstractMatrix
, all it needs to support isC \ y
for compatible vectorsy = f.(x)
.Methods are type stable. The elements of
x
can be derivatives, see𝑑
.Augment coordinates for a wider basis
SpectralKit.augment_coefficients
— Function source
augment_coefficients(basis1, basis2, θ1)
Return a set of coefficients
θ2
forbasis2
such thatlinear_combination(basis1, θ1, x) == linear_combination(basis2, θ2, x)
for any
x
in the domain. In practice this means padding with zeros.Throw a
ArgumentError
if the bases are incompatible with each other orx
, or this is not possible. Methods may not be defined for incompatible bases, compatibility between bases can be checked withis_subset_basis
.SpectralKit.is_subset_basis
— Function sourceis_subset_basis(basis1, basis2) +
Return a
Bool
indicating whether coefficients inbasis1
can be augmented tobasis2
withaugment_coefficients
.Note
true
does not mean that coefficients frombasis1
can just be padded with zeros, since they may be in different positions. Always useaugment_coefficients
.Derivatives
Note API for derivatives is still experimental and subject to change.
For univariate functions, use
𝑑
. For multivariate functions, use partial derivatives with∂
.SpectralKit.𝑑
— Constant sourceA callable that calculates the value and the derivative of the argument. Higher-order derivatives can be obtained by using an exponent, or multiplication.
julia> 𝑑(2.0) 2.0 + 1.0⋅Δ julia> (𝑑^3)(2.0) -2.0 + 1.0⋅Δ + 0.0⋅Δ² + 0.0⋅Δ³
Note that non-literal exponentiation requires
^Val(y)
, for type stability.See
linear_combination
for examples of evaluating derivatives of basis functions and linear combinations.SpectralKit.∂
— Function source∂(I) +2.0 + 1.0⋅Δ + 0.0⋅Δ² + 0.0⋅Δ³
Note that non-literal exponentiation requires
^Val(y)
, for type stability.See
linear_combination
for examples of evaluating derivatives of basis functions and linear combinations.SpectralKit.∂
— Function source∂(I)
Partial derivatives along the given coordinates.
!!! NOTE Partial derivatives are currently experimental and not heavily tested. API may change at any point without prior notice or deprecation.
The following are equivalent, and represent $\partial_1 \partial^2_2$, ie the first derivative along the first axis, and the second partial derivative along the second axis.
julia> ∂(1, 2) ∂(1, 2) @@ -121,5 +121,5 @@ julia> ∂((1, 0)) ERROR: ArgumentError: I ≡ () || last(I) ≠ 0 must hold.
Use the empty form for no derivatives:
julia> ∂() ∂()
Combine derivatives using
union
or∪
:julia> ∂(1, 2) ∪ ∂(2, 1) -union(∂(2, 1), ∂(1, 2))
Internals
This section of the documentation is probably only relevant to contributors and others who want to understand the internals.
Type hierarchies
Generally, the abstract types below are not part of the exposed API, and new types don't have to subtype them (unless they want to rely on the existing convenience methods). They are merely for code organization.
SpectralKit.AbstractUnivariateDomain
— Type sourceUnivariate domain representation. Supports
extrema
,minimum
,maximum
.Note Implementations only need to define
extrema
.Grid internals
SpectralKit.gridpoint
— Function sourcegridpoint(_, basis, i) -
Return a gridpoint for collocation, with
1 ≤ i ≤ dimension(basis)
.
T
is used as a hint for the element type of grid coordinates. The actual type can be broadened as required. Methods are type stable.Note Not all grids have this method defined, especially if it is impractical. See
grid
, which is part of the API, this function isn't.Settings
This document was generated with Documenter.jl version 1.4.1 on Tuesday 18 June 2024. Using Julia version 1.9.4.