@@ -689,11 +689,11 @@ function lobpcg(A, largest::Bool, nev::Int=1; kwargs...)
689
689
lobpcg (A, nothing , largest, nev; kwargs... )
690
690
end
691
691
function lobpcg (A, B, largest:: Bool , nev:: Int = 1 ; kwargs... )
692
- lobpcg (A, B, largest, rand (size (A, 1 ), nev); kwargs... )
692
+ lobpcg (A, B, largest, rand (eltype (A), size (A, 1 ), nev); not_zeros = true , kwargs... )
693
693
end
694
694
function lobpcg (A, B, largest, X0;
695
- log = false , P = nothing , C = nothing ,
696
- tol= nothing , maxiter= 200 )
695
+ not_zeros = false , log = false , P = nothing ,
696
+ C = nothing , tol= nothing , maxiter= 200 )
697
697
698
698
X = copy (X0)
699
699
T = eltype (X)
@@ -703,7 +703,7 @@ function lobpcg(A, B, largest, X0;
703
703
704
704
iterator = LOBPCGIterator (A, B, X, largest, P, C)
705
705
706
- return lobpcg! (iterator, log= log, tol= tol, maxiter= maxiter)
706
+ return lobpcg! (iterator, log= log, tol= tol, maxiter= maxiter, not_zeros = not_zeros )
707
707
end
708
708
709
709
"""
@@ -728,12 +728,14 @@ end
728
728
- `results`: a `LOBPCGResults` struct. `r.λ` and `r.X` store the eigenvalues and eigenvectors.
729
729
730
730
"""
731
- function lobpcg! (iterator:: LOBPCGIterator ; log= false , tol= nothing , maxiter= 200 )
731
+ function lobpcg! (iterator:: LOBPCGIterator ; log= false , tol= nothing , maxiter= 200 , not_zeros = false )
732
732
T = eltype (iterator. XBlocks. block)
733
733
X = iterator. XBlocks. block
734
+ if ! not_zeros
734
735
for j in 1 : size (X,2 )
735
736
if all (x -> x== 0 , view (X, :, j))
736
- X[:,j] .= rand .()
737
+ @inbounds X[:,j] .= rand .()
738
+ end
737
739
end
738
740
end
739
741
n = size (X, 1 )
0 commit comments