Skip to content

Commit 36d0546

Browse files
authored
Add a function normalizedspace that dispatches to the appropriate type (#459)
* Add normalize for spaces * remove doctest example * rename normalize to normalizedspace
1 parent 4112724 commit 36d0546

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunBase"
22
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
3-
version = "0.8.20"
3+
version = "0.8.21"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/ApproxFunBase.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ export pad!, pad, chop!, sample,
104104
export .., Interval, ChebyshevInterval, leftendpoint, rightendpoint
105105
export endpoints, cache
106106

107+
export normalizedspace
108+
107109
import Base: oneto
108110

109111
# assert that the conversion succeeds. This helps with inference as well as sanity

src/Spaces/Spaces.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,12 @@ end
199199

200200
include("HeavisideSpace.jl")
201201
include("DiracSpace.jl")
202+
203+
"""
204+
normalizedspace(S::Space)
205+
206+
Return a normalized space (or a direct sum of such spaces) over `domain(S)`.
207+
For polynomial spaces, this corresponds to normalized polynomials over the same domain.
208+
For a `DirectSumSpace`, this returns a direct sum over normalized spaces.
209+
"""
210+
normalizedspace

src/Spaces/SumSpace.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,3 +499,8 @@ component(sp::TensorSpace{Tuple{S1,S2}},k::Integer) where {S1,S2<:DirectSumSpace
499499

500500
component(sp::TensorSpace{Tuple{S1,S2}},k::Integer,j::Integer) where {S1<:DirectSumSpace,S2<:DirectSumSpace} =
501501
component(factor(sp,1),k) component(factor(sp,2),j)
502+
503+
# Normalized space
504+
normalizedspace(S::DirectSumSpace) = mapreduce(normalizedspace, , components(S))
505+
normalizedspace(S::SumSpace) = SumSpace(map(normalizedspace, components(S)))
506+
normalizedspace(S::PiecewiseSpace) = _PiecewiseSpace(map(normalizedspace, components(S)))

0 commit comments

Comments
 (0)