Skip to content

Commit

Permalink
Update LazyBandedMatrices.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Jul 20, 2023
1 parent 8d5b278 commit fd44183
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/LazyBandedMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ function similar(M::MulAdd{<:BandedLayouts,<:PaddedLayout}, ::Type{T}, axes::Tup
Vcat(Vector{T}(undef, n), Zeros{T}(size(A,1)-n))
end

similar(M::MulAdd{<:DiagonalLayout,<:PaddedLayout}, ::Type{T}, axes) where T = similar(M.B, T, axes)
similar(M::MulAdd{<:DiagonalLayout,<:PaddedLayout}, ::Type{T}, axes::Tuple{Any}) where T = similar(M.B, T, axes)

Check warning on line 286 in src/LazyBandedMatrices.jl

View check run for this annotation

Codecov / codecov/patch

src/LazyBandedMatrices.jl#L286

Added line #L286 was not covered by tests

function similar(M::MulAdd{<:BandedLayouts,<:PaddedLayout}, ::Type{T}, axes::Tuple{Any,Any}) where T
A,x = M.A,M.B
Expand All @@ -293,6 +293,8 @@ function similar(M::MulAdd{<:BandedLayouts,<:PaddedLayout}, ::Type{T}, axes::Tup
PaddedArray(Matrix{T}(undef, m, n), size(A,1), size(x,2))
end

similar(M::MulAdd{<:DiagonalLayout,<:PaddedLayout}, ::Type{T}, axes::Tuple{Any,Any}) where T = similar(M.B, T, axes)

Check warning on line 296 in src/LazyBandedMatrices.jl

View check run for this annotation

Codecov / codecov/patch

src/LazyBandedMatrices.jl#L296

Added line #L296 was not covered by tests

function materialize!(M::MatMulVecAdd{<:BandedLayouts,<:PaddedLayout,<:PaddedLayout})
α,A,x,β,y = M.α,M.A,M.B,M.β,M.C
length(y) == size(A,1) || throw(DimensionMismatch())
Expand Down Expand Up @@ -889,8 +891,7 @@ BandedLazyLayouts = Union{AbstractLazyBandedLayout, BandedColumns{LazyLayout}, B
TriangularLayout{UPLO,UNIT,BandedRows{LazyLayout}} where {UPLO,UNIT},
TriangularLayout{UPLO,UNIT,BandedColumns{LazyLayout}} where {UPLO,UNIT},
SymTridiagonalLayout{LazyLayout}, BidiagonalLayout{LazyLayout}, TridiagonalLayout{LazyLayout},
SymmetricLayout{BandedColumns{LazyLayout}}, HermitianLayout{BandedColumns{LazyLayout}},
DiagonalLayout{LazyLayout}}
SymmetricLayout{BandedColumns{LazyLayout}}, HermitianLayout{BandedColumns{LazyLayout}}}

StructuredLazyLayouts = Union{BandedLazyLayouts,
BlockBandedColumns{LazyLayout}, BandedBlockBandedColumns{LazyLayout},
Expand All @@ -910,6 +911,7 @@ copy(M::Mul{<:StructuredLazyLayouts}) = simplify(M)
copy(M::Mul{<:Any, <:StructuredLazyLayouts}) = simplify(M)
copy(M::Mul{<:StructuredLazyLayouts, <:AbstractLazyLayout}) = simplify(M)
copy(M::Mul{<:AbstractLazyLayout, <:StructuredLazyLayouts}) = simplify(M)
copy(M::Mul{ApplyLayout{typeof(*)},<:StructuredLazyLayouts}) = simplify(M)
copy(M::Mul{<:StructuredLazyLayouts, <:DiagonalLayout}) = simplify(M)
copy(M::Mul{<:DiagonalLayout, <:StructuredLazyLayouts}) = simplify(M)

Expand All @@ -935,6 +937,7 @@ copy(M::Mul{<:StructuredLazyLayouts,ApplyLayout{typeof(*)}}) = simplify(M)
copy(M::Mul{ApplyLayout{typeof(*)},<:BroadcastLayouts}) = simplify(M)
copy(M::Mul{<:BroadcastLayouts,ApplyLayout{typeof(*)}}) = simplify(M)
copy(M::Mul{<:AbstractInvLayout{<:BandedLazyLayouts},<:StructuredLazyLayouts}) = ArrayLayouts.ldiv(pinv(M.A), M.B)
copy(M::Mul{ApplyLayout{typeof(*)},<:AbstractInvLayout{<:BandedLazyLayouts}}) = simplify(M)

Check warning on line 940 in src/LazyBandedMatrices.jl

View check run for this annotation

Codecov / codecov/patch

src/LazyBandedMatrices.jl#L940

Added line #L940 was not covered by tests

copy(L::Ldiv{<:StructuredLazyLayouts, <:StructuredLazyLayouts}) = lazymaterialize(\, L.A, L.B)

Expand Down Expand Up @@ -969,6 +972,7 @@ mulreduce(M::Mul{<:StructuredLazyLayouts, <:PaddedLayout}) = MulAdd(M)
mulreduce(M::Mul{<:StructuredApplyLayouts{F}, D}) where {F,D<:PaddedLayout} = Mul{ApplyLayout{F},D}(M.A, M.B)
# need to overload copy due to above
copy(M::Mul{<:StructuredLazyLayouts, <:PaddedLayout}) = copy(mulreduce(M))
copy(M::Mul{<:BandedLazyLayouts, <:PaddedLayout}) = copy(mulreduce(M))
simplifiable(::Mul{<:StructuredLazyLayouts, <:PaddedLayout}) = Val(true)


Expand Down

0 comments on commit fd44183

Please sign in to comment.