Skip to content

Commit 659b99b

Browse files
committed
format and add specialized _ipiv_rows! and _ipiv_cols!
1 parent 2391c5e commit 659b99b

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/lu.jl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,33 @@ function lu(A::AbstractMatrix, pivot = Val(true), thread = Val(true); kwargs...)
2222
return lu!(copy(A), normalize_pivot(pivot), thread; kwargs...)
2323
end
2424

25-
struct NotIPIV <: AbstractVector{BlasInt} len::Int end
25+
struct NotIPIV <: AbstractVector{BlasInt}
26+
len::Int
27+
end
2628
Base.size(A::NotIPIV) = (A.len,)
2729
Base.getindex(::NotIPIV, i::Int) = i
2830
Base.view(::NotIPIV, r::AbstractUnitRange) = NotIPIV(length(r))
2931
init_pivot(::Val{false}, minmn) = NotIPIV(minmn)
3032
init_pivot(::Val{true}, minmn) = Vector{BlasInt}(undef, minmn)
3133

34+
if isdefined(LinearAlgebra, :_ipiv_cols!)
35+
function LinearAlgebra._ipiv_cols!(::LU{<:Any, <:Any, NotIPIV}, ::OrdinalRange,
36+
B::StridedVecOrMat)
37+
return B
38+
end
39+
end
40+
if isdefined(LinearAlgebra, :_ipiv_rows!)
41+
function LinearAlgebra._ipiv_rows!(::LU{<:Any, <:Any, NotIPIV}, ::OrdinalRange,
42+
B::StridedVecOrMat)
43+
return B
44+
end
45+
end
3246

3347
function lu!(A, pivot = Val(true), thread = Val(true); check = true, kwargs...)
3448
m, n = size(A)
3549
minmn = min(m, n)
3650
# we want the type on both branches to match. When pivot = Val(false), we construct
37-
# a `NotIPIV`, which `LinearAlgebra.generic_lufact!` does not.
51+
# a `NotIPIV`, which `LinearAlgebra.generic_lufact!` does not.
3852
F = if pivot === Val(true) && minmn < 10 # avx introduces small performance degradation
3953
LinearAlgebra.generic_lufact!(A, to_stdlib_pivot(pivot); check = check)
4054
else
@@ -102,8 +116,8 @@ end
102116
# [AL AR]
103117
AL = @view A[:, 1:m]
104118
AR = @view A[:, (m + 1):n]
105-
apply_permutation!(ipiv, AR, Val(Thread))
106-
ldiv!(_unit_lower_triangular(AL), AR, Val(Thread))
119+
apply_permutation!(ipiv, AR, Val{Thread}())
120+
ldiv!(_unit_lower_triangular(AL), AR, Val{Thread}())
107121
end
108122
info
109123
end

0 commit comments

Comments
 (0)