Skip to content

Commit 6b777fe

Browse files
authored
ProductSpace domain type fix (#361)
* ProductSpace domain type fix * version bump to v0.7.65
1 parent 04082db commit 6b777fe

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
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.7.64"
3+
version = "0.7.65"
44

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

src/Multivariate/TensorSpace.jl

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ abstract type AbstractProductSpace{SV,DD,RR} <: Space{DD,RR} end
77

88
spacetype(::AbstractProductSpace{SV},k) where {SV} = SV.parameters[k]
99

10+
nfactors(d::AbstractProductSpace) = length(factors(d))
11+
factors(d::AbstractProductSpace) = d.spaces
12+
factor(d::AbstractProductSpace,k) = factors(d)[k]
13+
1014

1115
##### Tensorizer
1216
# This gives the map from coefficients to the
@@ -401,37 +405,34 @@ iterate(sp::TensorSpace{Tuple{S1,S2}},k...) where {S1,S2<:Space{D,R}} where {D,R
401405
# TODO: remove
402406
columnspace(S::TensorSpace,_) = S.spaces[1]
403407

408+
isambiguous(A::TensorSpace) = any(isambiguous, A.spaces)
409+
410+
Base.transpose(d::TensorSpace2D) = TensorSpace(d.spaces[2],d.spaces[1])
411+
404412

405413
struct ProductSpace{S<:Space,V<:Space,D,R} <: AbstractProductSpace{Tuple{S,V},D,R}
406414
spacesx::Vector{S}
407415
spacey::V
416+
domain::D
408417
end
409418

410419
function ProductSpace(spacesx::AbstractVector, spacey)
411-
ProductSpace{eltype(spacesx),typeof(spacey),typeof(mapreduce(domain, ×, spacesx)),
412-
mapreduce(s->eltype(domain(s)),promote_type,spacesx)}(spacesx,spacey)
420+
dx = domain(spacesx[1])
421+
@assert all(sp -> domain(sp) == dx, spacesx) "domains of component Funs must be identical"
422+
dy = domain(spacey)
423+
Tdx = mapreduce(s->eltype(domain(s)),promote_type,spacesx)
424+
Tdy = eltype(dy)
425+
Td = promote_type(Tdx, Tdy)
426+
d = convert(Domain{Td}, dx) × convert(Domain{Td}, dy)
427+
ProductSpace{eltype(spacesx),typeof(spacey),typeof(d),Td}(spacesx, spacey, d)
413428
end
414429

415430
# TODO: This is a weird definition
416431
(A::AbstractVector{S},B::Space) where {S<:Space} = ProductSpace(A,B)
417-
domain(f::ProductSpace) = domain(f.spacesx[1]) × domain(f.spacey)
432+
domain(f::ProductSpace) = f.domain
418433

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

421-
nfactors(d::AbstractProductSpace) = length(d.spaces)
422-
factors(d::AbstractProductSpace) = d.spaces
423-
factor(d::AbstractProductSpace,k) = factors(d)[k]
424-
425-
426-
isambiguous(A::TensorSpace) = isambiguous(A.spaces[1]) || isambiguous(A.spaces[2])
427-
428-
429-
Base.transpose(d::TensorSpace) = TensorSpace(d.spaces[2],d.spaces[1])
430-
431-
432-
433-
434-
435436
## Transforms
436437
function nDtransform_inner!(A, tempv, Rpre, Rpost, dim, plan!)
437438
for indpost in Rpost, indpre in Rpre

0 commit comments

Comments
 (0)