Skip to content

Commit 8b2bb8d

Browse files
committed
increase codecov
1 parent c53b555 commit 8b2bb8d

File tree

2 files changed

+18
-35
lines changed

2 files changed

+18
-35
lines changed

ext/InfiniteArraysBandedMatricesExt.jl

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using InfiniteArrays.LazyArrays, InfiniteArrays.ArrayLayouts, InfiniteArrays.Fil
55
import Base: BroadcastStyle, size, getindex, similar, copy, *, +, -, /, \, materialize!, copyto!, OneTo
66
import Base.Broadcast: Broadcasted
77
import InfiniteArrays: InfIndexRanges, Infinity, PosInfinity, OneToInf, InfAxes, AbstractInfUnitRange, InfRanges
8-
import ArrayLayouts: sub_materialize, MemoryLayout, sublayout, mulreduce, _bidiag_forwardsub!, triangularlayout, MatLdivVec
8+
import ArrayLayouts: sub_materialize, MemoryLayout, sublayout, mulreduce, triangularlayout, MatLdivVec, subdiagonaldata, diagonaldata, supdiagonaldata
99
import LazyArrays: applybroadcaststyle, applylayout, islazy, islazy_layout, simplifiable, AbstractLazyLayout, PaddedColumns, LazyArrayStyle, ApplyLayout, AbstractLazyBandedLayout, ApplyBandedLayout, BroadcastBandedLayout
1010
import BandedMatrices: _BandedMatrix, AbstractBandedMatrix, banded_similar, BandedMatrix, bandedcolumns, BandedColumns, bandeddata
1111
import FillArrays: AbstractFillMatrix, AbstractFill, getindex_value
@@ -472,37 +472,6 @@ mulreduce(M::Mul{<:DiagonalLayout, <:InfToeplitzLayouts}) = Lmul(M)
472472
mulreduce(M::Mul{<:InfToeplitzLayouts, <:DiagonalLayout}) = Rmul(M)
473473

474474

475-
function _bidiag_forwardsub!(M::Ldiv{<:Any,<:PaddedColumns})
476-
A, b_in = M.A, M.B
477-
dv = diagonaldata(A)
478-
ev = subdiagonaldata(A)
479-
b = paddeddata(b_in)
480-
N = length(b)
481-
b[1] = bj1 = dv[1]\b[1]
482-
@inbounds for j = 2:N
483-
bj = b[j]
484-
bj -= ev[j - 1] * bj1
485-
dvj = dv[j]
486-
if iszero(dvj)
487-
throw(SingularEbception(j))
488-
end
489-
bj = dvj\bj
490-
b[j] = bj1 = bj
491-
end
492-
493-
@inbounds for j = N+1:length(b_in)
494-
iszero(bj1) && break
495-
bj = -ev[j - 1] * bj1
496-
dvj = dv[j]
497-
if iszero(dvj)
498-
throw(SingularEbception(j))
499-
end
500-
bj = dvj\bj
501-
b_in[j] = bj1 = bj
502-
end
503-
504-
b_in
505-
end
506475

507476
###
508477
# Inf-Toeplitz layout

test/test_infbanded.jl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ const BidiagonalToeplitzLayout = InfiniteArraysBandedMatricesExt.BidiagonalToepl
1414
const PertToeplitz = InfiniteArraysBandedMatricesExt.PertToeplitz
1515
const PertToeplitzLayout = InfiniteArraysBandedMatricesExt.PertToeplitzLayout
1616
const InfBandCartesianIndices = InfiniteArraysBandedMatricesExt.InfBandCartesianIndices
17+
const subdiagonalconstant = InfiniteArraysBandedMatricesExt.subdiagonalconstant
18+
const diagonalconstant = InfiniteArraysBandedMatricesExt.diagonalconstant
19+
const supdiagonalconstant = InfiniteArraysBandedMatricesExt.supdiagonalconstant
1720

1821
using Base: oneto
19-
using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
22+
using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout, islazy
2023

