Skip to content

Commit 46a9b26

Browse files
authored
Tuple recursion in KroneckerOperator banded checks (#343)
* tuple recursion in kronop banded checks * Version bump to v0.7.61 * fix isbandedblockbanded
1 parent e437f7e commit 46a9b26

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
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.60"
3+
version = "0.7.61"
44

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

src/Multivariate/TensorSpace.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ dimension(sp::TensorSpace) = mapreduce(dimension,*,sp.spaces)
305305
conversion_rule(a::TensorSpace{<:NTuple{2,Space}}, b::TensorSpace{<:NTuple{2,Space}}) =
306306
conversion_type(a.spaces[1],b.spaces[1]) conversion_type(a.spaces[2],b.spaces[2])
307307

308-
maxspace(a::TensorSpace{<:NTuple{2,Space}}, b::TensorSpace{<:NTuple{2,Space}}) =
308+
maxspace_rule(a::TensorSpace{<:NTuple{2,Space}}, b::TensorSpace{<:NTuple{2,Space}}) =
309309
maxspace(a.spaces[1],b.spaces[1]) maxspace(a.spaces[2],b.spaces[2])
310310

311311
function spacescompatible(A::TensorSpace{<:NTuple{N,Space}}, B::TensorSpace{<:NTuple{N,Space}}) where {N}
@@ -319,7 +319,7 @@ end
319319
canonicalspace(T::TensorSpace) = TensorSpace(map(canonicalspace,T.spaces))
320320

321321

322-
TensorSpace(A::SVector{N,<:Space}) where N = TensorSpace(tuple(A...))
322+
TensorSpace(A::SVector{<:Any,<:Space}) = TensorSpace(Tuple(A))
323323
TensorSpace(A...) = TensorSpace(A)
324324
TensorSpace(A::ProductDomain) = TensorSpace(tuple(map(Space,components(A))...))
325325
(A::TensorSpace,B::TensorSpace) = TensorSpace(A.spaces...,B.spaces...)

src/PDE/KroneckerOperator.jl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,22 @@ end
105105

106106
bandwidths(K::KroneckerOperator) = (ℵ₀,ℵ₀)
107107

108-
isblockbanded(K::KroneckerOperator) = all(isblockbanded,K.ops)
109-
isbandedblockbanded(K::KroneckerOperator) =
110-
all(op->isbanded(op) && isinf(size(op,1)) && isinf(size(op,2)),K.ops)
111-
israggedbelow(K::KroneckerOperator) = all(israggedbelow,K.ops)
112-
108+
for f in [:isblockbanded, :israggedbelow]
109+
_f = Symbol(:_, f)
110+
@eval begin
111+
$f(K::KroneckerOperator) = $(_f)(K.ops)
112+
function $(_f)(ops::Tuple)
113+
$f(first(ops)) && $(_f)(Base.tail(ops))
114+
end
115+
$(_f)(::Tuple{}) = true
116+
end
117+
end
118+
isbandedblockbanded(K::KroneckerOperator) = _isbandedblockbanded(K.ops)
119+
isbandedblockbandedcheck(op) = isbanded(op) && isinf(size(op,1)) && isinf(size(op,2))
120+
function _isbandedblockbanded(ops::Tuple)
121+
isbandedblockbandedcheck(first(ops)) && _isbandedblockbanded(Base.tail(ops))
122+
end
123+
_isbandedblockbanded(::Tuple{}) = true
113124

114125
blockbandwidths(K::KroneckerOperator) =
115126
(blockbandwidth(K.ops[1],1)+blockbandwidth(K.ops[2],1),

src/Space.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ union(a::Space, bs::Space...) = foldl(union, bs, init = a)
329329
"""
330330
hasconversion(a,b)
331331
332-
Test whether a banded `Conversion` operator exists.
332+
Test whether a banded `Conversion` operator exists from `a` to `b`.
333333
"""
334334
hasconversion(a,b) = maxspace(a,b) == b
335335

@@ -369,8 +369,6 @@ _Fun(v, sp) = Fun(v, sp)
369369
_maybeconvert(inplace::Val{true}, f, v) = v
370370
_maybeconvert(inplace::Val{false}, f::AbstractVector, v) = strictconvert(Vector{float(eltype(f))}, v)
371371
function defaultcoefficients(f,a,b,inplace = Val(false))
372-
ct=conversion_type(a,b) # gives a space that has a banded conversion to both a and b
373-
374372
x = if spacescompatible(a,b)
375373
f
376374
elseif hasconversion(a,b)

0 commit comments

Comments
 (0)