Skip to content

Commit 3cb6959

Browse files
authored
Merge pull request #94 from JuliaLinearAlgebra/square_view
Use `square_view` to avoid square check, instead of `new` hack
2 parents 26de024 + 4142194 commit 3cb6959

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
julia-version: ['1', '1.6']
15+
julia-version: ['1']
1616
threads:
1717
- '1'
1818
- '3'

Project.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "RecursiveFactorization"
22
uuid = "f2c3362d-daeb-58d1-803e-2bc74f2840b4"
33
authors = ["Yingbo Ma <[email protected]>"]
4-
version = "0.2.22"
4+
version = "0.2.23"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -16,9 +16,9 @@ LinearAlgebra = "1.5"
1616
LoopVectorization = "0.10,0.11, 0.12"
1717
Polyester = "0.3.2,0.4.1, 0.5, 0.6, 0.7"
1818
PrecompileTools = "1"
19-
StrideArraysCore = "0.1.13, 0.2.1, 0.3, 0.4.1, 0.5"
20-
TriangularSolve = "0.1.1"
21-
julia = "1.5"
19+
StrideArraysCore = "0.5.5"
20+
TriangularSolve = "0.2"
21+
julia = "1.10"
2222

2323
[extras]
2424
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

src/lu.jl

+7-8
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ using TriangularSolve: ldiv!
33
using LinearAlgebra: BlasInt, BlasFloat, LU, UnitLowerTriangular, checknonsingular, BLAS,
44
LinearAlgebra, Adjoint, Transpose, UpperTriangular, AbstractVecOrMat
55
using StrideArraysCore
6+
using StrideArraysCore: square_view
67
using Polyester: @batch
78

8-
@generated function _unit_lower_triangular(B::A) where {T, A <: AbstractMatrix{T}}
9-
Expr(:new, UnitLowerTriangular{T, A}, :B)
10-
end
119
# 1.7 compat
1210
normalize_pivot(t::Val{T}) where {T} = t
1311
to_stdlib_pivot(t) = t
@@ -55,6 +53,7 @@ end
5553
if CUSTOMIZABLE_PIVOT
5654
function LinearAlgebra.ldiv!(A::LU{T, <:StridedMatrix, <:NotIPIV},
5755
B::StridedVecOrMat{T}) where {T <: BlasFloat}
56+
tri = @inbounds square_view(A.factors, size(A.factors, 1))
5857
ldiv!(UpperTriangular(A.factors), ldiv!(UnitLowerTriangular(A.factors), B))
5958
end
6059
end
@@ -138,10 +137,10 @@ end
138137
info = reckernel!(A, Val(Pivot), m, mnmin, ipiv, info, blocksize, Val(Thread))::Int
139138
@inbounds if m < n # fat matrix
140139
# [AL AR]
141-
AL = @view A[:, 1:m]
140+
AL = square_view(A, m)
142141
AR = @view A[:, (m + 1):n]
143142
Pivot && apply_permutation!(ipiv, AR, Val{Thread}())
144-
ldiv!(_unit_lower_triangular(AL), AR, Val{Thread}())
143+
ldiv!(UnitLowerTriangular(AL), AR, Val{Thread}())
145144
end
146145
info
147146
end
@@ -190,7 +189,7 @@ function reckernel!(A::AbstractMatrix{T}, pivot::Val{Pivot}, m, n, ipiv, info, b
190189

191190
# ======================================== #
192191
# Now, our LU process looks like this
193-
# [ P1 ] [ A11 A21 ] [ L11 0 ] [ U11 U12 ]
192+
# [ P1 ] [ A11 A12 ] [ L11 0 ] [ U11 U12 ]
194193
# [ ] [ ] = [ ] [ ]
195194
# [ P2 ] [ A21 A22 ] [ L21 I ] [ 0 A′22 ]
196195
# ======================================== #
@@ -203,7 +202,7 @@ function reckernel!(A::AbstractMatrix{T}, pivot::Val{Pivot}, m, n, ipiv, info, b
203202
# AL AR
204203
# [A11 A12]
205204
# [A21 A22]
206-
A11 = @view A[1:n1, 1:n1]
205+
A11 = square_view(A, n1)
207206
A12 = @view A[1:n1, (n1 + 1):n]
208207
A21 = @view A[(n1 + 1):m, 1:n1]
209208
A22 = @view A[(n1 + 1):m, (n1 + 1):n]
@@ -223,7 +222,7 @@ function reckernel!(A::AbstractMatrix{T}, pivot::Val{Pivot}, m, n, ipiv, info, b
223222
# [ A22 ] [ 0 ] [ A22 ]
224223
Pivot && apply_permutation!(P1, AR, thread)
225224
# A12 = L11 U12 => U12 = L11 \ A12
226-
ldiv!(_unit_lower_triangular(A11), A12, thread)
225+
ldiv!(UnitLowerTriangular(A11), A12, thread)
227226
# Schur complement:
228227
# We have A22 = L21 U12 + A′22, hence
229228
# A′22 = A22 - L21 U12

0 commit comments

Comments
 (0)