Skip to content

Commit ec8e94e

Browse files
committed
Add generic_lufact! fallback
1 parent aca6589 commit ec8e94e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/lu.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
using LoopVectorization
2-
using LinearAlgebra: BlasInt, BlasFloat, LU, UnitLowerTriangular, ldiv!, checknonsingular, BLAS
2+
using LinearAlgebra: BlasInt, BlasFloat, LU, UnitLowerTriangular, ldiv!, checknonsingular, BLAS, LinearAlgebra
33

44
function lu(A::AbstractMatrix, pivot::Union{Val{false}, Val{true}} = Val(true); kwargs...)
5-
lu!(copy(A), pivot; kwargs...)
5+
return lu!(copy(A), pivot; kwargs...)
66
end
77

8-
function lu!(A, pivot::Union{Val{false}, Val{true}} = Val(true); kwargs...)
9-
lu!(A, Vector{BlasInt}(undef, min(size(A)...)), pivot; kwargs...)
8+
function lu!(A, pivot::Union{Val{false}, Val{true}} = Val(true); check=true, kwargs...)
9+
m, n = size(A)
10+
minmn = min(m, n)
11+
F = if minmn < 10 # avx introduces small performance degradation
12+
LinearAlgebra.generic_lufact!(A, pivot; check=check)
13+
else
14+
lu!(A, Vector{BlasInt}(undef, minmn), pivot; check=check, kwargs...)
15+
end
16+
return F
1017
end
1118

1219
# Use a function here to make sure it gets optimized away

0 commit comments

Comments
 (0)