-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preconditioning working ok it seems, still tough to get very high acc…
…uracy
- Loading branch information
1 parent
a7f6138
commit ded786d
Showing
3 changed files
with
38 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ using Test | |
|
||
@testset "BlockDavidson.jl" begin | ||
include("test01.jl") | ||
include("test_precond_01.jl") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,34 @@ | ||
using BlockDavidson | ||
using LinearAlgebra | ||
using Random | ||
using Test | ||
|
||
Random.seed!(2) | ||
@testset "BlockDavidson preconditioning" begin | ||
Random.seed!(2) | ||
|
||
N = 10_000 | ||
A = -10 .* diagm(rand(N)) + .001 * rand(N,N) | ||
A += A' | ||
N = 1_000 | ||
nr = 4 | ||
A = -10 .* diagm(rand(N)) + 0.001 * rand(N, N) | ||
A += A' | ||
|
||
v0 = qr(rand(N,2)).Q[:,1:3]; | ||
v0 = qr(rand(N, 2)).Q[:, 1:nr] | ||
|
||
idx = sortperm(diag(A)) | ||
v0 = Matrix(1.0I, N, N)[:, idx[1:nr]] | ||
|
||
|
||
println(" No preconditioning") | ||
dav1 = Davidson(A, max_iter=50, nroots=nr, tol=1e-8, v0=v0) | ||
dav2 = Davidson(A, max_iter=50, nroots=nr, tol=1e-8, v0=v0) | ||
e1, v1 = eigs(dav1) | ||
println() | ||
println(" Preconditioned") | ||
e2, v2 = eigs(dav2, Adiag=diag(A)) | ||
|
||
flush(stdout) | ||
display(dav1.converged) | ||
display(dav2.converged) | ||
@test dav1.converged == false | ||
@test dav2.converged == true | ||
|
||
end |