File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 284
284
end
285
285
end
286
286
287
+ @testset " Reuse precs" begin
288
+ num_precs_calls = 0
289
+
290
+ function countingprecs (A, p = nothing )
291
+ num_precs_calls += 1
292
+ (BlockJacobiPreconditioner (A, 2 ), I)
293
+ end
294
+
295
+ n = 10
296
+ A = spdiagm (- 1 => - ones (n - 1 ), 0 => fill (10.0 , n), 1 => - ones (n - 1 ))
297
+ b = rand (n)
298
+ p = LinearProblem (A, b)
299
+ x0 = solve (p, KrylovJL_CG (precs = countingprecs, ldiv = false ))
300
+ cache = x0. cache
301
+ x0 = copy (x0)
302
+ for i in 4 : (n - 3 )
303
+ A[i, i + 3 ] -= 1.0e-4
304
+ A[i - 3 , i] -= 1.0e-4
305
+ end
306
+ LinearSolve. reinit! (cache; A, reuse_precs = true )
307
+ x1 = copy (solve! (cache))
308
+ @test all (x0 .< x1) && num_precs_calls == 1
309
+ end
310
+
287
311
if VERSION >= v " 1.9-"
288
312
@testset " IterativeSolversJL" begin
289
313
kwargs = (; gmres_restart = 5 )
You can’t perform that action at this time.
0 commit comments