Skip to content

Commit 8715abc

Browse files
authored
Three-term ldiv for UpperTriangular AlmostBandedMatrix (#615)
* Three-term ldiv for UpperTriangular AlmostBandedMatrix * Tests for ldiv * Fix import
1 parent c676431 commit 8715abc

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunBase"
22
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
3-
version = "0.9.19"
3+
version = "0.9.20"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/Caching/almostbanded.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,4 +392,10 @@ for ArrTyp in (:AbstractVector, :AbstractMatrix)
392392
end
393393
u
394394
end
395+
@eval function ldiv!(v::$ArrTyp{T},
396+
U::UpperTriangular{T,<:SubArray{T, 2, <:AlmostBandedMatrix{T}, NTuple{2,UnitRange{Int}}}},
397+
u::$ArrTyp{T}) where T
398+
399+
ldiv!(U, copyto!(v, u))
400+
end
395401
end

src/LinearAlgebra/AlmostBandedMatrix.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ end
3535
size(A::AlmostBandedMatrix) = size(A.bands)
3636

3737

38-
function getindex(B::AlmostBandedMatrix,k::Integer,j::Integer)
38+
Base.@propagate_inbounds function getindex(B::AlmostBandedMatrix,k::Integer,j::Integer)
3939
if j > k + bandwidth(B.bands,2)
4040
B.fill[k,j]
4141
else
@@ -44,7 +44,7 @@ function getindex(B::AlmostBandedMatrix,k::Integer,j::Integer)
4444
end
4545

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

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ using FillArrays
1111
using InfiniteArrays
1212
using Infinities
1313
using LinearAlgebra
14+
using LowRankMatrices
1415
using Random
1516
using SpecialFunctions
1617
using Test
@@ -249,6 +250,11 @@ end
249250
AInt = convert(AbstractArray{Int}, A)
250251
@test AInt isa AbstractArray{Int}
251252
@test AInt == A
253+
254+
bands, fill = BandedMatrix(0=>Float64[1:4;]), LowRankMatrix(Float64[1:4;], Float64[1:4;])
255+
AB = ApproxFunBase.AlmostBandedMatrix(bands, fill)
256+
U = UpperTriangular(view(AB, 1:4, 1:4))
257+
@test ldiv!(U, Float64[1:4;]) == ldiv!(ones(4), U, Float64[1:4;]) == ldiv!(factorize(Array(U)), Float64[1:4;])
252258
end
253259

254260
@testset "DiracDelta sampling" begin

0 commit comments

Comments
 (0)