@@ -3,11 +3,9 @@ using TriangularSolve: ldiv!
33using LinearAlgebra: BlasInt, BlasFloat, LU, UnitLowerTriangular, checknonsingular, BLAS,
44 LinearAlgebra, Adjoint, Transpose, UpperTriangular, AbstractVecOrMat
55using StrideArraysCore
6+ using StrideArraysCore: square_view
67using 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
1210normalize_pivot (t:: Val{T} ) where {T} = t
1311to_stdlib_pivot (t) = t
5553if 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
6059end
@@ -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
147146end
@@ -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