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 1
1
2
2
# # Preconditioners
3
3
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)
5
6
6
7
struct ComposePreconditioner{Ti,To}
7
8
inner:: Ti
Original file line number Diff line number Diff line change 59
59
y = solve (_prob)
60
60
@test A1 * y ≈ b1
61
61
62
-
62
+
63
63
_prob = LinearProblem (sparse (A1. A), b1; u0= x1)
64
64
y = solve (_prob)
65
65
@test A1 * y ≈ b1
215
215
216
216
ldiv! (y, Pl, x); @test y ≈ s \ x
217
217
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
218
229
230
+ ldiv! (y, Pl, x); @test y ≈ s \ x
231
+ ldiv! (y, Pr, x); @test y ≈ s * x
219
232
end
220
233
221
234
@testset " ComposePreconditioenr" begin
You can’t perform that action at this time.
0 commit comments