Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define lu!(F::LU,A) for general matrices #1131

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/lu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,25 @@ function lu!(A::HermOrSym{T}, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupi
end
lu!(A.data, pivot; check, allowsingular)
end

#reusing LU object
#lu!(F::LU,A) should be dispatched on the type of matrix stored in the LU factorization.

function lu!(F::LU{<:Any,<:StridedMatrix{<:BlasFloat}}, A; check::Bool = true, allowsingular::Bool = false)
copyto!(F.factors,A)
longemen3000 marked this conversation as resolved.
Show resolved Hide resolved
lpt = LAPACK.getrf!(F.factors, F.ipiv; check)
check && _check_lu_success(lpt[3], allowsingular)
return F
longemen3000 marked this conversation as resolved.
Show resolved Hide resolved
end

function lu!(F::LU{<:Any,<:AbstractMatrix}, A; check::Bool = true, allowsingular::Bool = false)
longemen3000 marked this conversation as resolved.
Show resolved Hide resolved
copyto!(F.factors,A)
generic_lufact!(F.factors, lupivottype(eltype(A)), F.ipiv; check, allowsingular)
return F
end



# for backward compatibility
# TODO: remove towards Julia v2
@deprecate lu!(A::Union{StridedMatrix,HermOrSym,Tridiagonal}, ::Val{true}; check::Bool = true) lu!(A, RowMaximum(); check=check)
Expand Down Expand Up @@ -149,7 +168,7 @@ Stacktrace:
"""
lu!(A::AbstractMatrix, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupivottype(eltype(A));
check::Bool = true, allowsingular::Bool = false) = generic_lufact!(A, pivot; check, allowsingular)
function generic_lufact!(A::AbstractMatrix{T}, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupivottype(T);
function generic_lufact!(A::AbstractMatrix{T}, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupivottype(T), ipiv::AbstractVector{BlasInt} = Vector{BlasInt}(undef,min(size(A)...));
check::Bool = true, allowsingular::Bool = false) where {T}
check && LAPACK.chkfinite(A)
# Extract values
Expand All @@ -158,7 +177,6 @@ function generic_lufact!(A::AbstractMatrix{T}, pivot::Union{RowMaximum,NoPivot,R

# Initialize variables
info = 0
ipiv = Vector{BlasInt}(undef, minmn)
@inbounds begin
for k = 1:minmn
# find index max
Expand Down
Loading