Skip to content

Commit 2b3ebb0

Browse files
authored
Conditionally forward domain to wrapper op (#383)
* conditionally forward domain to wrapper op * version bump to v0.7.74
1 parent ac3fd11 commit 2b3ebb0

File tree

3 files changed

+40
-47
lines changed

3 files changed

+40
-47
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.73"
3+
version = "0.7.74"
44

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

src/Operators/Operator.jl

Lines changed: 37 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -493,33 +493,30 @@ haswrapperstructure(_) = false
493493
#
494494
# Ex: c*op or real(op)
495495
macro wrapperstructure(Wrap)
496-
ret = quote
497-
ApproxFunBase.haswrapperstructure(::$Wrap) = true
498-
end
499-
500-
for func in (:(ApproxFunBase.bandwidths),:(LinearAlgebra.stride),
496+
v1 = map((:(ApproxFunBase.bandwidths),:(LinearAlgebra.stride),
501497
:(ApproxFunBase.isbandedblockbanded),:(ApproxFunBase.isblockbanded),
502498
:(ApproxFunBase.israggedbelow),:(Base.size),:(ApproxFunBase.isbanded),
503499
:(ApproxFunBase.blockbandwidths),:(ApproxFunBase.subblockbandwidths),
504-
:(LinearAlgebra.issymmetric))
505-
ret = quote
506-
$ret
500+
:(LinearAlgebra.issymmetric))) do func
507501

508-
$func(D::$Wrap) = $func(D.op)
509-
end
502+
:($func(D::$Wrap) = $func(D.op))
510503
end
511504

512-
for func in (:(ApproxFunBase.bandwidth),:(ApproxFunBase.colstart),:(ApproxFunBase.colstop),
505+
v2 = map((:(ApproxFunBase.bandwidth),:(ApproxFunBase.colstart),:(ApproxFunBase.colstop),
513506
:(ApproxFunBase.rowstart),:(ApproxFunBase.rowstop),:(ApproxFunBase.blockbandwidth),
514-
:(Base.size),:(ApproxFunBase.subblockbandwidth))
515-
ret = quote
516-
$ret
517-
507+
:(Base.size),:(ApproxFunBase.subblockbandwidth))) do func
508+
quote
518509
$func(D::$Wrap,k::Integer) = $func(D.op,k)
519510
$func(A::$Wrap,i::ApproxFunBase.PosInfinity) = ℵ₀ # $func(A.op,i) | see PR #42
520-
end
511+
end
521512
end
522513

514+
ret = quote
515+
ApproxFunBase.haswrapperstructure(::$Wrap) = true
516+
$(v1...)
517+
$(v2...)
518+
end
519+
523520
esc(ret)
524521
end
525522

@@ -529,7 +526,19 @@ end
529526
# not necessarily the same spaces
530527
#
531528
macro wrappergetindex(Wrap)
529+
v = map((:(ApproxFunBase.BandedMatrix),:(ApproxFunBase.RaggedMatrix),
530+
:Matrix,:Vector,:AbstractVector)) do TYP
531+
quote
532+
$TYP(P::ApproxFunBase.SubOperator{T,OP}) where {T,OP<:$Wrap} =
533+
$TYP(view(parent(P).op,P.indexes[1],P.indexes[2]))
534+
$TYP(P::ApproxFunBase.SubOperator{T,OP,NTuple{2,UnitRange{Int}}}) where {T,OP<:$Wrap} =
535+
$TYP(view(parent(P).op,P.indexes[1],P.indexes[2]))
536+
end
537+
end
538+
532539
ret = quote
540+
$(v...)
541+
533542
Base.getindex(OP::$Wrap,k::Integer...) =
534543
OP.op[k...]::eltype(OP)
535544

@@ -549,22 +558,6 @@ macro wrappergetindex(Wrap)
549558
ApproxFunBase.mul_coefficients(view(parent(A).op,S.indexes[1],S.indexes[2]),b)
550559

551560
isdiag(W::$Wrap) = isdiag(W.op)
552-
end
553-
554-
for TYP in (:(ApproxFunBase.BandedMatrix),:(ApproxFunBase.RaggedMatrix),
555-
:Matrix,:Vector,:AbstractVector)
556-
ret = quote
557-
$ret
558-
559-
$TYP(P::ApproxFunBase.SubOperator{T,OP}) where {T,OP<:$Wrap} =
560-
$TYP(view(parent(P).op,P.indexes[1],P.indexes[2]))
561-
$TYP(P::ApproxFunBase.SubOperator{T,OP,NTuple{2,UnitRange{Int}}}) where {T,OP<:$Wrap} =
562-
$TYP(view(parent(P).op,P.indexes[1],P.indexes[2]))
563-
end
564-
end
565-
566-
ret = quote
567-
$ret
568561

569562
# fast converts to banded matrices would be based on indices, not blocks
570563
function ApproxFunBase.BandedMatrix(S::ApproxFunBase.SubOperator{T,OP,NTuple{2,ApproxFunBase.BlockRange1}}) where {T,OP<:$Wrap}
@@ -618,16 +611,16 @@ end
618611
# use this for wrapper operators that have the same spaces but
619612
# not necessarily the same entries or structure
620613
#
621-
macro wrapperspaces(Wrap)
622-
ret = quote end
623-
624-
for func in (:(ApproxFunBase.rangespace),:(ApproxFunBase.domain),
625-
:(ApproxFunBase.domainspace),:(ApproxFunBase.isconstop))
626-
ret = quote
627-
$ret
628-
629-
$func(D::$Wrap) = $func(D.op)
630-
end
614+
macro wrapperspaces(Wrap, forwarddomain = true)
615+
fns = [:(ApproxFunBase.rangespace),:(ApproxFunBase.domain), :(ApproxFunBase.isconstop)]
616+
if forwarddomain
617+
fns = [fns; :(ApproxFunBase.domainspace)]
618+
end
619+
v = map(fns) do func
620+
:($func(D::$Wrap) = $func(D.op))
621+
end
622+
ret = quote
623+
$(v...)
631624
end
632625

633626
esc(ret)
@@ -636,10 +629,10 @@ end
636629

637630
# use this for wrapper operators that have the same entries and same spaces
638631
#
639-
macro wrapper(Wrap)
632+
macro wrapper(Wrap, forwarddomain = true)
640633
ret = quote
641634
ApproxFunBase.@wrappergetindex($Wrap)
642-
ApproxFunBase.@wrapperspaces($Wrap)
635+
ApproxFunBase.@wrapperspaces($Wrap, $forwarddomain)
643636

644637
ApproxFunBase.iswrapper(::$Wrap) = true
645638
end

src/Operators/banded/CalculusOperator.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ macro calculus_operator(Op)
2424
space::S
2525
end
2626

27-
ApproxFunBase.@wrapper $WrappOp
28-
27+
ApproxFunBase.@wrapper $WrappOp false # the false doesn't forward the domain space
28+
ApproxFunBase.domainspace(A::$WrappOp) = A.space
2929

3030
## Constructors
3131
$ConcOp(sp::Space,k) = $ConcOp{typeof(sp),typeof(k),ApproxFunBase.prectype(sp)}(sp,k)

0 commit comments

Comments
 (0)