Skip to content

Commit

Permalink
add formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jutho committed Jun 7, 2024
1 parent 3441981 commit 18a042a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/dense/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ function schur2eigvecs(T::StridedMatrix{<:BlasReal})
end
function schur2realeigvecs(T::StridedMatrix{<:BlasReal})
n = checksquare(T)
for i = 1:n-1
iszero(T[i+1, i]) || throw(ArgumentError("T must be upper triangular"))
for i in 1:(n - 1)
iszero(T[i + 1, i]) || throw(ArgumentError("T must be upper triangular"))
end
VR = similar(T, n, n)
VL = similar(T, n, 0)
Expand Down
2 changes: 1 addition & 1 deletion src/eigsolve/arnoldi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function realeigsolve(A, x₀, howmany::Int, which::Selector, alg::Arnoldi; alg_
throw(ArgumentError("realeigsolve can only be used for real eigenvalue problems"))
else
allreal = true
for i = 1:(howmany < length(fact) ? howmany : howmany - 1)
for i in 1:(howmany < length(fact) ? howmany : howmany - 1)
if T[i + 1, i] != 0
allreal = false
break
Expand Down
47 changes: 28 additions & 19 deletions test/eigsolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
A = (A + A') / 2
v = rand(T, (n,))
n1 = div(n, 2)
D1, V1, info = @test_logs (:info,) eigsolve(wrapop(A, Val(mode)), wrapvec(v, Val(mode)), n1, :SR;
krylovdim=n,
maxiter=1, tol=tolerance(T), verbosity=1)
D1, V1, info = @test_logs (:info,) eigsolve(wrapop(A, Val(mode)),
wrapvec(v, Val(mode)), n1, :SR;
krylovdim=n,
maxiter=1, tol=tolerance(T),
verbosity=1)
@test KrylovKit.eigselector(wrapop(A, Val(mode)), scalartype(v); krylovdim=n,
maxiter=1,
tol=tolerance(T), ishermitian=true) isa Lanczos
Expand All @@ -29,9 +31,10 @@
@test A * U1 U1 * Diagonal(D1)
@test A * U2 U2 * Diagonal(D2)

@test_logs (:warn,) eigsolve(wrapop(A, Val(mode)), wrapvec(v, Val(mode)), n + 1, :LM;
krylovdim=2n,
maxiter=1, tol=tolerance(T), verbosity=0)
@test_logs (:warn,) eigsolve(wrapop(A, Val(mode)), wrapvec(v, Val(mode)), n + 1,
:LM;
krylovdim=2n,
maxiter=1, tol=tolerance(T), verbosity=0)
end
end
end
Expand Down Expand Up @@ -81,9 +84,11 @@ end
A = rand(T, (n, n)) .- one(T) / 2
v = rand(T, (n,))
n1 = div(n, 2)
D1, V1, info1 = @test_logs (:info,) eigsolve(wrapop(A, Val(mode)), wrapvec(v, Val(mode)), n1, :SR;
orth=orth, krylovdim=n,
maxiter=1, tol=tolerance(T), verbosity=1)
D1, V1, info1 = @test_logs (:info,) eigsolve(wrapop(A, Val(mode)),
wrapvec(v, Val(mode)), n1, :SR;
orth=orth, krylovdim=n,
maxiter=1, tol=tolerance(T),
verbosity=1)
@test KrylovKit.eigselector(wrapop(A, Val(mode)), eltype(v); orth=orth,
krylovdim=n, maxiter=1,
tol=tolerance(T)) isa Arnoldi
Expand Down Expand Up @@ -119,9 +124,10 @@ end
@test A * U2 U2 * Diagonal(D2)
end

@test_logs (:warn,) eigsolve(wrapop(A, Val(mode)), wrapvec(v, Val(mode)), n + 1, :LM; orth=orth,
krylovdim=2n,
maxiter=1, tol=tolerance(T), verbosity=0)
@test_logs (:warn,) eigsolve(wrapop(A, Val(mode)), wrapvec(v, Val(mode)), n + 1,
:LM; orth=orth,
krylovdim=2n,
maxiter=1, tol=tolerance(T), verbosity=0)
end
end
end
Expand Down Expand Up @@ -191,23 +197,26 @@ end
end
end

@testset "Arnoldi - realeigsolve iteratively ($mode)" for mode in (:vector, :inplace, :outplace)
@testset "Arnoldi - realeigsolve iteratively ($mode)" for mode in
(:vector, :inplace, :outplace)
scalartypes = mode === :vector ? (Float32, Float64) : (Float64,)
orths = mode === :vector ? (cgs2, mgs2, cgsr, mgsr) : (mgsr,)
@testset for T in scalartypes
@testset for orth in orths
V = exp(randn(T, (N, N))/10)
V = exp(randn(T, (N, N)) / 10)
D = randn(T, N)
A = V * Diagonal(D) / V
v = rand(T, (N,))
alg = Arnoldi(; krylovdim=3 * n, maxiter=20,
tol=tolerance(T), eager=true)
D1, V1, info1 = @constinferred realeigsolve(wrapop(A, Val(mode)),
wrapvec(v, Val(mode)), n, :SR, alg)
D2, V2, info2 = realeigsolve(wrapop(A, Val(mode)), wrapvec(v, Val(mode)), n, :LR,
alg)
D3, V3, info3 = realeigsolve(wrapop(A, Val(mode)), wrapvec(v, Val(mode)), n, :LM,
alg)
wrapvec(v, Val(mode)), n, :SR, alg)
D2, V2, info2 = realeigsolve(wrapop(A, Val(mode)), wrapvec(v, Val(mode)), n,
:LR,
alg)
D3, V3, info3 = realeigsolve(wrapop(A, Val(mode)), wrapvec(v, Val(mode)), n,
:LM,
alg)
l1 = info1.converged
l2 = info2.converged
l3 = info3.converged
Expand Down

0 comments on commit 18a042a

Please sign in to comment.