@@ -4,12 +4,12 @@ import PrecompileTools: @recompile_invalidations, @setup_workload, @compile_work
44
55@recompile_invalidations begin
66 using ArrayInterface, ArrayLayouts, BandedMatrices, ConcreteStructs, LazyArrays,
7- LinearAlgebra, MatrixFactorizations, Reexport
7+ LinearAlgebra, MatrixFactorizations, Reexport
88end
99
1010import ArrayLayouts: MemoryLayout, sublayout, sub_materialize, MatLdivVec, materialize!,
11- triangularlayout, triangulardata, zero!, _copyto!, colsupport, rowsupport, _qr, _qr! ,
12- _factorize, muladd!
11+ triangularlayout, triangulardata, zero!, _copyto!, colsupport,
12+ rowsupport, _qr, _qr!, _factorize, muladd!
1313import BandedMatrices: _banded_qr!, bandeddata, banded_qr_lmul!
1414import LinearAlgebra: ldiv!
1515import MatrixFactorizations: QR, QRPackedQ, getQ, getR, QRPackedQLayout, AdjQRPackedQLayout
@@ -67,8 +67,8 @@ function AlmostBandedMatrix{T}(::UndefInitializer, mn::NTuple{2, Integer},
6767 return AlmostBandedMatrix (undef, T, mn, lu, rank)
6868end
6969
70- function AlmostBandedMatrix (:: UndefInitializer , mn :: NTuple{2, Integer} ,
71- lu:: NTuple{2, Integer} , rank:: Integer )
70+ function AlmostBandedMatrix (
71+ :: UndefInitializer , mn :: NTuple{2, Integer} , lu:: NTuple{2, Integer} , rank:: Integer )
7272 return AlmostBandedMatrix (undef, Float64, mn, lu, rank)
7373end
7474
160160 end
161161end
162162
163+ function Base. copy (B:: AlmostBandedMatrix )
164+ return AlmostBandedMatrix (copy (bandpart (B)), copy (fillpart (B)))
165+ end
166+
163167function Base. setindex! (B:: AlmostBandedMatrix , v, k:: Integer , j:: Integer )
164168 if k ≤ size (B. fill, 1 )
165169 if j > k + bandwidth (B. bands, 2 )
219223# Pretty Printing
220224# ---------------
221225function _almost_banded_summary (io, B:: AlmostBandedMatrix{T} , inds) where {T}
222- print (io,
223- Base. dims2string (length .(inds)),
226+ print (io, Base. dims2string (length .(inds)),
224227 " AlmostBandedMatrix{$T } with bandwidths $(almostbandwidths (B)) and fill \
225228 rank $(almostbandedrank (B)) " )
226229end
@@ -267,8 +270,9 @@ function _almostbanded_qr(_, A)
267270 B, L = bandpart (A), fillpart (A)
268271 # Expand the bandsize for the QR factorization
269272 # # Bypass the safety checks in `AlmostBandedMatrix`
270- return almostbanded_qr! (AlmostBandedMatrix {eltype(A)} (BandedMatrix (copy (B), (l, l + u)),
271- copy (L)), Val (true ))
273+ return almostbanded_qr! (
274+ AlmostBandedMatrix {eltype(A)} (BandedMatrix (copy (B), (l, l + u)), copy (L)),
275+ Val (true ))
272276end
273277
274278# Band size not yet expanded!
@@ -320,14 +324,14 @@ end
320324 L_right = L[:, jr2]
321325 U′ = U[kr, :]
322326 for j in 1 : length (jr2)
323- muladd! (- one (T), U′[(j + 1 ) : end , :], L_right[:, j], one (T),
324- B_right[(j + 1 ): end , j])
327+ muladd! (
328+ - one (T), U′[(j + 1 ) : end , :], L_right[:, j], one (T), B_right[(j + 1 ): end , j])
325329 end
326330 banded_qr_lmul! (Q' , B_right)
327331 banded_qr_lmul! (Q' , U′)
328332 for j in 1 : length (jr2)
329- muladd! (one (T), U′[(j + 1 ) : end , :], L_right[:, j], one (T),
330- B_right[(j + 1 ): end , j])
333+ muladd! (
334+ one (T), U′[(j + 1 ) : end , :], L_right[:, j], one (T), B_right[(j + 1 ): end , j])
331335 end
332336 k = last (jr1) + 1
333337 end
@@ -363,8 +367,8 @@ _almostbanded_widerect_ldiv!(::QR{T}, B) where {T} = error("Not implemented")
363367
364368const UpperLayoutMatrix{T} = UpperTriangular{T, <: LayoutMatrix{T} }
365369
366- for Typ in (:StridedVector , :StridedMatrix , :AbstractVecOrMat , :UpperLayoutMatrix ,
367- :LayoutMatrix )
370+ for Typ in (
371+ :StridedVector , :StridedMatrix , :AbstractVecOrMat , :UpperLayoutMatrix , : LayoutMatrix )
368372 @eval function ldiv! (A:: QR{T, <:AlmostBandedMatrix} , B:: $Typ{T} ) where {T}
369373 m, n = size (A)
370374 if m == n
410414
411415@inline __original_almostbandedrank (A) = size (first (__lowrankfillpart (A)), 2 )
412416
413- @views function _almostbanded_upper_ldiv! (:: Type{Tri} , R :: AbstractMatrix ,
414- b:: AbstractVector{T} , buffer) where {T, Tri}
417+ @views function _almostbanded_upper_ldiv! (
418+ :: Type{Tri} , R :: AbstractMatrix , b:: AbstractVector{T} , buffer) where {T, Tri}
415419 B = bandpart (R)
416420 U, V = __lowrankfillpart (R)
417421 fill! (buffer, zero (T))
472476# Matrix Multiply
473477# ---------------
474478
475- @views function muladd! (α, A :: AlmostBandedMatrix , B :: AbstractVecOrMat , β,
476- C:: AbstractVecOrMat )
479+ @views function muladd! (
480+ α, A :: AlmostBandedMatrix , B :: AbstractVecOrMat , β, C:: AbstractVecOrMat )
477481 L = fillpart (A)
478482 muladd! (α, L, B, β, selectdim (C, 1 , 1 : size (L, 1 )))
479483 muladd! (α, exclusive_bandpart (A), B, β, selectdim (C, 1 , (size (L, 1 ) + 1 ): size (C, 1 )))
504508end
505509
506510export AlmostBandedMatrix, bandpart, fillpart, exclusive_bandpart, finish_part_setindex!,
507- almostbandwidths, almostbandedrank
511+ almostbandwidths, almostbandedrank
508512
509513end
0 commit comments