Skip to content

Commit 9492c19

Browse files
committed
Cleanup code
1 parent 071b767 commit 9492c19

File tree

8 files changed

+24
-283
lines changed

8 files changed

+24
-283
lines changed

Project.toml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,24 @@ BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
88
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
99
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
1010
InfiniteArrays = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
11-
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
1211
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
1312
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1413
MatrixFactorizations = "a3b82374-2e81-5b9e-98ce-41277c0e4c87"
15-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
14+
1615

1716
[compat]
18-
BandedMatrices = "0.9"
17+
BandedMatrices = "0.10"
1918
BlockArrays = "0.9"
2019
BlockBandedMatrices = "0.4"
21-
FillArrays = "≥ 0.5.0"
20+
FillArrays = "0.6.4"
2221
InfiniteArrays = "0.1"
23-
IntervalArithmetic = "≥ 0.15.2"
24-
LazyArrays = "0.8, 0.9"
25-
MatrixFactorizations = "0.0.4, 0.1"
26-
julia = "0.7, 1"
22+
LazyArrays = "0.10"
23+
MatrixFactorizations = "0.1"
24+
julia = "1"
25+
26+
[extras]
27+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
28+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
29+
30+
[targets]
31+
test = ["Test", "Random"]

src/InfiniteLinearAlgebra.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import FillArrays: AbstractFill
99
import BandedMatrices: BandedMatrix, _BandedMatrix, bandeddata
1010
import LinearAlgebra: lmul!, ldiv!, matprod, qr, QRPackedQ, AbstractTriangular, AbstractQ, adjoint, transpose,
1111
QR
12-
import LazyArrays: CachedArray, VecMulMat, DenseColumnMajor, FillLayout, ApplyMatrix
12+
import LazyArrays: CachedArray, DenseColumnMajor, FillLayout, ApplyMatrix
1313
import MatrixFactorizations: ql, ql!, QLPackedQ, getL, reflector!, reflectorApply!,
1414
QL
1515

@@ -20,8 +20,6 @@ import BandedMatrices: BandedMatrix, bandwidths
2020
import BlockBandedMatrices: _BlockSkylineMatrix, _BandedMatrix, AbstractBlockSizes, cumulsizes, _BlockSkylineMatrix, BlockSizes, blockstart, blockstride,
2121
BlockSkylineSizes, BlockSkylineMatrix, BlockBandedMatrix, _BlockBandedMatrix, BlockTridiagonal
2222

23-
import IntervalArithmetic
24-
import IntervalArithmetic: Interval, emptyinterval
2523

2624
if VERSION < v"1.2-"
2725
import Base: has_offset_axes
@@ -38,6 +36,5 @@ include("banded/infbanded.jl")
3836
include("blockbanded/infblocktridiagonal.jl")
3937
include("banded/infqltoeplitz.jl")
4038
include("infql.jl")
41-
include("banded/rigorous.jl")
4239

4340
end # module

src/banded/hessenbergq.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ bandwidths(Q::LowerHessenbergQ) = (size(Q,1)-1,1)
8787
adjoint(Q::UpperHessenbergQ) = LowerHessenbergQ(adjoint.(Q.q))
8888
adjoint(Q::LowerHessenbergQ) = UpperHessenbergQ(adjoint.(Q.q))
8989

90+
check_mul_axes(A::AbstractHessenbergQ, B, C...) =
91+
axes(A,2) == axes(B,1) || throw(DimensionMismatch("Second axis of A, $(axes(A,2)), and first axis of B, $(axes(B,1)) must match"))
92+
93+
9094
function lmul!(Q::LowerHessenbergQ{T}, x::AbstractVector) where T
9195
t = Array{T}(undef, 2)
9296
for n = 1:length(Q.q)

src/banded/infbanded.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const TriToeplitz{T} = Tridiagonal{T,Fill{T,1,Tuple{OneToInf{Int}}}}
2-
const InfToeplitz{T} = BandedMatrix{T,<:ApplyMatrix{T,<:VecMulMat{DenseColumnMajor,FillLayout,T,T}},OneToInf{Int}}
3-
const PertToeplitz{T} = BandedMatrix{T,<:Hcat{T,<:Tuple{Matrix{T},ApplyMatrix{T,<:VecMulMat{DenseColumnMajor,FillLayout,T,T}}}},OneToInf{Int}}
2+
const ConstRows{T} = ApplyMatrix{T,typeof(*),<:Tuple{<:AbstractVector,<:AbstractFill}}
3+
const InfToeplitz{T} = BandedMatrix{T,<:ConstRows{T},OneToInf{Int}}
4+
const PertToeplitz{T} = BandedMatrix{T,<:Hcat{T,<:Tuple{Matrix{T},<:ConstRows{T}}},OneToInf{Int}}
45

