Skip to content

Commit

Permalink
Merge pull request #10 from SebastianFlassbeck/main
Browse files Browse the repository at this point in the history
DiagOp now working with @view on linear operator
  • Loading branch information
nHackel authored Oct 1, 2024
2 parents 7b52781 + 18f1227 commit eaa69cf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DiagOp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function DiagOp(ops)
(res,y) -> (diagOpTProd(res,y,ncol,yIdx,xIdx,ops)),
(res,y) -> (diagOpCTProd(res,y,ncol,yIdx,xIdx,ops)),
0, 0, 0, false, false, false, S(undef, 0), S(undef, 0),
[ops...], false, xIdx, yIdx)
ops, false, xIdx, yIdx)

return Op
end
Expand Down
17 changes: 17 additions & 0 deletions test/testOperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -317,50 +317,63 @@ function testDiagOp(N=32,K=2;arrayType = Array)
op1 = DiagOp(blocks)
op2 = DiagOp(blocks...)
op3 = DiagOp(block, K)
op4 = DiagOp(@view blocks[1:K])


# Operations
@testset "Diag Prod" begin
y = Array(F * x)
y1 = Array(op1 * x)
y2 = Array(op2 * x)
y3 = Array(op3 * x)
y4 = Array(op4 * x)


@test y y1 rtol = 1e-2
@test y1 y2 rtol = 1e-2
@test y2 y3 rtol = 1e-2
@test y4 y1 rtol = 1e-2

end

@testset "Diag Transpose" begin
y = Array(transpose(F) * x)
y1 = Array(transpose(op1) * x)
y2 = Array(transpose(op2) * x)
y3 = Array(transpose(op3) * x)
y4 = Array(transpose(op4) * x)

@test y y1 rtol = 1e-2
@test y1 y2 rtol = 1e-2
@test y2 y3 rtol = 1e-2
@test y4 y1 rtol = 1e-2
end

@testset "Diag Adjoint" begin
y = Array(adjoint(F) * x)
y1 = Array(adjoint(op1) * x)
y2 = Array(adjoint(op2) * x)
y3 = Array(adjoint(op3) * x)
y4 = Array(adjoint(op4) * x)

@test y y1 rtol = 1e-2
@test y1 y2 rtol = 1e-2
@test y2 y3 rtol = 1e-2
@test y4 y1 rtol = 1e-2
end

@testset "Diag Normal" begin
y = Array(adjoint(F) * F* x)
y1 = Array(normalOperator(op1) * x)
y2 = Array(normalOperator(op2) * x)
y3 = Array(normalOperator(op3) * x)
y4 = Array(normalOperator(op4) * x)

@test y y1 rtol = 1e-2
@test y1 y2 rtol = 1e-2
@test y2 y3 rtol = 1e-2
@test y4 y1 rtol = 1e-2

end

@testset "Weighted Diag Normal" begin
Expand All @@ -369,15 +382,19 @@ function testDiagOp(N=32,K=2;arrayType = Array)
prod1 = ProdOp(wop, op1)
prod2 = ProdOp(wop, op2)
prod3 = ProdOp(wop, op3)
prod4 = ProdOp(wop, op4)

y = Array(adjoint(F) * adjoint(wop) * wop * F* x)
y1 = Array(normalOperator(prod1) * x)
y2 = Array(normalOperator(prod2) * x)
y3 = Array(normalOperator(prod3) * x)
y4 = Array(normalOperator(prod4) * x)

@test y y1 rtol = 1e-2
@test y1 y2 rtol = 1e-2
@test y2 y3 rtol = 1e-2
@test y4 y1 rtol = 1e-2

end

end
Expand Down

0 comments on commit eaa69cf

Please sign in to comment.