Skip to content

Three-term ldiv for UpperTriangular AlmostBandedMatrix #615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ApproxFunBase"
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
version = "0.9.19"
version = "0.9.20"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
6 changes: 6 additions & 0 deletions src/Caching/almostbanded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -392,4 +392,10 @@ for ArrTyp in (:AbstractVector, :AbstractMatrix)
end
u
end
@eval function ldiv!(v::$ArrTyp{T},
U::UpperTriangular{T,<:SubArray{T, 2, <:AlmostBandedMatrix{T}, NTuple{2,UnitRange{Int}}}},
u::$ArrTyp{T}) where T

ldiv!(U, copyto!(v, u))
end
end
4 changes: 2 additions & 2 deletions src/LinearAlgebra/AlmostBandedMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ end
size(A::AlmostBandedMatrix) = size(A.bands)


function getindex(B::AlmostBandedMatrix,k::Integer,j::Integer)
Base.@propagate_inbounds function getindex(B::AlmostBandedMatrix,k::Integer,j::Integer)
if j > k + bandwidth(B.bands,2)
B.fill[k,j]
else
Expand All @@ -44,7 +44,7 @@ function getindex(B::AlmostBandedMatrix,k::Integer,j::Integer)
end

# can only change the bands, not the fill
function setindex!(B::AlmostBandedMatrix,v,k::Integer,j::Integer)
Base.@propagate_inbounds function setindex!(B::AlmostBandedMatrix,v,k::Integer,j::Integer)
B.bands[k,j] = v
end

Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using FillArrays
using InfiniteArrays
using Infinities
using LinearAlgebra
using LowRankMatrices
using Random
using SpecialFunctions
using Test
Expand Down Expand Up @@ -249,6 +250,11 @@ end
AInt = convert(AbstractArray{Int}, A)
@test AInt isa AbstractArray{Int}
@test AInt == A

bands, fill = BandedMatrix(0=>Float64[1:4;]), LowRankMatrix(Float64[1:4;], Float64[1:4;])
AB = ApproxFunBase.AlmostBandedMatrix(bands, fill)
U = UpperTriangular(view(AB, 1:4, 1:4))
@test ldiv!(U, Float64[1:4;]) == ldiv!(ones(4), U, Float64[1:4;]) == ldiv!(factorize(Array(U)), Float64[1:4;])
end

@testset "DiracDelta sampling" begin
Expand Down