Skip to content

Commit 170e1a7

Browse files
committed
Fix weighted normal diag op
1 parent a80f78a commit 170e1a7

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/DiagOp.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ function LinearOperatorCollection.normalOperator(diag::DiagOp, W=opEye(eltype(di
148148

149149
# we promote the weights to be of the same type as T, which will be required
150150
# when creating the temporary vector in normalOperator in a later stage
151-
opInner = normalOperator(diag.ops[1], WeightingOp(T; weights=T.(weights[diag.yIdx[1]:diag.yIdx[2]-1])); copyOpsFn = copyOpsFn, kwargs...)
152-
op = DiagNormalOp([copyOpsFn(opInner) for i=1:length(diag.ops)], size(diag,2), diag.xIdx, S(undef, diag.ncol) )
151+
op = DiagNormalOp([normalOperator(copyOpsFn(diag.ops[1]), WeightingOp(T; weights=T.(weights[diag.yIdx[i]:diag.yIdx[i+1]-1])); copyOpsFn = copyOpsFn, kwargs...)
152+
for i in 1:length(diag.ops)], size(diag,2), diag.xIdx, S(undef, diag.ncol) )
153153
else
154154
op = DiagNormalOp([normalOperator(diag.ops[i], WeightingOp(T; weights=T.(weights[diag.yIdx[i]:diag.yIdx[i+1]-1])); copyOpsFn = copyOpsFn, kwargs...)
155155
for i in 1:length(diag.ops)], size(diag,2), diag.xIdx, S(undef, diag.ncol) )

test/testOperators.jl

+17
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,23 @@ function testDiagOp(N=32,K=2;arrayType = Array)
363363
@test y2 y3 rtol = 1e-2
364364
end
365365

366+
@testset "Weighted Diag Normal" begin
367+
w = rand(eltype(op1), size(op1, 1))
368+
wop = WeightingOp(w)
369+
prod1 = ProdOp(wop, op1)
370+
prod2 = ProdOp(wop, op2)
371+
prod3 = ProdOp(wop, op3)
372+
373+
y = Array(adjoint(F) * adjoint(wop) * wop * F* x)
374+
y1 = Array(normalOperator(prod1) * x)
375+
y2 = Array(normalOperator(prod2) * x)
376+
y3 = Array(normalOperator(prod3) * x)
377+
378+
@test y y1 rtol = 1e-2
379+
@test y1 y2 rtol = 1e-2
380+
@test y2 y3 rtol = 1e-2
381+
end
382+
366383
end
367384

368385
function testRadonOp(N=32;arrayType = Array)

0 commit comments

Comments
 (0)