Skip to content

Commit 3f7b3a8

Browse files
mohamed82008haampie
authored andcommitted
New API function without initial solution and cleaner show
1 parent 2a14d8e commit 3f7b3a8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/lobpcg.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ function Base.show(io::IO, r::LOBPCGResults)
6666
@printf io "Results of LOBPCG Algorithm\n"
6767
@printf io " * Algorithm: LOBPCG - CholQR\n"
6868

69-
if length(join(r.λ, ",")) < 40
69+
if length(join(r.λ, ",")) < 40 || length(r.λ) <= 2
7070
@printf io " * λ: [%s]\n" join(r.λ, ",")
7171
else
7272
@printf io " * λ: [%s, ...]\n" join(first_two(r.λ), ",")
7373
end
7474

75-
if length(join(r.residual_norms, ",")) < 40
75+
if length(join(r.residual_norms, ",")) < 40 || length(r.residual_norms) <= 2
7676
@printf io " * Residual norm(s): [%s]\n" join(r.residual_norms, ",")
7777
else
7878
@printf io " * Residual norm(s): [%s, ...]\n" join(first_two(r.residual_norms), ",")
@@ -81,7 +81,6 @@ function Base.show(io::IO, r::LOBPCGResults)
8181
@printf io " * Iterations: %s\n" r.iterations
8282
@printf io " * Converged: %s\n" r.converged
8383
@printf io " * Iterations limit: %s\n" r.maxiter
84-
@printf io " * Reached Maximum Number of Iterations: %s\n" r.iterations >= r.maxiter
8584

8685
return
8786
end
@@ -686,6 +685,12 @@ Finds the k extremal eigenvalues and their corresponding eigenvectors satisfying
686685
function lobpcg(A, largest::Bool, X0::Union{AbstractMatrix, AbstractVector}; kwargs...)
687686
lobpcg(A, nothing, largest, X0; kwargs...)
688687
end
688+
function lobpcg(A, largest::Bool, nev::Int=1; kwargs...)
689+
lobpcg(A, nothing, largest, nev; kwargs...)
690+
end
691+
function lobpcg(A, B, largest::Bool, nev::Int=1; kwargs...)
692+
lobpcg(A, B, largest, rand(size(A, 1), nev); kwargs...)
693+
end
689694
function lobpcg(A, B, largest, X0;
690695
log=false, P=nothing, C=nothing,
691696
tol=nothing, maxiter=200)

0 commit comments

Comments
 (0)