52
52
53
53
function do_factorization (alg:: LUFactorization , A, b, u)
54
54
A = convert (AbstractMatrix, A)
55
- if A isa SparseMatrixCSC
56
- return lu (A )
55
+ if A isa AbstractSparseMatrixCSC
56
+ return lu (SparseMatrixCSC ( size (A) ... , getcolptr (A), rowvals (A), nonzeros (A)) )
57
57
else
58
58
fact = lu! (A, alg. pivot)
59
59
end
@@ -277,7 +277,8 @@ function init_cacheval(alg::UMFPACKFactorization, A, b, u, Pl, Pr, maxiters::Int
277
277
copy (nonzeros (A)), 0 )
278
278
finalizer (SuiteSparse. UMFPACK. umfpack_free_symbolic, res)
279
279
else
280
- return SuiteSparse. UMFPACK. UmfpackLU (A)
280
+ return SuiteSparse. UMFPACK. UmfpackLU (SparseMatrixCSC (size (A)... , getcolptr (A),
281
+ rowvals (A), nonzeros (A)))
281
282
end
282
283
end
283
284
@@ -290,12 +291,15 @@ function SciMLBase.solve(cache::LinearCache, alg::UMFPACKFactorization; kwargs..
290
291
if alg. check_pattern && ! (SuiteSparse. decrement (SparseArrays. getcolptr (A)) ==
291
292
cache. cacheval. colptr &&
292
293
SuiteSparse. decrement (SparseArrays. getrowval (A)) == cache. cacheval. rowval)
293
- fact = lu (A)
294
+ fact = lu (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
295
+ nonzeros (A)))
294
296
else
295
- fact = lu! (cache. cacheval, A)
297
+ fact = lu! (cache. cacheval,
298
+ SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
299
+ nonzeros (A)))
296
300
end
297
301
else
298
- fact = lu (A )
302
+ fact = lu (SparseMatrixCSC ( size (A) ... , getcolptr (A), rowvals (A), nonzeros (A)) )
299
303
end
300
304
cache = set_cacheval (cache, fact)
301
305
end
312
316
function init_cacheval (alg:: KLUFactorization , A, b, u, Pl, Pr, maxiters:: Int , abstol,
313
317
reltol,
314
318
verbose:: Bool , assumptions:: OperatorAssumptions )
315
- return KLU. KLUFactorization (convert (AbstractMatrix, A)) # this takes care of the copy internally.
319
+ A = convert (AbstractMatrix, A)
320
+ return KLU. KLUFactorization (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
321
+ nonzeros (A)))
316
322
end
317
323
318
324
function SciMLBase. solve (cache:: LinearCache , alg:: KLUFactorization ; kwargs... )
@@ -323,21 +329,25 @@ function SciMLBase.solve(cache::LinearCache, alg::KLUFactorization; kwargs...)
323
329
if alg. check_pattern && ! (SuiteSparse. decrement (SparseArrays. getcolptr (A)) ==
324
330
cache. cacheval. colptr &&
325
331
SuiteSparse. decrement (SparseArrays. getrowval (A)) == cache. cacheval. rowval)
326
- fact = KLU. klu (A)
332
+ fact = KLU. klu (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
333
+ nonzeros (A)))
327
334
else
328
335
# If we have a cacheval already, run umfpack_symbolic to ensure the symbolic factorization exists
329
336
# This won't recompute if it does.
330
337
KLU. klu_analyze! (cache. cacheval)
331
- copyto! (cache. cacheval. nzval, A . nzval )
338
+ copyto! (cache. cacheval. nzval, nonzeros (A) )
332
339
if cache. cacheval. _numeric === C_NULL # We MUST have a numeric factorization for reuse, unlike UMFPACK.
333
340
KLU. klu_factor! (cache. cacheval)
334
341
end
335
- fact = KLU. klu! (cache. cacheval, A)
342
+ fact = KLU. klu! (cache. cacheval,
343
+ SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
344
+ nonzeros (A)))
336
345
end
337
346
else
338
347
# New fact each time since the sparsity pattern can change
339
348
# and thus it needs to reallocate
340
- fact = KLU. klu (A)
349
+ fact = KLU. klu (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
350
+ nonzeros (A)))
341
351
end
342
352
cache = set_cacheval (cache, fact)
343
353
end
@@ -511,17 +521,20 @@ function init_cacheval(::SparspakFactorization, A, b, u, Pl, Pr, maxiters::Int,
511
521
reltol,
512
522
verbose:: Bool , assumptions:: OperatorAssumptions )
513
523
A = convert (AbstractMatrix, A)
514
- return sparspaklu (A, factorize = false )
524
+ return sparspaklu (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A), nonzeros (A)),
525
+ factorize = false )
515
526
end
516
527
517
528
function SciMLBase. solve (cache:: LinearCache , alg:: SparspakFactorization ; kwargs... )
518
529
A = cache. A
519
- A = convert (AbstractMatrix, A)
520
530
if cache. isfresh
521
531
if cache. cacheval != = nothing && alg. reuse_symbolic
522
- fact = sparspaklu! (cache. cacheval, A)
532
+ fact = sparspaklu! (cache. cacheval,
533
+ SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
534
+ nonzeros (A)))
523
535
else
524
- fact = sparspaklu (A)
536
+ fact = sparspaklu (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
537
+ nonzeros (A)))
525
538
end
526
539
cache = set_cacheval (cache, fact)
527
540
end
0 commit comments