Skip to content

Commit

Permalink
Fix normal op tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nHackel committed Jul 4, 2024
1 parent c59fc1e commit b835266
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions test/testNormalOp.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@

@info "test normal operator"
N = 512
@testset "Normal Operator" begin
for arrayType in arrayTypes
@testset "$arrayType" begin
N = 512

Random.seed!(1234)
x = rand(N)
A = rand(N,N)
W = WeightingOp(rand(N))
Random.seed!(1234)
x = arrayType(rand(N))
A = arrayType(rand(N,N))
A_adj = arrayType(collect(adjoint(A))) # LinearOperators can't resolve storage_type otherwise
W = WeightingOp(arrayType(rand(N)))
WA = W*A

y1 = adjoint(A)*W*A*x
y = normalOperator(A,W)*x
y1 = Array(A_adj*W*W*A*x)
y2 = Array(adjoint(WA) * WA * x)
y = Array(normalOperator(A,W)*x)

@test norm(y1 - y) / norm(y) 0 atol=0.01
@test norm(y1 - y) / norm(y) 0 atol=0.01
@test norm(y2 - y) / norm(y) 0 atol=0.01

y1 = adjoint(A)*A*x
y = normalOperator(A)*x

@test norm(y1 - y) / norm(y) 0 atol=0.01
y1 = Array(adjoint(A)*A*x)
y = Array(normalOperator(A)*x)

@test norm(y1 - y) / norm(y) 0 atol=0.01
end
end
end

0 comments on commit b835266

Please sign in to comment.