Skip to content

Commit e8339aa

Browse files
committed
some bugfixing
1 parent d64a07f commit e8339aa

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/decompOPs.jl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# This currently takes the weight multiplication operator as input.
22
# I will probably change this to take the weight function instead.
3-
function cholesky_jacobimatrix(W)
3+
function cholesky_jacobimatrix(W::Symmetric)
44
bands = CholeskyJacobiBands(W) # the cached array only needs to store two bands bc of symmetry
55
return SymTridiagonal(bands[1,:],bands[2,:])
66
end
77

88
# The generated Jacobi operators are symmetric tridiagonal, so we store their data as two bands
99
mutable struct CholeskyJacobiBands{T} <: AbstractCachedMatrix{T}
10-
data
11-
U
12-
X
10+
data::Matrix{T}
11+
U::UpperTriangular
12+
X::Symmetric{T}
1313
datasize::Int
1414
array
1515
end
@@ -18,8 +18,7 @@ end
1818
symmjacobim(J::SymTridiagonal) = Symmetric(BandedMatrix(0=>J.dv, 1=>J.ev))
1919

2020
# Computes the initial data for the Jacobi operator bands
21-
function CholeskyJacobiBands(W)
22-
T = eltype(W)
21+
function CholeskyJacobiBands(W::Symmetric{T}) where T
2322
U = cholesky(W).U
2423
X = symmjacobim(jacobimatrix(Normalized(Legendre()[affine(zero(T)..one(T),Inclusion(-one(T)..one(T))),:])))
2524
dat = zeros(T,2,10)
@@ -37,15 +36,15 @@ function resizedata!(K::CholeskyJacobiBands, nm::Integer)
3736
νμ = K.datasize
3837
if nm > νμ
3938
olddata = copy(K.data)
40-
K.data = similar(K.data, nm, nm)
39+
K.data = similar(K.data, 2, nm)
4140
K.data[axes(olddata)...] = olddata
4241
inds = νμ:nm
4342
cache_filldata!(K, inds)
4443
K.datasize = nm
4544
end
4645
K
4746
end
48-
function cache_filldata!(J::CholeskyJacobiBands, inds)
47+
function cache_filldata!(J::CholeskyJacobiBands, inds::UnitRange{Int})
4948
for k in inds
5049
J.data[1,k] = (J.U * (J.X * (J.U \ [zeros(k-1); 1; zeros(∞)])))[k]
5150
J.data[2,k] = (J.U * (J.X * (J.U \ [zeros(k); 1; zeros(∞)])))[k]
@@ -56,7 +55,7 @@ function getindex(K::CholeskyJacobiBands, k::Integer, j::Integer)
5655
resizedata!(K, max(k,j))
5756
K.data[k, j]
5857
end
59-
function getindex(K::CholeskyJacobiBands, kr::Integer, jr::UnitRange{Integer})
58+
function getindex(K::CholeskyJacobiBands, kr::Integer, jr::UnitRange{Int})
6059
resizedata!(K, maximum(jr))
6160
K.data[kr, jr]
6261
end

0 commit comments

Comments
 (0)