11using LoopVectorization
22using LinearAlgebra: BlasInt, BlasFloat, LU, UnitLowerTriangular, ldiv!, checknonsingular, BLAS, LinearAlgebra
33
4- function lu (A:: AbstractMatrix , pivot:: Union{Val{false}, Val{true}} = Val (true ); kwargs... )
5- return lu! (copy (A), pivot; kwargs... )
4+ # 1.7 compat
5+ normalize_pivot (t:: Val{T} ) where T = t
6+ to_stdlib_pivot (t) = t
7+ if VERSION >= v " 1.7.0-DEV.1188"
8+ normalize_pivot (:: LinearAlgebra.RowMaximum ) = Val (true )
9+ normalize_pivot (:: LinearAlgebra.NoPivot ) = Val (false )
10+ to_stdlib_pivot (:: Val{true} ) = LinearAlgebra. RowMaximum ()
11+ to_stdlib_pivot (:: Val{false} ) = LinearAlgebra. NoPivot ()
612end
713
8- function lu! (A, pivot:: Union{Val{false}, Val{true}} = Val (true ); check= true , kwargs... )
14+ function lu (A:: AbstractMatrix , pivot = Val (true ); kwargs... )
15+ return lu! (copy (A), normalize_pivot (pivot); kwargs... )
16+ end
17+
18+ function lu! (A, pivot = Val (true ); check= true , kwargs... )
919 m, n = size (A)
1020 minmn = min (m, n)
1121 F = if minmn < 10 # avx introduces small performance degradation
12- LinearAlgebra. generic_lufact! (A, pivot; check= check)
22+ LinearAlgebra. generic_lufact! (A, to_stdlib_pivot ( pivot) ; check= check)
1323 else
14- lu! (A, Vector {BlasInt} (undef, minmn), pivot; check= check, kwargs... )
24+ lu! (A, Vector {BlasInt} (undef, minmn), normalize_pivot ( pivot) ; check= check, kwargs... )
1525 end
1626 return F
1727end
@@ -29,12 +39,15 @@ function pick_threshold()
2939 end
3040end
3141
32- function lu! (A:: AbstractMatrix{T} , ipiv:: AbstractVector{<:Integer} ,
33- pivot:: Union{Val{false}, Val{true}} = Val (true );
34- check:: Bool = true ,
35- # the performance is not sensitive wrt blocksize, and 16 is a good default
36- blocksize:: Integer = 16 ,
37- threshold:: Integer = pick_threshold ()) where T
42+ function lu! (
43+ A:: AbstractMatrix{T} , ipiv:: AbstractVector{<:Integer} ,
44+ pivot = Val (true );
45+ check:: Bool = true ,
46+ # the performance is not sensitive wrt blocksize, and 16 is a good default
47+ blocksize:: Integer = 16 ,
48+ threshold:: Integer = pick_threshold ()
49+ ) where T
50+ pivot = normalize_pivot (pivot)
3851 info = zero (BlasInt)
3952 m, n = size (A)
4053 mnmin = min (m, n)
@@ -187,7 +200,7 @@ function _generic_lufact!(A, ::Val{Pivot}, ipiv, info) where Pivot
187200 elseif info == 0
188201 info = k
189202 end
190- k == minmn && break
203+ k == minmn && break
191204 # Update the rest
192205 @avx for j = k+ 1 : n
193206 for i = k+ 1 : m
0 commit comments