56
const SymTriPertToeplitz{T} = SymTridiagonal{T,Vcat{T,1,Tuple{Vector{T},Fill{T,1,Tuple{OneToInf{Int}}}}}}
67
const TriPertToeplitz{T} = Tridiagonal{T,Vcat{T,1,Tuple{Vector{T},Fill{T,1,Tuple{OneToInf{Int}}}}}}

src/banded/reducetoeplitzql.jl

Lines changed: 0 additions & 141 deletions
This file was deleted.

src/banded/rigorous.jl

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/blockbanded/infblocktridiagonal.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ for op in (:-, :+)
2828
end
2929
end
3030

31-
*(a::AbstractVector, b::AbstractFill{<:Any,2,Tuple{OneTo{Int},OneToInf{Int}}}) = MulArray(a,b)
31+
*(a::AbstractVector, b::AbstractFill{<:Any,2,Tuple{OneTo{Int},OneToInf{Int}}}) = ApplyArray(*,a,b)
3232

3333

3434
sizes_from_blocks(A::AbstractVector, ::Tuple{OneToInf{Int}}) = BlockSizes((Vcat(1, 1 .+ cumsum(length.(A))),))

test/runtests.jl

Lines changed: 2 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using InfiniteLinearAlgebra, BlockBandedMatrices, BlockArrays, BandedMatrices, InfiniteArrays, FillArrays, LazyArrays, Test, MatrixFactorizations, LinearAlgebra
1+
using InfiniteLinearAlgebra, BlockBandedMatrices, BlockArrays, BandedMatrices, InfiniteArrays, FillArrays, LazyArrays, Test, MatrixFactorizations, LinearAlgebra, Random
22
import InfiniteLinearAlgebra: qltail, toeptail, tailiterate , tailiterate!, tail_de, ql_X!,
3-
InfToeplitz, PertToeplitz, TriToeplitz, InfBandedMatrix, householderparams, combine_two_Q, periodic_combine_two_Q, householderparams,
3+
InfToeplitz, PertToeplitz, TriToeplitz, InfBandedMatrix,
44
rightasymptotics, QLHessenberg
55
import BlockBandedMatrices: isblockbanded, _BlockBandedMatrix
66
import MatrixFactorizations: QLPackedQ
@@ -44,7 +44,6 @@ end
4444

4545
include("test_hessenbergq.jl")
4646