2124
@testset "∞-banded" begin
2225
@testset "Diagonal and BandedMatrix" begin
@@ -51,7 +54,7 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
5154
@test A isa InfToeplitz
5255
@test MemoryLayout(A.data) == ConstRows()
5356
@test MemoryLayout(A) == BandedToeplitzLayout()
54-
@test LazyArrays.islazy(A) == Val(true)
57+
@test islazy(A) == Val(true)
5558

5659
V = view(A,:,3:∞)
5760
@test MemoryLayout(typeof(bandeddata(V))) == ConstRows()
@@ -82,9 +85,14 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
8285
T = Tridiagonal(Fill(1,∞), Fill(2,∞), Fill(3,∞))
8386
@test T isa TriToeplitz
8487
@test (T + 2I)[1:10,1:10] == (2I + T)[1:10,1:10] == T[1:10,1:10] + 2I
88+
@test BandedMatrix(T, (2,3))[1:10,1:10] == InfToeplitz(T,(3,2))[1:10,1:10] == InfToeplitz(T)[1:10,1:10] == T[1:10,1:10]
89+
@test subdiagonalconstant(T) == 1
90+
@test diagonalconstant(T) == 2
91+
@test supdiagonalconstant(T) == 3
8592

8693
S = SymTridiagonal(Fill(1,∞), Fill(2,∞))
8794
@test (S + 2I)[1:10,1:10] == (2I + S)[1:10,1:10] == S[1:10,1:10] + 2I
95+
@test BandedMatrix(S, (2,3))[1:10,1:10] == S[1:10,1:10]
8896
end
8997

9098
@testset "constant data" begin
@@ -118,9 +126,11 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
118126
A = BandedMatrix(-2 => Vcat(Float64[], Fill(1/4,∞)), 0 => Vcat([1.0+im,2,3],Fill(0,∞)), 1 => Vcat(Float64[], Fill(1,∞)))
119127
@test A isa PertToeplitz
120128
@test MemoryLayout(A) isa PertToeplitzLayout
129+
121130
V = view(A,2:∞,2:∞)
122131
@test MemoryLayout(V) isa PertToeplitzLayout
123132
@test BandedMatrix(V) isa PertToeplitz
133+
@test islazy(V) == Val(true)
124134
@test A[2:∞,2:∞] isa PertToeplitz
125135

126136
@test (A + 2I)[1:10,1:10] == (2I + A)[1:10,1:10] == A[1:10,1:10] + 2I
@@ -133,14 +143,18 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
133143
A = SymTridiagonal(Vcat([1,2.], Fill(2.,∞)), Vcat([3.,4.], Fill.(0.5,∞)))
134144
@test A isa SymTriPertToeplitz
135145
@test (A + 2I)[1:10,1:10] == (2I + A)[1:10,1:10] == A[1:10,1:10] + 2I
146+
@test BandedMatrix(A, (2,3))[1:10,1:10] == A[1:10,1:10]
136147

137148
A = Tridiagonal(Vcat([3.,4.], Fill.(0.5,∞)), Vcat([1,2.], Fill(2.,∞)), Vcat([3.,4.], Fill.(0.5,∞)))
138149
@test A isa TriPertToeplitz
139150
@test Adjoint(A) isa AdjTriPertToeplitz
140151
@test (A + 2I)[1:10,1:10] == (2I + A)[1:10,1:10] == A[1:10,1:10] + 2I
141152
@test (Adjoint(A) + 2I)[1:10,1:10] == (2I + Adjoint(A))[1:10,1:10] == Adjoint(A)[1:10,1:10] + 2I
153+
@test BandedMatrix(A, (2,3))[1:10,1:10] == A[1:10,1:10]
142154
end
143155

156+
157+
144158
@testset "InfBanded" begin
145159
A = _BandedMatrix(Fill(2,4,∞),ℵ₀,2,1)
146160
B = _BandedMatrix(Fill(3,2,∞),ℵ₀,-1,2)
@@ -213,7 +227,7 @@ using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout
213227
@test A[band(2)][1:5] == [1; fill(2,4)]
214228
@test A[band(4)] Zeros{Int}(∞)
215229
end
216-
230+
217231
@testset "prepad with fill" begin
218232
A = BandedMatrix(2 => Zeros(∞))
219233
@test A[band(2)][1:10] == Zeros(10)

0 commit comments

Comments
 (0)