Skip to content

Commit 1a59fa8

Browse files
committed
Start TridiagonalConjugation
1 parent 5c38eff commit 1a59fa8

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

test/test_bidiagonalconjugation.jl

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,45 @@ using LazyArrays: LazyLayout
8989
end
9090

9191
@testset "Chebyshev" begin
92-
R0 = BandedMatrix(0 => [1; Fill(0.5,∞)], 2 => Fill(-0.5,∞))
92+
R0 = BandedMatrices._BandedMatrix(Vcat(-Ones(1,∞)/2,
93+
Zeros(1,∞),
94+
Hcat(Ones(1,1),Ones(1,∞)/2)), ℵ₀, 0,2)
95+
9396
D0 = BandedMatrix(1 => 1:∞)
9497
R1 = BandedMatrix(0 => 1 ./ (1:∞), 2 => -1 ./ (3:∞))
9598

96-
BidiagonalConjugation(R1, D0, R0, :U)
99+
B = BidiagonalConjugation(R0', D0', R1', :L)'
97100
end
98101
end
102+
103+
104+
"""
105+
tridiagonal(A, B) == Tridiagonal(A*B)
106+
"""
107+
function tridiagonalmul(A, B)
108+
T = promote_type(eltype(A), eltype(B))
109+
UX = Tridiagonal(Vector{T}(undef, n-1), Vector{T}(undef, n), Vector{T}(undef, n-1))
110+
111+
for j = 1:n-1
112+
UX.d[j] = U.data[3,j]*X.d[j] + U.data[2,j]*X.dl[j]
113+
end
114+
UX.d[n] = U.data[3,n]*X.d[n]
115+
116+
for j = 1:n-1
117+
UX.dl[j] = U.data[3,j]*X.d[j] + U.data[2,j]*X.dl[j]
118+
end
119+
end
120+
121+
@testset "TridiagonalConjugation" begin
122+
R0 = BandedMatrices._BandedMatrix(Vcat(-Ones(1,∞)/2,
123+
Zeros(1,∞),
124+
Hcat(Ones(1,1),Ones(1,∞)/2)), ℵ₀, 0,2)
125+
X_T = LazyBandedMatrices.Tridiagonal(Vcat(1.0, Fill(1/2,∞)), Zeros(∞), Fill(1/2,∞))
126+
127+
n = 1000; @time U = V = R0[1:n,1:n]
128+
@time X = Tridiagonal(Vector(X_T.dl[1:n-1]), Vector(X_T.d[1:n]), Vector(X_T.du[1:n-1]))
129+
130+
@time U*X
131+
T = Float64
132+
133+
end

0 commit comments

Comments
 (0)