Skip to content

Commit 69dd4a2

Browse files
authored
Fix mul_coefficients for wrapper types (#483)
* Fix mul_coefficients for wrapper types * Add tests * Fix tests
1 parent 774f0d9 commit 69dd4a2

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/Operators/Operator.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,9 @@ macro wrappergetindex(Wrap, forwardsize = true)
565565

566566
ApproxFunBase.mul_coefficients(A::$Wrap,b) = ApproxFunBase.mul_coefficients(A.op,b)
567567
ApproxFunBase.mul_coefficients(A::ApproxFunBase.SubOperator{T,OP,NTuple{2,UnitRange{Int}}},b) where {T,OP<:$Wrap} =
568-
ApproxFunBase.mul_coefficients(view(parent(A).op,S.indexes[1],S.indexes[2]),b)
568+
ApproxFunBase.mul_coefficients(view(parent(A).op,A.indexes[1],A.indexes[2]),b)
569569
ApproxFunBase.mul_coefficients(A::ApproxFunBase.SubOperator{T,OP},b) where {T,OP<:$Wrap} =
570-
ApproxFunBase.mul_coefficients(view(parent(A).op,S.indexes[1],S.indexes[2]),b)
570+
ApproxFunBase.mul_coefficients(view(parent(A).op,A.indexes[1],A.indexes[2]),b)
571571

572572
LinearAlgebra.isdiag(W::$Wrap) = isdiag(W.op)
573573

src/Operators/SubOperator.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ end
189189
view(V::SubOperator, kr, jr) = view(V.parent,reindex(V,parentindices(V),(kr,jr))...)
190190
view(V::SubOperator,kr::InfRanges,jr::InfRanges) = view(V.parent,reindex(V,parentindices(V),(kr,jr))...)
191191

192+
view(A::SubOperator,::Colon,jr) = view(A,1:size(A,1),jr)
193+
192194
bandwidths(S::SubOperator) = S.bandwidths
193195
function colstop(S::SubOperator{<:Any,<:Any,NTuple{2,UnitRange{Int}}},j::Integer)
194196
cs = colstop(parent(S),parentindices(S)[2][j])

test/runtests.jl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,21 @@ end
373373
f = Fun(PointSpace(1:10))
374374
M = Multiplication(f, space(f))
375375
T = TimesOperator([M,M])
376-
S = view(T, 1:2:7, 1:2:7)
377-
B = BandedMatrix(S)
378-
for I in CartesianIndices(B)
379-
@test B[I] S[Tuple(I)...]
376+
for S in (view(T, 1:2:7, 1:2:7), view(M, :, 1:3), view(M, 1:3, :))
377+
B = BandedMatrix(S)
378+
for I in CartesianIndices(B)
379+
@test B[I] S[Tuple(I)...]
380+
end
380381
end
381382
end
383+
@testset "mul_coefficients" begin
384+
sp1 = PointSpace(1:3)
385+
sp2 = PointSpace(2:4)
386+
S = ApproxFunBase.SpaceOperator(Conversion(sp1, sp1), sp2, sp2)
387+
v = [1.0, 2.0, 2.0]
388+
@test mul_coefficients(view(S, axes(S)...), v) == v
389+
@test mul_coefficients(view(S, Block(1), Block(1)), v) == v
390+
end
382391
end
383392
@testset "conversion to a matrix" begin
384393
M = Multiplication(Fun(identity, PointSpace(1:3)))

0 commit comments

Comments
 (0)