Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/IterGP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ using AbstractGPs: AbstractGP, FiniteGP, MeanFunction, ZeroMean
export CholeskyPolicy, ConjugateGradientPolicy
export NoPreconditioner, CholeskyPreconditioner

include("lowrankplusdiagonal.jl")
include("preconditioners.jl")
include("policies.jl")
include("actors.jl")
Expand Down
16 changes: 16 additions & 0 deletions src/lowrankplusdiagonal.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
Type for matrices on the form A = D + UU' that can be inverted using the matrix inversion lemma.
"""
struct LowRankPlusDiagonal{TD <: AbstractMatrix, TU <: AbstractMatrix}
D::TD # Diagonal component
U::TU # Low-rank component
end

function LinearAlgebra.inv(A::LowRankPlusDiagonal)
(;D, U) = A
V = U'
Dinv = inv(D)
B = I + V*Dinv*U
Binv = inv(B)
Dinv - Dinv*U*Binv*V*Dinv
end
4 changes: 2 additions & 2 deletions src/preconditioners.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ function (p::CholeskyPreconditioner)(K, Σy)
K′ .= K′ - Iᵢ*Iᵢ'
L[:,i] = Iᵢ
end
L*L' + Σy
LowRankPlusDiagonal(Σy, L)
end

struct NoPreconditioner <: AbstractPreconditioner end
function (p::NoPreconditioner)(_, _) I end
function (p::NoPreconditioner)(_, _) I end