@@ -99,6 +99,12 @@ function do_factorization(alg::QRFactorization, A, b, u)
99
99
return fact
100
100
end
101
101
102
+ function init_cacheval (alg:: QRFactorization , A, b, u, Pl, Pr,
103
+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
104
+ assumptions:: OperatorAssumptions )
105
+ ArrayInterface. qr_instance (convert (AbstractMatrix, A))
106
+ end
107
+
102
108
# # SVDFactorization
103
109
104
110
struct SVDFactorization{A} <: AbstractFactorization
@@ -114,6 +120,12 @@ function do_factorization(alg::SVDFactorization, A, b, u)
114
120
return fact
115
121
end
116
122
123
+ function init_cacheval (alg:: SVDFactorization , A, b, u, Pl, Pr,
124
+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
125
+ assumptions:: OperatorAssumptions )
126
+ ArrayInterface. svd_instance (convert (AbstractMatrix, A))
127
+ end
128
+
117
129
# # GenericFactorization
118
130
119
131
struct GenericFactorization{F} <: AbstractFactorization
@@ -172,6 +184,94 @@ function init_cacheval(alg::GenericFactorization{typeof(lu!)}, A::Tridiagonal, b
172
184
ArrayInterface. lu_instance (A)
173
185
end
174
186
187
+ function init_cacheval (alg:: GenericFactorization{typeof(qr)} , A, b, u, Pl, Pr,
188
+ maxiters:: Int ,
189
+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
190
+ ArrayInterface. qr_instance (convert (AbstractMatrix, A))
191
+ end
192
+ function init_cacheval (alg:: GenericFactorization{typeof(qr!)} , A, b, u, Pl, Pr,
193
+ maxiters:: Int ,
194
+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
195
+ ArrayInterface. qr_instance (convert (AbstractMatrix, A))
196
+ end
197
+
198
+ function init_cacheval (alg:: GenericFactorization{typeof(qr)} ,
199
+ A:: StridedMatrix{<:LinearAlgebra.BlasFloat} , b, u, Pl, Pr,
200
+ maxiters:: Int ,
201
+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
202
+ ArrayInterface. qr_instance (A)
203
+ end
204
+ function init_cacheval (alg:: GenericFactorization{typeof(qr!)} ,
205
+ A:: StridedMatrix{<:LinearAlgebra.BlasFloat} , b, u, Pl, Pr,
206
+ maxiters:: Int ,
207
+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
208
+ ArrayInterface. qr_instance (A)
209
+ end
210
+ function init_cacheval (alg:: GenericFactorization{typeof(qr)} , A:: Diagonal , b, u, Pl, Pr,
211
+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
212
+ assumptions:: OperatorAssumptions )
213
+ Diagonal (inv .(A. diag))
214
+ end
215
+ function init_cacheval (alg:: GenericFactorization{typeof(qr)} , A:: Tridiagonal , b, u, Pl, Pr,
216
+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
217
+ assumptions:: OperatorAssumptions )
218
+ ArrayInterface. qr_instance (A)
219
+ end
220
+ function init_cacheval (alg:: GenericFactorization{typeof(qr!)} , A:: Diagonal , b, u, Pl, Pr,
221
+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
222
+ assumptions:: OperatorAssumptions )
223
+ Diagonal (inv .(A. diag))
224
+ end
225
+ function init_cacheval (alg:: GenericFactorization{typeof(qr!)} , A:: Tridiagonal , b, u, Pl, Pr,
226
+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
227
+ assumptions:: OperatorAssumptions )
228
+ ArrayInterface. qr_instance (A)
229
+ end
230
+
231
+ function init_cacheval (alg:: GenericFactorization{typeof(svd)} , A, b, u, Pl, Pr,
232
+ maxiters:: Int ,
233
+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
234
+ ArrayInterface. svd_instance (convert (AbstractMatrix, A))
235
+ end
236
+ function init_cacheval (alg:: GenericFactorization{typeof(svd!)} , A, b, u, Pl, Pr,
237
+ maxiters:: Int ,
238
+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
239
+ ArrayInterface. svd_instance (convert (AbstractMatrix, A))
240
+ end
241
+
242
+ function init_cacheval (alg:: GenericFactorization{typeof(svd)} ,
243
+ A:: StridedMatrix{<:LinearAlgebra.BlasFloat} , b, u, Pl, Pr,
244
+ maxiters:: Int ,
245
+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
246
+ ArrayInterface. svd_instance (A)
247
+ end
248
+ function init_cacheval (alg:: GenericFactorization{typeof(svd!)} ,
249
+ A:: StridedMatrix{<:LinearAlgebra.BlasFloat} , b, u, Pl, Pr,
250
+ maxiters:: Int ,
251
+ abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
252
+ ArrayInterface. svd_instance (A)
253
+ end
254
+ function init_cacheval (alg:: GenericFactorization{typeof(svd)} , A:: Diagonal , b, u, Pl, Pr,
255
+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
256
+ assumptions:: OperatorAssumptions )
257
+ Diagonal (inv .(A. diag))
258
+ end
259
+ function init_cacheval (alg:: GenericFactorization{typeof(svd)} , A:: Tridiagonal , b, u, Pl, Pr,
260
+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
261
+ assumptions:: OperatorAssumptions )
262
+ ArrayInterface. svd_instance (A)
263
+ end
264
+ function init_cacheval (alg:: GenericFactorization{typeof(svd!)} , A:: Diagonal , b, u, Pl, Pr,
265
+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
266
+ assumptions:: OperatorAssumptions )
267
+ Diagonal (inv .(A. diag))
268
+ end
269
+ function init_cacheval (alg:: GenericFactorization{typeof(svd!)} , A:: Tridiagonal , b, u, Pl, Pr,
270
+ maxiters:: Int , abstol, reltol, verbose:: Bool ,
271
+ assumptions:: OperatorAssumptions )
272
+ ArrayInterface. svd_instance (A)
273
+ end
274
+
175
275
function init_cacheval (alg:: GenericFactorization , A:: Diagonal , b, u, Pl, Pr, maxiters:: Int ,
176
276
abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
177
277
Diagonal (inv .(A. diag))
209
309
210
310
# Fallback, tries to make nonsingular and just factorizes
211
311
# Try to never use it.
212
- function init_cacheval (alg:: Union{QRFactorization, SVDFactorization, GenericFactorization} ,
312
+ function init_cacheval (alg:: GenericFactorization ,
213
313
A, b, u, Pl, Pr, maxiters:: Int , abstol, reltol, verbose:: Bool ,
214
314
assumptions:: OperatorAssumptions )
215
315
newA = copy (convert (AbstractMatrix, A))
@@ -221,20 +321,6 @@ function init_cacheval(alg::Union{QRFactorization, SVDFactorization, GenericFact
221
321
do_factorization (alg, newA, b, u)
222
322
end
223
323
224
- # Ambiguity handling dispatch
225
- function init_cacheval (alg:: Union{QRFactorization, SVDFactorization} ,
226
- A:: StridedMatrix{<:LinearAlgebra.BlasFloat} , b, u, Pl, Pr,
227
- maxiters:: Int ,
228
- abstol, reltol, verbose:: Bool , assumptions:: OperatorAssumptions )
229
- newA = copy (convert (AbstractMatrix, A))
230
- if newA isa AbstractSparseMatrix
231
- fill! (nonzeros (newA), true )
232
- else
233
- fill! (newA, true )
234
- end
235
- do_factorization (alg, newA, b, u)
236
- end
237
-
238
324
# Cholesky needs the posdef matrix, for GenericFactorization assume structure is needed
239
325
function init_cacheval (alg:: Union {GenericFactorization,
240
326
GenericFactorization{typeof (cholesky)},
0 commit comments