1
- export check_ctranspose, check_hermitian, check_positive_definite, normest, solve_shifted_system!, ldiv!
1
+ export check_ctranspose,
2
+ check_hermitian, check_positive_definite, normest, solve_shifted_system!, ldiv!
2
3
import LinearAlgebra. ldiv!
3
4
4
5
"""
147
148
check_positive_definite (M:: AbstractMatrix ; kwargs... ) =
148
149
check_positive_definite (LinearOperator (M); kwargs... )
149
150
150
-
151
- """
151
+ """
152
152
solve_shifted_system!(x, B, b, σ)
153
153
154
154
Solve linear system (B + σI) x = b, where B is a forward L-BFGS operator and σ ≥ 0.
@@ -209,14 +209,13 @@ function solve_shifted_system!(
209
209
B:: LBFGSOperator{T, I, F1, F2, F3} ,
210
210
b:: AbstractVector{T} ,
211
211
σ:: T ,
212
- ) where {T, I, F1, F2, F3}
213
-
212
+ ) where {T, I, F1, F2, F3}
214
213
if σ < 0
215
214
throw (ArgumentError (" σ must be nonnegative" ))
216
215
end
217
216
data = B. data
218
217
insert = data. insert
219
-
218
+
220
219
γ_inv = 1 / data. scaling_factor
221
220
x_0 = 1 / (γ_inv + σ)
222
221
@. x = x_0 * b
@@ -234,20 +233,20 @@ function solve_shifted_system!(
234
233
sign_t = 1
235
234
for t = 1 : (i - 1 )
236
235
c0 = dot (view (data. shifted_p, :, t), data. shifted_u)
237
- c1= sign_t .* data. shifted_v[t]
236
+ c1 = sign_t .* data. shifted_v[t]
238
237
c2 = c1 * c0
239
238
view (data. shifted_p, :, i) .+ = c2 .* view (data. shifted_p, :, t)
240
239
sign_t = - sign_t
241
240
end
242
241
243
242
data. shifted_v[i] = 1 / (1 - sign_i * dot (data. shifted_u, view (data. shifted_p, :, i)))
244
- x .+ = sign_i * data. shifted_v[i] * (view (data. shifted_p, :, i)' * b) .* view (data. shifted_p, :, i)
243
+ x .+ =
244
+ sign_i * data. shifted_v[i] * (view (data. shifted_p, :, i)' * b) .* view (data. shifted_p, :, i)
245
245
sign_i = - sign_i
246
246
end
247
247
return x
248
248
end
249
249
250
-
251
250
"""
252
251
ldiv!(x, B, b)
253
252
@@ -279,8 +278,12 @@ ldiv!(x, B, b)
279
278
# The vector `x` now contains the solution
280
279
"""
281
280
282
- function ldiv! (x:: AbstractVector{T} , B:: LBFGSOperator{T, I, F1, F2, F3} , b:: AbstractVector{T} ) where {T, I, F1, F2, F3}
281
+ function ldiv! (
282
+ x:: AbstractVector{T} ,
283
+ B:: LBFGSOperator{T, I, F1, F2, F3} ,
284
+ b:: AbstractVector{T} ,
285
+ ) where {T, I, F1, F2, F3}
283
286
# Call solve_shifted_system! with σ = 0
284
287
solve_shifted_system! (x, B, b, T (0.0 ))
285
288
return x
286
- end
289
+ end
0 commit comments