Skip to content

Commit 272c3ab

Browse files
committed
bugfixes in InterlaceOperator and KroneckerOperator
1 parent 36e0868 commit 272c3ab

File tree

5 files changed

+73
-17
lines changed

5 files changed

+73
-17
lines changed

src/Operators/banded/ToeplitzOperator.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ ToeplitzOperator(V::Vector{T},W::Vector{Q}) where {T<:Number,Q<:Number} =
1212
ToeplitzOperator(V::AbstractVector,W::AbstractVector) =
1313
ToeplitzOperator(collect(V),collect(W))
1414

15-
function ToeplitzOperator{T}(x::ToeplitzOperator) where {T}
15+
function ToeplitzOperator{T}(x::ToeplitzOperator) where {T<:Number}
1616
ToeplitzOperator{T}(strictconvert(Vector{T}, x.negative), strictconvert(Vector{T}, x.nonnegative))
1717
end
18-
Operator{TT}(T::ToeplitzOperator) where {TT} =
18+
Operator{TT}(T::ToeplitzOperator) where {TT<:Number} =
1919
ToeplitzOperator(strictconvert(Vector{TT},T.negative),strictconvert(Vector{TT},T.nonnegative))
2020

2121
for op in (:(Base.real), :(Base.imag))
@@ -109,8 +109,8 @@ HankelOperator(V::AbstractVector)=HankelOperator(collect(V))
109109
HankelOperator(f::Fun)=HankelOperator(f.coefficients)
110110

111111

112-
HankelOperator{T}(H::HankelOperator) where {T} = HankelOperator{T}(strictconvert(Vector{T}, H.coefficients))
113-
Operator{TT}(H::HankelOperator) where {TT} = HankelOperator(strictconvert(Vector{TT},H.coefficients))
112+
HankelOperator{T}(H::HankelOperator) where {T<:Number} = HankelOperator{T}(strictconvert(Vector{T}, H.coefficients))
113+
Operator{TT}(H::HankelOperator) where {TT<:Number} = HankelOperator(strictconvert(Vector{TT},H.coefficients))
114114

115115
function hankel_getindex(v::AbstractVector,k::Integer,j::Integer)
116116
if k+j-1 length(v)

src/Operators/general/InterlaceOperator.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ InterlaceOperator(ops::AbstractArray) =
197197

198198
function InterlaceOperator{T,p,DS,RS,DI,RI,BI}(S::InterlaceOperator) where {T,p,DS<:Space,RS<:Space,DI,RI,BI}
199199
InterlaceOperator{T,p,DS,RS,DI,RI,BI}(
200-
strictconvert(Array{Operator{T},p}, ops),
201-
strictconvert(DS, domainspace),
202-
strictconvert(RS, rangespace),
203-
strictconvert(DI, domaininterlacer),
204-
strictconvert(RI, rangeinterlacer),
205-
strictconvert(BI, bandwidths),
200+
strictconvert(Array{Operator{T},p}, S.ops),
201+
strictconvert(DS, S.domainspace),
202+
strictconvert(RS, S.rangespace),
203+
strictconvert(DI, S.domaininterlacer),
204+
strictconvert(RI, S.rangeinterlacer),
205+
strictconvert(BI, S.bandwidths),
206206
)
207207
end
208208
function Operator{T}(S::InterlaceOperator) where T

src/Operators/general/algebra.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ end
198198

199199
function ConstantTimesOperator{T,B}(C::ConstantTimesOperator) where {T<:Number,B<:Operator{T}}
200200
ConstantTimesOperator{T,B}(
201-
strictconvert(T, λ),
202-
strictconvert(B, op),
201+
strictconvert(T, C.λ),
202+
strictconvert(B, C.op),
203203
)
204204
end
205205
function Operator{T}(C::ConstantTimesOperator) where {T}

src/PDE/KroneckerOperator.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ end
5353

5454
function KroneckerOperator{S,V,DS,RS,DI,RI,T}(K::KroneckerOperator) where {S,V,DS,RS,DI,RI,T}
5555
KroneckerOperator{S,V,DS,RS,DI,RI,T}(
56-
strictconvert(Tuple{S,V}, ops),
57-
strictconvert(DS, domainspace),
58-
strictconvert(RS, rangespace),
59-
strictconvert(DI, domaintensorizer),
60-
strictconvert(RI, rangetensorizer),
56+
strictconvert(Tuple{S,V}, K.ops),
57+
strictconvert(DS, K.domainspace),
58+
strictconvert(RS, K.rangespace),
59+
strictconvert(DI, K.domaintensorizer),
60+
strictconvert(RI, K.rangetensorizer),
6161
)
6262
end
6363
function Operator{T}(K::KroneckerOperator) where T<:Number

test/runtests.jl

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,62 @@ end
368368

369369
R = real(M)
370370
@test typeof(M)(M) == M
371+
372+
P = PlusOperator([M,M])
373+
@test typeof(P)(P) == P
374+
375+
T = TimesOperator([M,M])
376+
@test typeof(T)(T) == T
377+
378+
cT = 2M
379+
@test typeof(cT)(cT) == cT
380+
381+
Q = qr(M)
382+
Q2 = typeof(Q)(Q)
383+
# For some reason (perhaps owing to mutability), this does't satisfy Q == Q2,
384+
# so we check the fields
385+
@test typeof(Q) == typeof(Q2)
386+
@test all(x -> getfield(Q, x) === getfield(Q2, x), fieldnames(typeof(Q)))
387+
388+
Sp = ApproxFunBase.SpaceOperator(M, PointSpace(2:4), PointSpace(2:4))
389+
@test typeof(Sp)(Sp) == Sp
390+
391+
K = Sp Sp
392+
@test typeof(K)(K) == K
393+
394+
Sb = view(M, 1:3, 1:3)
395+
@test typeof(Sb)(Sb) == Sb
396+
397+
Intrlc = [M; M]
398+
@test typeof(Intrlc)(Intrlc) == Intrlc
399+
400+
Hrm = ApproxFunBase.HermitianOperator(M)
401+
@test typeof(Hrm)(Hrm) == Hrm
402+
403+
Sym = ApproxFunBase.SymmetricOperator(M)
404+
@test typeof(Sym)(Sym) == Sym
405+
406+
Cch = cache(M)
407+
Cch2 = typeof(Cch)(Cch)
408+
# For some reason (perhaps owing to mutability), this does't satisfy Cch == Cch2,
409+
# so we check the fields
410+
@test typeof(Cch) == typeof(Cch2)
411+
@test all(x -> getfield(Cch, x) === getfield(Cch2, x), fieldnames(typeof(Cch)))
412+
413+
Madj = M'
414+
@test typeof(Madj)(Madj) == Madj
415+
416+
Mtr = transpose(M)
417+
@test typeof(Mtr)(Mtr) == Mtr
418+
419+
CnstO = Operator(2I, PointSpace(1:3))
420+
@test typeof(CnstO)(CnstO) == CnstO
421+
422+
Tplz = ApproxFunBase.ToeplitzOperator([1,2], [2,3])
423+
@test typeof(Tplz)(Tplz) == Tplz
424+
425+
Hnkl = ApproxFunBase.HankelOperator([1,2, 3])
426+
@test typeof(Hnkl)(Hnkl) == Hnkl
371427
end
372428
end
373429

0 commit comments

Comments
 (0)