Skip to content

Commit a143ef5

Browse files
authored
Replace ∞ with ℵ₀ in Lanczos sizes (#135)
* replace infinity with aleph_0 * add tests that check powers work and sizes are correct
1 parent d43b558 commit a143ef5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/lanczos.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct LanczosConversion{T} <: LayoutMatrix{T}
6868
data::LanczosData{T}
6969
end
7070

71-
size(::LanczosConversion) = (∞,∞)
71+
size(::LanczosConversion) = (ℵ₀,ℵ₀)
7272
copy(R::LanczosConversion) = R
7373

7474
Base.permutedims(R::LanczosConversion{<:Number}) = transpose(R)
@@ -128,7 +128,7 @@ struct LanczosJacobiBand{T} <: LazyVector{T}
128128
diag::Symbol
129129
end
130130

131-
size(P::LanczosJacobiBand) = (,)
131+
size(P::LanczosJacobiBand) = (ℵ₀,)
132132
resizedata!(A::LanczosJacobiBand, n) = resizedata!(A.data, n)
133133

134134

test/test_lanczos.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import ClassicalOrthogonalPolynomials: recurrencecoefficients, PaddedLayout, ort
66
P = Legendre();
77
w = P * [1; zeros(∞)];
88
Q = LanczosPolynomial(w);
9+
X = jacobimatrix(Q);
910
@test Q.data.W[1:10,1:10] isa BandedMatrix
11+
@test size(X) === (ℵ₀,ℵ₀) # make sure size uses ℵ₀ instead of ∞
12+
# test taking integer powers of jacobi matrix
13+
@test (X*X)[1:100,1:100] (X^2)[1:100,1:100]
14+
@test (X*X*X)[1:100,1:100] (X^3)[1:100,1:100]
15+
@test (X*X*X*X)[1:100,1:100] (X^4)[1:100,1:100]
1016

1117
= Normalized(P);
1218
A,B,C = recurrencecoefficients(Q);
@@ -177,6 +183,7 @@ import ClassicalOrthogonalPolynomials: recurrencecoefficients, PaddedLayout, ort
177183
U = LanczosPolynomial(y, P₊)
178184
@test P₊ U
179185
R = P₊ \ U
186+
@test size(R) === (ℵ₀,ℵ₀)
180187
@test U[0.1,5] (P₊ * R * [zeros(4); 1; zeros(∞)])[0.1]
181188
end
182189
end

0 commit comments

Comments
 (0)