diff --git a/Project.toml b/Project.toml index 2990148..89de0f1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ContinuumArrays" uuid = "7ae1f121-cc2c-504b-ac30-9b923412ae5c" -version = "0.20.3" +version = "0.20.4" [deps] AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c" diff --git a/docs/src/index.md b/docs/src/index.md index 27e814b..e685b7a 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -49,6 +49,9 @@ weaklaplacian ## Routines +```@docs +affine +``` ```@docs transform ``` diff --git a/src/ContinuumArrays.jl b/src/ContinuumArrays.jl index 60332a3..6e9a147 100644 --- a/src/ContinuumArrays.jl +++ b/src/ContinuumArrays.jl @@ -3,7 +3,7 @@ using IntervalSets, DomainSets, LinearAlgebra, LazyArrays, FillArrays, BandedMat import Base: @_inline_meta, @_propagate_inbounds_meta, axes, size, getindex, convert, prod, *, /, \, +, -, ==, ^, IndexStyle, IndexLinear, ==, OneTo, tail, similar, copyto!, copy, diff, first, last, show, isempty, findfirst, findlast, findall, Slice, union, minimum, maximum, extrema, sum, _sum, _maximum, _minimum, - getproperty, isone, iszero, zero, abs, <, ≤, >, ≥, string, summary, to_indices, view, @propagate_inbounds + getproperty, isone, iszero, zero, abs, <, ≤, >, ≥, string, summary, to_indices, view, @propagate_inbounds, collect import Base.Broadcast: materialize, BroadcastStyle, broadcasted, Broadcasted import LazyArrays: MemoryLayout, Applied, ApplyStyle, flatten, _flatten, colsupport, combine_mul_styles, AbstractArrayApplyStyle, adjointlayout, arguments, _mul_arguments, call, broadcastlayout, layout_getindex, UnknownLayout, @@ -37,6 +37,7 @@ cardinality(::AbstractInterval) = ℵ₁ cardinality(::Union{FullSpace{<:AbstractFloat},EuclideanDomain,DomainSets.RealNumbers,DomainSets.ComplexNumbers}) = ℵ₁ cardinality(::Union{DomainSets.Integers,DomainSets.Rationals,DomainSets.NaturalNumbers}) = ℵ₀ +Inclusion(d::ProductDomain{T}) where T = Inclusion{float(T)}(d) Inclusion(d::AbstractInterval{T}) where T = Inclusion{float(T)}(d) first(S::Inclusion{<:Any,<:AbstractInterval}) = leftendpoint(S.domain) last(S::Inclusion{<:Any,<:AbstractInterval}) = rightendpoint(S.domain) @@ -102,6 +103,10 @@ checkpoints(d::AbstractInterval{T}) where T = width(d) .* SVector{3,float(T)}(0. checkpoints(d::UnionDomain) = mapreduce(checkpoints,union,d.domains) checkpoints(x::Inclusion) = checkpoints(x.domain) checkpoints(A::AbstractQuasiMatrix) = checkpoints(axes(A,1)) +function checkpoints(P::ProductDomain) + x,y = map(checkpoints, components(P)) + SVector.(x, y') +end include("operators.jl") diff --git a/src/bases/bases.jl b/src/bases/bases.jl index a9a52c2..4e3d074 100644 --- a/src/bases/bases.jl +++ b/src/bases/bases.jl @@ -376,7 +376,9 @@ function expand(v) end - +expand(g::Base.Generator{<:Inclusion}) = expand(g.f.(g.iter)) +expand(g::Base.Generator{<:Domain}) = expand(Base.Generator(g.f, Inclusion(g.iter))) +expand(g::Base.Generator{<:Base.Iterators.ProductIterator{<:Tuple{Vararg{Domain}}}}) = expand(Base.Generator(g.f, ×(g.iter.iterators...))) @inline copy(L::Ldiv{<:AbstractBasisLayout}) = basis_ldiv_size(size(L), L.A, L.B) diff --git a/src/maps.jl b/src/maps.jl index 2ca2efe..31d96a9 100644 --- a/src/maps.jl +++ b/src/maps.jl @@ -147,6 +147,13 @@ end first(A::AffineMap{T}) where T = convert(T, first(A.range))::T last(A::AffineMap{T}) where T = convert(T, last(A.range))::T +""" + affine(a, b) + +constructs a quasivector corresponding to the affine map between two domains/quasivectors. For example: + + affine(1..2, 2..3)[1.5] == 2.5 +""" affine(a::AbstractQuasiVector, b::AbstractQuasiVector) = AffineMap(a, b) affine(a, b::AbstractQuasiVector) = affine(Inclusion(a), b) affine(a::AbstractQuasiVector, b) = affine(a, Inclusion(b)) diff --git a/test/test_chebyshev.jl b/test/test_chebyshev.jl index fc6298c..938570c 100644 --- a/test/test_chebyshev.jl +++ b/test/test_chebyshev.jl @@ -295,4 +295,9 @@ Base.:(==)(::FooBasis, ::FooBasis) = true @test_throws ErrorException maximum(exp.(x)) @test_throws ErrorException minimum(exp.(x)) end + + @testset "generator" begin + @test expand(exp(t) for t in -1..1)[0.1] ≈ [exp(t) for t in -1..1][0.1] ≈ exp(0.1) + @test [exp(x*cos(y)) for x in Inclusion(0:0.5:1), y in Inclusion(1:0.5:2)][0.5,1.5] ≈ exp(0.5*cos(1.5)) + end end