Skip to content

Commit 456abc6

Browse files
authored
allow passing ipiv to lu! factorizations
1 parent ff78c38 commit 456abc6

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/lu.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,20 @@ end
8787

8888
# the following method is meant to catch calls to lu!(A::LAPACKArray) without a pivoting strategy
8989
lu!(A::StridedMatrix{<:BlasFloat}; check::Bool = true, allowsingular::Bool = false) = lu!(A, RowMaximum(); check, allowsingular)
90-
function lu!(A::StridedMatrix{T}, ::RowMaximum; check::Bool = true, allowsingular::Bool = false) where {T<:BlasFloat}
91-
lpt = LAPACK.getrf!(A; check)
90+
function lu!(A::StridedMatrix{T}, ::RowMaximum,ipiv::AbstractVector{BlasInt} = Vector{BlasInt}(undef,min(size(A)...)); check::Bool = true, allowsingular::Bool = false) where {T<:BlasFloat}
91+
lpt = LAPACK.getrf!(A, ipiv; check)
9292
check && _check_lu_success(lpt[3], allowsingular)
9393
return LU{T,typeof(lpt[1]),typeof(lpt[2])}(lpt[1], lpt[2], lpt[3])
9494
end
95-
function lu!(A::HermOrSym{T}, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupivottype(T);
95+
function lu!(A::HermOrSym{T}, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupivottype(T), ipiv::AbstractVector{BlasInt} = Vector{BlasInt}(undef,min(size(A)...));
9696
check::Bool = true, allowsingular::Bool = false) where {T}
9797
copytri!(A.data, A.uplo, isa(A, Hermitian))
9898
@inbounds if isa(A, Hermitian) # realify diagonal
9999
for i in axes(A, 1)
100100
A.data[i,i] = A[i,i]
101101
end
102102
end
103-
lu!(A.data, pivot; check, allowsingular)
103+
lu!(A.data, pivot, ipiv; check, allowsingular)
104104
end
105105
# for backward compatibility
106106
# TODO: remove towards Julia v2
@@ -147,9 +147,9 @@ Stacktrace:
147147
[...]
148148
```
149149
"""
150-
lu!(A::AbstractMatrix, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupivottype(eltype(A));
151-
check::Bool = true, allowsingular::Bool = false) = generic_lufact!(A, pivot; check, allowsingular)
152-
function generic_lufact!(A::AbstractMatrix{T}, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupivottype(T);
150+
lu!(A::AbstractMatrix, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupivottype(eltype(A)), ipiv::AbstractVector{BlasInt} = Vector{BlasInt}(undef,min(size(A)...));
151+
check::Bool = true, allowsingular::Bool = false) = generic_lufact!(A, pivot, ipiv; check, allowsingular)
152+
function generic_lufact!(A::AbstractMatrix{T}, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupivottype(T), ipiv::AbstractVector{BlasInt} = Vector{BlasInt}(undef,min(size(A)...));
153153
check::Bool = true, allowsingular::Bool = false) where {T}
154154
check && LAPACK.chkfinite(A)
155155
# Extract values
@@ -158,7 +158,6 @@ function generic_lufact!(A::AbstractMatrix{T}, pivot::Union{RowMaximum,NoPivot,R
158158

159159
# Initialize variables
160160
info = 0
161-
ipiv = Vector{BlasInt}(undef, minmn)
162161
@inbounds begin
163162
for k = 1:minmn
164163
# find index max

0 commit comments

Comments
 (0)