Skip to content

Make spaces callable #369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions src/Space.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ export Space, domainspace, rangespace, maxspace,Space,conversion_type, transform



# Space maps the Domain to the type R
# For example, we have
# Chebyshev{Interval{Float64}} <: Space{Interval{Float64},Float64}
# Laurent{PeriodicSegment{Float64}} <: Space{PeriodicSegment{Float64},ComplexF64}
# Fourier{Circle{ComplexF64}} <: Space{Circle{ComplexF64},Float64}
# Note for now Space doesn't contain any information about the coefficients
"""
Space{D<:Domain, R}

Abstract supertype of various spaces in which a `Fun` may be defined, where `R` represents
the type of the basis functions over the domain. Space maps the `Domain` to the type `R`.

For example, we have
* `Chebyshev{Interval{Float64}} <: Space{Interval{Float64},Float64}`
* `Laurent{PeriodicSegment{Float64}} <: Space{PeriodicSegment{Float64},ComplexF64}`
* `Fourier{Circle{ComplexF64}} <: Space{Circle{ComplexF64},Float64}`

!!! note
For now, `Space` doesn't contain any information about the coefficients
"""
abstract type Space{D,R} end


Expand Down Expand Up @@ -661,3 +668,33 @@ spacescompatible(::SequenceSpace,::SequenceSpace) = true
## Boundary

boundary(S::Space) = boundary(domain(S))

"""
(s::Space)(n::Integer)

Return a `Fun` with the coefficients being a sparse representation of
`[zeros(n); 1]`. The result is primarily meant to be evaluated at
a specific point.

For orthogonal polynomial spaces, the result will usually represent the `n`-th
basis function.

# Examples
```jldoctest
julia> Chebyshev()(2)
Fun(Chebyshev(), [0.0, 0.0, 1.0])
```
"""
(s::Space)(n::Integer) = basisfunction(s, n+1)
"""
(s::Space)(n::Integer, points...)

Evaluate `s(n)(points...)`

# Examples
```jldoctest
julia> Chebyshev()(1, 0.5)
0.5
```
"""
(s::Space)(n::Integer, args...) = s(n)(args...)
4 changes: 4 additions & 0 deletions test/SpacesTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ using LinearAlgebra
@test B isa Operator{ComplexF64}
@test ComplexF64.(Ainv[1:4, 1:4]) == B[1:4, 1:4]
end

@testset "call spaces" begin
@test PointSpace(1:4)(3, 4) == 1
end
end

@testset "DiracSpace" begin
Expand Down