Skip to content

Commit 247ffd3

Browse files
committed
Add handling for fat matrices
1 parent 507ac7a commit 247ffd3

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/lu.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,22 @@ function lu!(A::AbstractMatrix{T}, ipiv::AbstractVector{<:Integer},
1515
m, n = size(A)
1616
mnmin = min(m, n)
1717
reckernel!(A, pivot, m, mnmin, ipiv, info, blocksize)
18+
if m < n # fat matrix
19+
# [AL AR]
20+
AL = @view A[:, 1:m]
21+
AR = @view A[:, m+1:n]
22+
apply_permutation!(ipiv, AR)
23+
ldiv!(UnitLowerTriangular(AL), AR)
24+
end
1825
check && checknonsingular(info[])
1926
LU{T, typeof(A)}(A, ipiv, info[])
2027
end
2128

22-
nsplit(::Type{Float64}, n) = n >= 16 ? ((n + 8) ÷ 16) * 8 : n ÷ 2
23-
nsplit(::Type{Float32}, n) = n >= 32 ? ((n + 16) ÷ 32) * 16 : n ÷ 2
24-
nsplit(::Type{ComplexF64}, n) = n >= 8 ? ((n + 4) ÷ 8) * 4 : n ÷ 2
25-
nsplit(::Type{ComplexF32}, n) = n >= 16 ? ((n + 8) ÷ 16) * 8 : n ÷ 2
29+
function nsplit(::Type{T}, n) where T
30+
k = 128 ÷ sizeof(T)
31+
k_2 = k ÷ 2
32+
return n >= k ? ((n + k_2) ÷ k) * k_2 : n ÷ 2
33+
end
2634

2735
Base.@propagate_inbounds function apply_permutation!(P, A)
2836
for i in axes(P, 1)

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ end
1313

1414
@testset "Test LU factorization" begin
1515
for p in (Val(true), Val(false)), T in (Float64, Float32, ComplexF64, ComplexF32)
16-
A = rand(T, 100, 100)
16+
A = rand(T, 50, 100)
1717
MF = mylu(A, p)
1818
BF = baselu(A, p)
1919
testlu(A, MF, BF)

0 commit comments

Comments
 (0)