Skip to content

Commit 02fbe50

Browse files
authored
Lazy MemoryLayout for QR/Cholesky Jacobi matrices (#143)
* QR and Cholesky jacobimatrix with lazy memorylayout * add X multiplication tests * increase version number
1 parent 4789503 commit 02fbe50

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ClassicalOrthogonalPolynomials"
22
uuid = "b30e2e7b-c4ee-47da-9d5f-2c5c27239acd"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.10"
4+
version = "0.10.1"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/choleskyQR.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function cholesky_jacobimatrix(W::AbstractMatrix, Q)
5656
end
5757

5858
# The generated Jacobi operators are symmetric tridiagonal, so we store their data in two cached bands which are generated in tandem but can be accessed separately.
59-
mutable struct CholeskyJacobiData{T} <: AbstractMatrix{T}
59+
mutable struct CholeskyJacobiData{T} <: LazyMatrix{T}
6060
dv::AbstractVector{T} # store diagonal band entries in adaptively sized vector
6161
ev::AbstractVector{T} # store off-diagonal band entries in adaptively sized vector
6262
U::UpperTriangular{T} # store upper triangular conversion matrix (needed to extend available entries)
@@ -135,7 +135,7 @@ function qr_jacobimatrix(sqrtW::AbstractMatrix{T}, Q, method = :Q) where T
135135
end
136136

137137
# The generated Jacobi operators are symmetric tridiagonal, so we store their data in two cached bands which are generated in tandem but can be accessed separately.
138-
mutable struct QRJacobiData{method,T} <: AbstractMatrix{T}
138+
mutable struct QRJacobiData{method,T} <: LazyMatrix{T}
139139
dv::AbstractVector{T} # store diagonal band entries in adaptively sized vector
140140
ev::AbstractVector{T} # store off-diagonal band entries in adaptively sized vector
141141
U # store conversion, Q method: stores QR object. R method: only stores R.

test/test_choleskyQR.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ import LazyArrays: AbstractCachedMatrix, resizedata!
116116
# Comparison with Lanczos
117117
@test Jchol[1:500,1:500] Jlanc[1:500,1:500]
118118
end
119+
120+
@testset "Jacobi matrix multiplication" begin
121+
P = Normalized(legendre(0..1))
122+
x = axes(P,1)
123+
J = jacobimatrix(P)
124+
wf(x) = (1-x)^2
125+
sqrtwf(x) = (1-x)
126+
# compute Jacobi matrix via decomp
127+
Jchol = cholesky_jacobimatrix(wf, P)
128+
JqrQ = qr_jacobimatrix(sqrtwf, P)
129+
JqrR = qr_jacobimatrix(sqrtwf, P, :R)
130+
@test (Jchol*Jchol)[1:10,1:10] ApplyArray(*,Jchol,Jchol)[1:10,1:10]
131+
@test (Jchol*Jchol)[1:10,1:10] (JqrQ*JqrQ)[1:10,1:10]
132+
@test (Jchol*Jchol)[1:10,1:10] (JqrR*JqrR)[1:10,1:10]
133+
end
119134
end
120135
end
121136

0 commit comments

Comments
 (0)