Skip to content

Commit

Permalink
Three-term ldiv for UpperTriangular AlmostBandedMatrix (#615)
Browse files Browse the repository at this point in the history
* Three-term ldiv for UpperTriangular AlmostBandedMatrix

* Tests for ldiv

* Fix import
  • Loading branch information
jishnub authored Dec 20, 2023
1 parent c676431 commit 8715abc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
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

2 comments on commit 8715abc

@jishnub
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/97457

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.9.20 -m "<description of version>" 8715abc84204d27c2b1b5c6243ad97e187cd1bff
git push origin v0.9.20

Please sign in to comment.