Skip to content

Commit 612a3ac

Browse files
Allow for setting QR pivot types
1 parent 92400fa commit 612a3ac

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ArrayInterface"
22
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
3-
version = "7.4.10"
3+
version = "7.4.11"
44

55
[deps]
66
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/ArrayInterface.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,28 @@ else
622622
end
623623

624624
"""
625-
qr_instance(A) -> qr_factorization_instance
625+
qr_instance(A, pivot = NoPivot()) -> qr_factorization_instance
626626
627627
Returns an instance of the QR factorization object with the correct type
628628
cheaply.
629629
"""
630+
function qr_instance(A::Matrix{T},pivot = DEFAULT_CHOLESKY_PIVOT) where {T}
631+
if pivot === DEFAULT_CHOLESKY_PIVOT
632+
LinearAlgebra.QRCompactWY(zeros(T,0,0),zeros(T,0,0))
633+
else
634+
LinearAlgebra.QRPivoted(zeros(T,0,0),zeros(T,0),zeros(Int,0))
635+
end
636+
end
637+
638+
function qr_instance(A::Matrix{BigFloat},pivot = DEFAULT_CHOLESKY_PIVOT)
639+
LinearAlgebra.QR(zeros(BigFloat,0,0),zeros(BigFloat,0))
640+
end
641+
642+
# Could be optimized but this should work for any real case.
643+
function qr_instance(jac_prototype::SparseMatrixCSC, pivot = DEFAULT_CHOLESKY_PIVOT)
644+
qr(sparse(rand(1,1)))
645+
end
646+
630647
function qr_instance(A::Matrix{T}) where {T}
631648
LinearAlgebra.QRCompactWY(zeros(T,0,0),zeros(T,0,0))
632649
end

0 commit comments

Comments
 (0)