Skip to content

Commit e5bd756

Browse files
Merge pull request #420 from JuliaArrays/qrpivot
Allow for setting QR pivot types
2 parents 92400fa + 08aebd3 commit e5bd756

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
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: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -622,21 +622,25 @@ 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}) where {T}
631-
LinearAlgebra.QRCompactWY(zeros(T,0,0),zeros(T,0,0))
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
632636
end
633637

634-
function qr_instance(A::Matrix{BigFloat})
638+
function qr_instance(A::Matrix{BigFloat},pivot = DEFAULT_CHOLESKY_PIVOT)
635639
LinearAlgebra.QR(zeros(BigFloat,0,0),zeros(BigFloat,0))
636640
end
637641

638642
# Could be optimized but this should work for any real case.
639-
function qr_instance(jac_prototype::SparseMatrixCSC)
643+
function qr_instance(jac_prototype::SparseMatrixCSC, pivot = DEFAULT_CHOLESKY_PIVOT)
640644
qr(sparse(rand(1,1)))
641645
end
642646

@@ -645,15 +649,15 @@ end
645649
646650
Returns the number.
647651
"""
648-
qr_instance(a::Number) = a
652+
qr_instance(a::Number, pivot = DEFAULT_CHOLESKY_PIVOT) = a
649653

650654
"""
651655
qr_instance(a::Any) -> qr(a)
652656
653657
Slow fallback which gets the instance via factorization. Should get
654658
specialized for new matrix types.
655659
"""
656-
qr_instance(a::Any) = qr(a)# check = false)
660+
qr_instance(a::Any, pivot = DEFAULT_CHOLESKY_PIVOT) = qr(a)# check = false)
657661

658662
"""
659663
svd_instance(A) -> qr_factorization_instance

0 commit comments

Comments
 (0)