Skip to content

Commit 51bc106

Browse files
committed
move bandwidth and friends
1 parent 6139298 commit 51bc106

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/Operators/Operator.jl

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,13 @@ bandwidths(A::Operator) = opbandwidths(A)
184184
# the gcd with any number < 10 is the number
185185
stride(A::Operator) = opstride(A::Operator)
186186

187-
isdiag(A::Operator) = bandwidths(A)==(0,0)
187+
isdiag(A::Operator) = opisdiag(A)
188+
188189
istriu(A::Operator) = bandwidth(A, 1) <= 0
189190
istril(A::Operator) = bandwidth(A, 2) <= 0
190191

192+
issymmetric(A::Operator) = opissymmetric(A)
193+
191194

192195
## Construct operators
193196

@@ -523,15 +526,19 @@ defaultsize(A, k) = k==1 ? dimension(rangespace(A)) : dimension(domainspace(A))
523526
@traitfn opsize(A::X, k::Integer) where {X; !HasWrapperStructure{X}} =
524527
defaultsize(A, k)
525528

529+
@traitfn opisdiag(A::X) where {X; !HasWrapperStructure{X}} = bandwidths(A)==(0,0)
530+
@traitfn opissymmetric(A::X) where {X; !HasWrapperStructure{X}} = false
531+
526532
for f in [:size, :stride, :bandwidths, :blockbandwidths, :subblockbandwidths,
527-
:israggedbelow, :isbanded, :isblockbanded, :isbandedblockbanded]
533+
:israggedbelow, :isbanded, :isblockbanded, :isbandedblockbanded,
534+
:issymmetric, :isdiag]
528535
opf = Symbol(:op, f)
529536
@eval begin
530537
@traitfn $opf(A::X) where {X; HasWrapperStructure{X}} = $f(A.op)
531538
end
532539
end
533540

534-
for f in [:size]
541+
for f in [:size, :bandwidth, :blockbandwidth, :subblockbandwidth]
535542
opf = Symbol(:op, f)
536543
@eval begin
537544
@traitfn $opf(A::X, k::Integer) where {X; HasWrapperStructure{X}} = $f(A.op, k)
@@ -543,17 +550,10 @@ end
543550
#
544551
# Ex: c*op or real(op)
545552
macro wrapperstructure(Wrap)
546-
fns = [:(LinearAlgebra.issymmetric)]
553+
fns2 = [:(ApproxFunBase.colstart),:(ApproxFunBase.colstop),
554+
:(ApproxFunBase.rowstart),:(ApproxFunBase.rowstop)]
547555

548-
v1 = map(fns) do func
549-
:($func(D::$Wrap) = $func(D.op))
550-
end
551-
552-
fns2 = [:(ApproxFunBase.bandwidth),:(ApproxFunBase.colstart),:(ApproxFunBase.colstop),
553-
:(ApproxFunBase.rowstart),:(ApproxFunBase.rowstop),:(ApproxFunBase.blockbandwidth),
554-
:(ApproxFunBase.subblockbandwidth)]
555-
556-
v2 = map(fns2) do func
556+
v = map(fns2) do func
557557
quote
558558
$func(D::$Wrap,k::Integer) = $func(D.op,k)
559559
$func(A::$Wrap,i::ApproxFunBase.PosInfinity) = ℵ₀ # $func(A.op,i) | see PR #42
@@ -562,8 +562,7 @@ macro wrapperstructure(Wrap)
562562

563563
ret = quote
564564
ApproxFunBase.haswrapperstructure(::Type{<:$Wrap}) = true
565-
$(v1...)
566-
$(v2...)
565+
$(v...)
567566
end
568567

569568
esc(ret)
@@ -606,8 +605,6 @@ macro wrappergetindex(Wrap)
606605
ApproxFunBase.mul_coefficients(A::ApproxFunBase.SubOperator{T,OP},b) where {T,OP<:$Wrap} =
607606
ApproxFunBase.mul_coefficients(view(parent(A).op,A.indexes[1],A.indexes[2]),b)
608607

609-
LinearAlgebra.isdiag(W::$Wrap) = LinearAlgebra.isdiag(W.op)
610-
611608
# fast converts to banded matrices would be based on indices, not blocks
612609
function ApproxFunBase.BandedMatrix(S::ApproxFunBase.SubOperator{T,OP,NTuple{2,ApproxFunBase.BlockRange1}}) where {T,OP<:$Wrap}
613610
A = parent(S)

0 commit comments

Comments
 (0)