@@ -169,10 +169,6 @@ function _tsvd(A,
169
169
# Save the estimates of the maximum angles between Lanczos vectors
170
170
append! (maxμs, maxμ)
171
171
172
- # vals0 = svdvals(Bidiagonal(αs, βs[1:end-1], :L))
173
- vals0 = svdvals (Bidiagonal ([αs;z], βs, :L ))
174
- vals1 = vals0
175
-
176
172
hasConv = false
177
173
while iter <= maxiter
178
174
_tmp, _tmp, _tmp, _tmp, _tmp, _tmp, reorth_μ, maxμ, maxν, _tmp =
@@ -181,23 +177,21 @@ function _tsvd(A,
181
177
append! (maxνs, maxν)
182
178
iter += stepsize
183
179
184
- # vals1 = svdvals(Bidiagonal(αs, βs[1:end-1], :L))
185
- vals1 = svdvals (Bidiagonal ([αs;z], βs, :L ))
180
+ # This is more expensive than necessary because we only need the last components. However, LAPACK doesn't support this.
181
+ UU, ss, VV = svd (Bidiagonal ([αs;z], βs, :L ))
186
182
187
- debug && @show vals1[nvals] / vals0[nvals] - 1
183
+ debug && @show βs[ end ]
188
184
189
- if vals0[nvals]* (1 - tolconv) < vals1[nvals] < vals0[nvals]* (1 + tolconv)
190
- # UU, ss, VV = svd(Bidiagonal([αs;z], βs[1:end-1], :L))
191
- # This is more expensive than necessary because we only need the last components. However, LAPACK doesn't support this.
192
- UU, ss, VV = svd (Bidiagonal ([αs;z], βs, :L ))
193
- # @show UU[end, 1:iter]*βs[end]
194
- if all (abs .(UU[end , 1 : nvals])* βs[end ] .< tolconv* ss[1 : nvals]) && all (abs .(VV[end , 1 : nvals])* βs[end ] .< tolconv* ss[1 : nvals])
195
- hasConv = true
196
- break
197
- end
185
+ # Test for convergence. A Ritzvalue is considered converged if
186
+ # either the last component of the corresponding vector is (relatively)
187
+ # small or if the last component in βs is small (or both)
188
+ if all (abs .(UU[end , 1 : nvals])* βs[end ] .< tolconv* ss[1 : nvals]) &&
189
+ all (abs .(VV[end , 1 : nvals])* βs[end ] .< tolconv* ss[1 : nvals])
190
+ hasConv = true
191
+ break
198
192
end
199
- vals0 = vals1
200
- τ = eps (eltype (vals1 ))* vals1 [1 ]
193
+
194
+ τ = eps (eltype (ss ))* ss [1 ]
201
195
202
196
debug && @show iter
203
197
debug && @show τ
0 commit comments