Skip to content

Commit 238c1fe

Browse files
committed
tests
1 parent ef35dac commit 238c1fe

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

test/runtests.jl

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,41 +127,35 @@ end
127127
end
128128

129129
@testset "Preconditioners" begin
130-
@testset "ScaleVector" begin
130+
@testset "scaling_preconditioner" begin
131131
s = rand()
132-
α = rand()
133-
β = rand()
134132

135133
x = rand(n,n)
136134
y = rand(n,n)
137135

138-
Pl = LinearSolve.default_preconditioner(s, true)
139-
Pr = LinearSolve.default_preconditioner(s, false)
136+
Pl = LinearSolve.scaling_preconditioner(s, true)
137+
Pr = LinearSolve.scaling_preconditioner(s, false)
140138

141-
mul!(y, Pl, x)
142-
mul!(y, Pr, x)
139+
mul!(y, Pl, x); @test y s * x
140+
mul!(y, Pr, x); @test y s \ x
143141

144-
mul!(y, Pl, x, α, β)
145-
mul!(y, Pr, x, α, β)
142+
y .= x; ldiv!(Pl, x); @test x s \ y
143+
y .= x; ldiv!(Pr, x); @test x s * y
146144

147-
ldiv!(Pl, x)
148-
ldiv!(Pr, x)
149-
150-
ldiv!(y, Pl, x)
151-
ldiv!(y, Pr, x)
145+
ldiv!(y, Pl, x); @test y s \ x
146+
ldiv!(y, Pr, x); @test y s * x
152147

153148
end
154149

155150
@testset "ComposePreconditioenr" begin
156-
s = rand()
157-
α = rand()
158-
β = rand()
151+
s1 = rand()
152+
s2 = rand()
159153

160154
x = rand(n,n)
161155
y = rand(n,n)
162156

163-
P1 = LinearSolve.default_preconditioner(s, true)
164-
P2 = LinearSolve.default_preconditioner(s, false)
157+
P1 = LinearSolve.scaling_preconditioner(s1, true)
158+
P2 = LinearSolve.scaling_preconditioner(s2, true)
165159

166160
P = LinearSolve.ComposePreconditioner(P1,P2)
167161
Pi = LinearSolve.InvComposePreconditioner(P)
@@ -172,11 +166,11 @@ end
172166
@test Pi' == inv(P')
173167

174168
# ComposePreconditioner
175-
ldiv!(P, x)
176-
ldiv!(y, P, x)
169+
ldiv!(y, P, x); @test y ldiv!(P2, ldiv!(P1, x))
170+
y .= x; ldiv!(P, x); @test x ldiv!(P2, ldiv!(P1, y))
177171

178172
# InvComposePreconditioner
179-
mul!(y, Pi, x)
173+
mul!(y, Pi, x); @test y ldiv!(P2, ldiv!(P1, x))
180174

181175
end
182176
end

0 commit comments

Comments
 (0)