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
+ return KLU. KLUFactorization (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
320
+ nonzeros (A)))
316
321
end
317
322
318
323
function SciMLBase. solve (cache:: LinearCache , alg:: KLUFactorization ; kwargs... )
@@ -323,21 +328,25 @@ function SciMLBase.solve(cache::LinearCache, alg::KLUFactorization; kwargs...)
323
328
if alg. check_pattern && ! (SuiteSparse. decrement (SparseArrays. getcolptr (A)) ==
324
329
cache. cacheval. colptr &&
325
330
SuiteSparse. decrement (SparseArrays. getrowval (A)) == cache. cacheval. rowval)
326
- fact = KLU. klu (A)
331
+ fact = KLU. klu (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
332
+ nonzeros (A)))
327
333
else
328
334
# If we have a cacheval already, run umfpack_symbolic to ensure the symbolic factorization exists
329
335
# This won't recompute if it does.
330
336
KLU. klu_analyze! (cache. cacheval)
331
- copyto! (cache. cacheval. nzval, A . nzval )
337
+ copyto! (cache. cacheval. nzval, nonzeros (A) )
332
338
if cache. cacheval. _numeric === C_NULL # We MUST have a numeric factorization for reuse, unlike UMFPACK.
333
339
KLU. klu_factor! (cache. cacheval)
334
340
end
335
- fact = KLU. klu! (cache. cacheval, A)
341
+ fact = KLU. klu! (cache. cacheval,
342
+ SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
343
+ nonzeros (A)))
336
344
end
337
345
else
338
346
# New fact each time since the sparsity pattern can change
339
347
# and thus it needs to reallocate
340
- fact = KLU. klu (A)
348
+ fact = KLU. klu (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
349
+ nonzeros (A)))
341
350
end
342
351
cache = set_cacheval (cache, fact)
343
352
end
@@ -510,18 +519,20 @@ end
510
519
function init_cacheval (:: SparspakFactorization , A, b, u, Pl, Pr, maxiters:: Int , abstol,
511
520
reltol,
512
521
verbose:: Bool , assumptions:: OperatorAssumptions )
513
- A = convert (AbstractMatrix, A)
514
- return sparspaklu (A, factorize = false )
522
+ return sparspaklu ( SparseMatrixCSC ( size (A) ... , getcolptr (A), rowvals (A), nonzeros (A)),
523
+ factorize = false )
515
524
end
516
525
517
526
function SciMLBase. solve (cache:: LinearCache , alg:: SparspakFactorization ; kwargs... )
518
527
A = cache. A
519
- A = convert (AbstractMatrix, A)
520
528
if cache. isfresh
521
529
if cache. cacheval != = nothing && alg. reuse_symbolic
522
- fact = sparspaklu! (cache. cacheval, A)
530
+ fact = sparspaklu! (cache. cacheval,
531
+ SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
532
+ nonzeros (A)))
523
533
else
524
- fact = sparspaklu (A)
534
+ fact = sparspaklu (SparseMatrixCSC (size (A)... , getcolptr (A), rowvals (A),
535
+ nonzeros (A)))
525
536
end
526
537
cache = set_cacheval (cache, fact)
527
538
end
0 commit comments