Skip to content

Commit

Permalink
Fix to_boundary unit tests.
Browse files Browse the repository at this point in the history
Note the new 4th argument z, which is a vector that provides workspace for the mul! (or ldiv!) operations on the preconditioner. This isn't needed when M=I`.

Because z is modified in place, probably the function should be renamed to to_boundary! (add exclamation).
  • Loading branch information
mpf authored and amontoison committed Aug 5, 2024
1 parent d1a7326 commit 3719f78
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/test_aux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@
n = 5
x = ones(n)
d = ones(n); d[1:2:n] .= -1
@test_throws ErrorException Krylov.to_boundary(n, x, d, -1.0)
@test_throws ErrorException Krylov.to_boundary(n, x, d, 0.5)
@test_throws ErrorException Krylov.to_boundary(n, x, zeros(n), 1.0)
@test maximum(Krylov.to_boundary(n, x, d, 5.0)) 2.209975124224178
@test minimum(Krylov.to_boundary(n, x, d, 5.0)) -1.8099751242241782
@test maximum(Krylov.to_boundary(n, x, d, 5.0, flip=true)) 1.8099751242241782
@test minimum(Krylov.to_boundary(n, x, d, 5.0, flip=true)) -2.209975124224178
z = similar(d) # <-- placeholder for preconditioning storage
@test_throws ErrorException Krylov.to_boundary(n, x, d, z, -1.0)
@test_throws ErrorException Krylov.to_boundary(n, x, d, z, 0.5)
@test_throws ErrorException Krylov.to_boundary(n, x, zeros(n), z, 1.0)
@test maximum(Krylov.to_boundary(n, x, d, z, 5.0)) 2.209975124224178
@test minimum(Krylov.to_boundary(n, x, d, z, 5.0)) -1.8099751242241782
@test maximum(Krylov.to_boundary(n, x, d, z, 5.0, flip=true)) 1.8099751242241782
@test minimum(Krylov.to_boundary(n, x, d, z, 5.0, flip=true)) -2.209975124224178
end

@testset "kzeros" begin
Expand Down

0 comments on commit 3719f78

Please sign in to comment.