@@ -102,6 +102,39 @@ function lu!(A::HermOrSym{T}, pivot::Union{RowMaximum,NoPivot,RowNonZero} = lupi
102102    end 
103103    lu! (A. data, pivot; check, allowsingular)
104104end 
105+ 
106+ # reusing LU object
107+ # lu!(F::LU,A) should be dispatched on the type of matrix stored in the LU factorization.
108+ # but special care needs to be done in the HermOrSym case
109+ function  _lu_copy! (A,x)
110+     copyto! (A, x)
111+ end 
112+ 
113+ function  lu_copy! (A,x:: HermOrSym )
114+     copytri! (A. data, x. uplo, isa (x, Hermitian))
115+     @inbounds  if  isa (x, Hermitian) #  realify diagonal
116+         for  i in  axes (x, 1 )
117+             A[i,i] =  x[i,i]
118+         end 
119+     end 
120+     return  A
121+ end 
122+ 
123+ function  lu! (F:: LU{<:Any,<:StridedMatrix{<:BlasFloat}} , A; check:: Bool  =  true , allowsingular:: Bool  =  false )
124+     lu_copy! (F. factors,A)
125+     lpt =  LAPACK. getrf! (F. factors, F. ipiv; check)
126+     check &&  _check_lu_success (lpt[3 ], allowsingular)
127+     return  F
128+ end 
129+ 
130+ function  lu! (F:: LU{<:Any,<:AbstractMatrix} , A; check:: Bool  =  true , allowsingular:: Bool  =  false )
131+     lu_copy! (F. factors,A)
132+     generic_lufact! (F. factors, lupivottype (eltype (A)), F. ipiv; check, allowsingular)
133+     return  F
134+ end 
135+ 
136+ 
137+ 
105138#  for backward compatibility
106139#  TODO : remove towards Julia v2
107140@deprecate  lu! (A:: Union{StridedMatrix,HermOrSym,Tridiagonal} , :: Val{true} ; check:: Bool  =  true ) lu! (A, RowMaximum (); check= check)
@@ -149,7 +182,7 @@ Stacktrace:
149182""" 
150183lu! (A:: AbstractMatrix , pivot:: Union{RowMaximum,NoPivot,RowNonZero}  =  lupivottype (eltype (A));
151184    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);
185+ function  generic_lufact! (A:: AbstractMatrix{T} , pivot:: Union{RowMaximum,NoPivot,RowNonZero}  =  lupivottype (T), ipiv :: AbstractVector{BlasInt}   =   Vector {BlasInt} (undef, min ( size (A) ... )) ;
153186                         check:: Bool  =  true , allowsingular:: Bool  =  false ) where  {T}
154187    check &&  LAPACK. chkfinite (A)
155188    #  Extract values
@@ -158,7 +191,6 @@ function generic_lufact!(A::AbstractMatrix{T}, pivot::Union{RowMaximum,NoPivot,R
158191
159192    #  Initialize variables
160193    info =  0 
161-     ipiv =  Vector {BlasInt} (undef, minmn)
162194    @inbounds  begin 
163195        for  k =  1 : minmn
164196            #  find index max
0 commit comments