|
10 | 10 |
|
11 | 11 | _ldiv!(x, A, b) = ldiv!(x, A, b)
|
12 | 12 |
|
| 13 | +_ldiv!(x::MVector, A, b::SVector) = (x .= A \ b) |
| 14 | +_ldiv!(::SVector, A, b::SVector) = (A \ b) |
| 15 | + |
13 | 16 | function _ldiv!(x::Vector, A::Factorization, b::Vector)
|
14 | 17 | # workaround https://github.com/JuliaLang/julia/issues/43507
|
15 | 18 | # Fallback if working with non-square matrices
|
@@ -88,6 +91,8 @@ function do_factorization(alg::LUFactorization, A, b, u)
|
88 | 91 | if A isa AbstractSparseMatrixCSC
|
89 | 92 | return lu(SparseMatrixCSC(size(A)..., getcolptr(A), rowvals(A), nonzeros(A)),
|
90 | 93 | check = false)
|
| 94 | + elseif !ArrayInterface.can_setindex(typeof(A)) |
| 95 | + fact = lu(A, alg.pivot, check = false) |
91 | 96 | else
|
92 | 97 | fact = lu!(A, alg.pivot, check = false)
|
93 | 98 | end
|
@@ -172,10 +177,14 @@ end
|
172 | 177 |
|
173 | 178 | function do_factorization(alg::QRFactorization, A, b, u)
|
174 | 179 | A = convert(AbstractMatrix, A)
|
175 |
| - if alg.inplace && !(A isa SparseMatrixCSC) && !(A isa GPUArraysCore.AbstractGPUArray) |
176 |
| - fact = qr!(A, alg.pivot) |
| 180 | + if ArrayInterface.can_setindex(typeof(A)) |
| 181 | + if alg.inplace && !(A isa SparseMatrixCSC) && !(A isa GPUArraysCore.AbstractGPUArray) |
| 182 | + fact = qr!(A, alg.pivot) |
| 183 | + else |
| 184 | + fact = qr(A) # CUDA.jl does not allow other args! |
| 185 | + end |
177 | 186 | else
|
178 |
| - fact = qr(A) # CUDA.jl does not allow other args! |
| 187 | + fact = qr(A, alg.pivot) |
179 | 188 | end
|
180 | 189 | return fact
|
181 | 190 | end
|
@@ -372,11 +381,15 @@ SVDFactorization() = SVDFactorization(false, LinearAlgebra.DivideAndConquer())
|
372 | 381 |
|
373 | 382 | function do_factorization(alg::SVDFactorization, A, b, u)
|
374 | 383 | A = convert(AbstractMatrix, A)
|
375 |
| - fact = svd!(A; full = alg.full, alg = alg.alg) |
| 384 | + if ArrayInterface.can_setindex(typeof(A)) |
| 385 | + fact = svd!(A; alg.full, alg.alg) |
| 386 | + else |
| 387 | + fact = svd(A; alg.full) |
| 388 | + end |
376 | 389 | return fact
|
377 | 390 | end
|
378 | 391 |
|
379 |
| -function init_cacheval(alg::SVDFactorization, A::Matrix, b, u, Pl, Pr, |
| 392 | +function init_cacheval(alg::SVDFactorization, A::Union{Matrix, SMatrix}, b, u, Pl, Pr, |
380 | 393 | maxiters::Int, abstol, reltol, verbose::Bool,
|
381 | 394 | assumptions::OperatorAssumptions)
|
382 | 395 | ArrayInterface.svd_instance(convert(AbstractMatrix, A))
|
@@ -1354,6 +1367,11 @@ function init_cacheval(::SparspakFactorization, A, b, u, Pl, Pr, maxiters::Int,
|
1354 | 1367 | end
|
1355 | 1368 | end
|
1356 | 1369 |
|
| 1370 | +function init_cacheval(::SparspakFactorization, ::StaticArray, b, u, Pl, Pr, |
| 1371 | + maxiters::Int, abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions) |
| 1372 | + nothing |
| 1373 | +end |
| 1374 | + |
1357 | 1375 | function SciMLBase.solve!(cache::LinearCache, alg::SparspakFactorization; kwargs...)
|
1358 | 1376 | A = cache.A
|
1359 | 1377 | if cache.isfresh
|
|
0 commit comments