Skip to content

Commit f6a6782

Browse files
authored
Generalise Cholesky (#84)
* generalise Cholesky * v0.5.10
1 parent d2fd2ff commit f6a6782

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "InfiniteLinearAlgebra"
22
uuid = "cde9dba0-b1de-11e9-2c62-0bab9446c55c"
3-
version = "0.5.9"
3+
version = "0.5.10"
44

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

src/infcholesky.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ end
66

77
size(U::AdaptiveCholeskyFactors) = size(U.data.array)
88
bandwidths(A::AdaptiveCholeskyFactors) = (0,bandwidth(A.data,2))
9-
AdaptiveCholeskyFactors(A::Symmetric) = AdaptiveCholeskyFactors(cache(parent(A)),0)
9+
10+
function AdaptiveCholeskyFactors(::SymmetricLayout{<:AbstractBandedLayout}, S::AbstractMatrix{T}) where T
11+
A = parent(S)
12+
l,u = bandwidths(A)
13+
data = BandedMatrix{T}(undef,(0,0),(l,u)) # pad super
14+
AdaptiveCholeskyFactors(CachedArray(data,A), 0)
15+
end
16+
AdaptiveCholeskyFactors(A::AbstractMatrix{T}) where T = AdaptiveCholeskyFactors(MemoryLayout(A), A)
1017
MemoryLayout(::Type{AdaptiveCholeskyFactors{T,DM,M}}) where {T,DM,M} = AdaptiveLayout{typeof(MemoryLayout(DM))}()
1118

1219

@@ -19,8 +26,9 @@ function partialcholesky!(F::AdaptiveCholeskyFactors{T,<:BandedMatrix}, n::Int)
1926
factors = view(F.data.data,kr,kr)
2027
banded_chol!(factors, UpperTriangular)
2128
# multiply remaining columns
22-
U1 = UpperTriangular(view(F.data.data,n-u+1:n,n-u+1:n))
23-
B = view(F.data.data,n-u+1:n,n+1:n+u)
29+
kr2 = max(n-u+1,1):n
30+
U1 = UpperTriangular(view(F.data.data,kr2,kr2))
31+
B = view(F.data.data,kr2,n+1:n+u)
2432
ldiv!(U1',B)
2533
muladd!(-one(T),B',B,one(T),view(F.data.data,n+1:n+u,n+1:n+u))
2634
F.ncols = n

src/infqr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function AdaptiveQRData(::AbstractBlockLayout, A::AbstractMatrix{T}) where T
2626
AdaptiveQRData(CachedArray(data,A), Vector{T}(), 0)
2727
end
2828

29-
AdaptiveQRData(A::AbstractMatrix{T}) where T = AdaptiveQRData(MemoryLayout(typeof(A)), A)
29+
AdaptiveQRData(A::AbstractMatrix{T}) where T = AdaptiveQRData(MemoryLayout(A), A)
3030

3131
function partialqr!(F::AdaptiveQRData{<:Any,<:BandedMatrix}, n::Int)
3232
if n > F.ncols

test/test_infcholesky.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ using InfiniteLinearAlgebra, LinearAlgebra, BandedMatrices, ArrayLayouts, Test
2121
b = [1; zeros(∞)]
2222
@test cholesky(S) \ b qr(S) \ b S \ b
2323
end
24+
25+
@testset "powers" begin
26+
b = [1; zeros(∞)]
27+
@test cholesky(S^2) \ b qr(S^2) \ b S^2 \ b
28+
end
2429
end

0 commit comments

Comments
 (0)