1
1
using LoopVectorization
2
2
using LinearAlgebra: BlasInt, BlasFloat, LU, UnitLowerTriangular, ldiv!, checknonsingular, BLAS, LinearAlgebra
3
3
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 ()
6
12
end
7
13
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... )
9
19
m, n = size (A)
10
20
minmn = min (m, n)
11
21
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)
13
23
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... )
15
25
end
16
26
return F
17
27
end
@@ -29,12 +39,15 @@ function pick_threshold()
29
39
end
30
40
end
31
41
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)
38
51
info = zero (BlasInt)
39
52
m, n = size (A)
40
53
mnmin = min (m, n)
@@ -187,7 +200,7 @@ function _generic_lufact!(A, ::Val{Pivot}, ipiv, info) where Pivot
187
200
elseif info == 0
188
201
info = k
189
202
end
190
- k == minmn && break
203
+ k == minmn && break
191
204
# Update the rest
192
205
@avx for j = k+ 1 : n
193
206
for i = k+ 1 : m
0 commit comments