Skip to content

TensorSpace in ProductFun constructor #541

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 2 commits into from
Aug 5, 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
6 changes: 4 additions & 2 deletions src/Multivariate/ProductFun.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ true
```
"""
function ProductFun(M::AbstractVector{VFun{S,T}}, dy::V) where {S<:UnivariateSpace,V<:UnivariateSpace,T<:Number}
prodsp = ProductSpace(map(space, M), dy)
ProductFun{S,V,typeof(prodsp),T}(copy(M), prodsp)
sp = mapreduce(space, maxspace, M)
Msp = [Fun(f, sp) for f in M]
prodsp = sp ⊗ dy
ProductFun{S,V,typeof(prodsp),T}(Msp, prodsp)
end

## Adaptive construction
Expand Down
2 changes: 2 additions & 0 deletions src/Multivariate/TensorSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ domain(f::ProductSpace) = f.domain

factors(d::ProductSpace) = (d.spacesx, d.spacey)

show(io::IO, P::ProductSpace) = print(io, "ProductSpace", factors(P))

## Transforms
function nDtransform_inner!(A, tempv, Rpre, Rpost, dim, plan!)
for indpost in Rpost, indpre in Rpre
Expand Down
11 changes: 9 additions & 2 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@testset "ConstantSpace" begin
@test contains(repr(ConstantSpace()), "ConstantSpace")
c = ConstantSpace(0..1)
@test contains(repr(c), "ConstantSpace")
@test startswith(repr(c), "ConstantSpace")
@test contains(repr(c), repr(domain(c)))
end
@testset "TensorSpace" begin
Expand All @@ -21,6 +21,13 @@
@test length(v) == 2
@test all(==(repr(S1)), v)
end
@testset "ProductSpace" begin
S1 = PointSpace(1:4)
S2 = PointSpace(1:2)
P = ProductSpace([S1, S1], S2)
@test startswith(repr(P), "ProductSpace")
@test contains(repr(P), string(factors(P)))
end
@testset "SumSpace" begin
S1 = PointSpace(1:3)
S = S1 ⊕ S1
Expand All @@ -32,7 +39,7 @@
p = PointSpace(1:4)
ps = PiecewiseSpace(p)
rpr = repr(ps)
@test contains(rpr, "PiecewiseSpace")
@test startswith(rpr, "PiecewiseSpace")
@test contains(rpr, repr(p))
end
end
Expand Down