File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 11
22# # Preconditioners
33
4- scaling_preconditioner (s) = I * s , I * (1 / s)
4+ scaling_preconditioner (s:: Number ) = I * (1 / s), I * s
5+ scaling_preconditioner (s:: AbstractVector ) = Diagonal (inv .(s)),Diagonal (s)
56
67struct ComposePreconditioner{Ti,To}
78 inner:: Ti
Original file line number Diff line number Diff line change 5959 y = solve (_prob)
6060 @test A1 * y ≈ b1
6161
62-
62+
6363 _prob = LinearProblem (sparse (A1. A), b1; u0= x1)
6464 y = solve (_prob)
6565 @test A1 * y ≈ b1
215215
216216 ldiv! (y, Pl, x); @test y ≈ s \ x
217217 ldiv! (y, Pr, x); @test y ≈ s * x
218+ end
219+
220+ @testset " vector scaling_preconditioner" begin
221+ s = rand (n)
222+ Pl, Pr = LinearSolve. scaling_preconditioner (s)
223+
224+ mul! (y, Pl, x); @test y ≈ s * x
225+ mul! (y, Pr, x); @test y ≈ s \ x
226+
227+ y .= x; ldiv! (Pl, x); @test x ≈ s \ y
228+ y .= x; ldiv! (Pr, x); @test x ≈ s * y
218229
230+ ldiv! (y, Pl, x); @test y ≈ s \ x
231+ ldiv! (y, Pr, x); @test y ≈ s * x
219232 end
220233
221234 @testset " ComposePreconditioenr" begin
You can’t perform that action at this time.
0 commit comments