47-
4847
@testset "PertTriToeplitz QL" begin
4948
A = Tridiagonal(Vcat(Float64[], Fill(2.0,∞)),
5049
Vcat(Float64[2.0], Fill(0.0,∞)),
@@ -55,7 +54,6 @@ include("test_hessenbergq.jl")
5554
end
5655
end
5756

58-
5957
@testset "Pert Hessenberg Toeplitz" begin
6058
a = [1,2,5,0.5]
6159
Random.seed!(0)
@@ -100,7 +98,6 @@ end
10098
end
10199
end
102100

103-
104101
@testset "Pert faux-periodic QL" begin
105102
a = [0.5794879759059747 + 0.0im,0.538107104952824 - 0.951620830938543im,-0.19352887774167749 - 0.3738926065520737im,0.4314153362874331,0.0]
106103
T = _BandedMatrix(a*Ones{ComplexF64}(1,∞), ∞, 3,1)
@@ -119,86 +116,3 @@ end
119116
@test Qn[1:10,1:10] * diagm(0 => [Ones(5); -(-1).^(1:5)]) Q[1:10,1:10]
120117
@test diagm(0 => [Ones(5); -(-1).^(1:5)]) * Ln[1:10,1:10] L[1:10,1:10]
121118
end
122-
123-
124-
function qdL(A)
125-
l,u = bandwidths(A)
126-
H = _BandedMatrix(A.data, ∞, l+u-1, 1)
127-
Q1,L1 = ql(H)
128-
D1, Q1, L1 = reduceband(A)
129-
T2 = _BandedMatrix(Lrightasymptotics(L1), ∞, l, u)
130-
l1 = L1[1,1]
131-
A2 = [[D1 l1 zeros(1,10-size(D1,2)-1)]; T2[1:10-1,1:10]] # TODO: remove
132-
B2 = _BandedMatrix(T2.data, ∞, l+u-2, 2)
133-
B2 = _BandedMatrix(T2.data, ∞, l+u-2, 2)
134-
D2, Q2, L2 = reduceband(B2)
135-
l2 = L2[1,1]
136-
# peroidic tail
137-
T3 = _BandedMatrix(Lrightasymptotics(L2), ∞, l+1, u-1)
138-
A3 = [[D2 l2 zeros(1,10-size(D2,2)-1)]; T3[1:10-1,1:10]] # TODO: remove
139-
140-
Q3,L3 = ql( [A2[1,1] A2[1:1,2:3]; [Q2[1:3,1:1]' * T2[1:3,1] A3[1:1,1:2] ]])
141-
142-
fd_data = hcat([0; L3[:,1]; Q2[1:3,2:3]' * T2[1:3,1]], [L3[:,2]; T3[1:3,1]], [L3[2,3]; T3[1:4,2]])
143-
B3 = _BandedMatrix(Hcat(fd_data, T3.data), ∞, l+u-1, 1)
144-
145-
ql(B3).L
146-
end
147-
148-
@testset "quick-and-dirty L" begin
149-
for λ in (5,1,0.1+0.1im,-0.5-0.1im), A in (BandedMatrix(3 => Fill(7/10,∞), 2 => Fill(1,∞), 0 => Fill(-λ,∞), -1 => Fill(2im,∞)),
150-
BandedMatrix(3 => Fill(7/10,∞), 2 => Fill(1,∞), 0 => Fill(-conj(λ),∞), -1 => Fill(-2im,∞)))
151-
L∞ = qdL(A)[1:10,1:10]
152-
Ln = ql(A[1:1000,1:1000]).L[1:10,1:10]
153-
@test L∞ .* sign.(diag(L∞)) Matrix(Ln) .* sign.(diag(Ln))
154-
end
155-
for λ in (-3-0.1im, 0.0, -1im)
156-
A = BandedMatrix(3 => Fill(7/10,∞), 2 => Fill(1,∞), 0 => Fill(-conj(λ),∞), -1 => Fill(-2im,∞))
157-
@test abs(qdL(A)[1,1]) abs(ql(A[1:10000,1:10000]).L[1,1])
158-
end
159-
for λ in (1+2im,)
160-
A = BandedMatrix(3 => Fill(7/10,∞), 2 => Fill(1,∞), 0 => Fill(-λ,∞), -1 => Fill(2im,∞))
161-
@test_throws DomainError qdL(A)
162-
end
163-
end
164-
165-
166-
167-
function tail_de_j(a::AbstractVector{T}, j) where T
168-
m = length(a)
169-
C = [view(a,m-1:-1:1) Vcat(-a[end]*Eye(m-2), Zeros{T}(1,m-2))]
170-
λ, V = eigen(C)::Eigen{T,T,Matrix{T},Vector{T}}
171-
n2 = abs2.(λ[j])
172-
n2  abs2(a[end]) || throw(DomainError(a, "QL factorization does not exist. This could indicate that the operator is not Fredholm or that the dimension of the kernel exceeds that of the co-kernel. Try again with the adjoint."))
173-
c_abs = sqrt((n2 - abs2(a[end]))/abs2(V[1,j]))
174-
c_sgn = -sign(λ[j])/sign(V[1,j]*a[end-1] - V[2,j]*a[end])
175-
c_sgn*c_abs*V[end:-1:1,j]
176-
end
177-
178-
@testset "non-uniqueness" begin
179-
a = [10.774290245267503 - 2.01600077393353im , -0.21512211005762638 + 0.4071609685512763im , -1.1744464421530598 + 0.6046364065537878im , 0.9690771351593747 + 0.24407852288135806im,
180-
-0.17679826119222275 - 1.0449912257889253im , 1.350321850620113 + 0.1195877826052787im , -0.7557518148047799 - 0.809927665736972im , -0.24869467464627973 + 0.06062801043516876im,
181-
-0.83619838577036 + 1.053001604590783im ,1.0 + 0.0im ]
182-
183-
A = _BandedMatrix(reverse(a) * Ones{ComplexF64}(1,∞), ∞, length(a)-2, 1)
184-
l,u = bandwidths(A)
185-
Q,L = ql(A)
186-
@test Q[1:10,1:11] * L[1:11,1:10] A[1:10,1:10]
187-
188-
de = tail_de(a)
189-
de2 = tail_de_j(a, 2)
190-
191-
@test !(de de2)
192-
193-
X = [transpose(a); 0 transpose(de2)]
194-
F = ql_X!(X)
195-
@test X[1,1:end-1] de2
196-
factors = _BandedMatrix(Hcat([zero(T); X[1,end-1]; X[2,end-1:-1:1]], [0; X[2,end:-1:1]] * Ones{T}(1,∞)), ∞, l+u, 1)
197-
Q2,L2 = QLHessenberg(factors, Fill(F.Q,∞))
198-
@test Q2[1:10,1:11] * L2[1:11,1:10] A[1:10,1:10]
199-
@test Q2[1:10,1:11] * (Q2')[1:11,1:10] I
200-
@test (Q2')[1:10,1:100] * (Q2)[1:100,1:10] I
201-
@test (Q')[1:10,1:100] * (Q)[1:100,1:10] I
202-
203-
@test !(abs(L2[1,1]) abs(L[1,1]))
204-
end

0 commit comments

Comments
 (0)