diff --git a/Project.toml b/Project.toml index 4d7a075d..5c84a8b2 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.4.10" +version = "7.4.11" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index b104f403..cb1c91bb 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -622,21 +622,25 @@ else end """ - qr_instance(A) -> qr_factorization_instance + qr_instance(A, pivot = NoPivot()) -> qr_factorization_instance Returns an instance of the QR factorization object with the correct type cheaply. """ -function qr_instance(A::Matrix{T}) where {T} - LinearAlgebra.QRCompactWY(zeros(T,0,0),zeros(T,0,0)) +function qr_instance(A::Matrix{T},pivot = DEFAULT_CHOLESKY_PIVOT) where {T} + if pivot === DEFAULT_CHOLESKY_PIVOT + LinearAlgebra.QRCompactWY(zeros(T,0,0),zeros(T,0,0)) + else + LinearAlgebra.QRPivoted(zeros(T,0,0),zeros(T,0),zeros(Int,0)) + end end -function qr_instance(A::Matrix{BigFloat}) +function qr_instance(A::Matrix{BigFloat},pivot = DEFAULT_CHOLESKY_PIVOT) LinearAlgebra.QR(zeros(BigFloat,0,0),zeros(BigFloat,0)) end # Could be optimized but this should work for any real case. -function qr_instance(jac_prototype::SparseMatrixCSC) +function qr_instance(jac_prototype::SparseMatrixCSC, pivot = DEFAULT_CHOLESKY_PIVOT) qr(sparse(rand(1,1))) end @@ -645,7 +649,7 @@ end Returns the number. """ -qr_instance(a::Number) = a +qr_instance(a::Number, pivot = DEFAULT_CHOLESKY_PIVOT) = a """ qr_instance(a::Any) -> qr(a) @@ -653,7 +657,7 @@ qr_instance(a::Number) = a Slow fallback which gets the instance via factorization. Should get specialized for new matrix types. """ -qr_instance(a::Any) = qr(a)# check = false) +qr_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = qr(a)# check = false) """ svd_instance(A) -> qr_factorization_instance