@@ -3,13 +3,20 @@ using .PDMats: PDMat
3
3
export kernelpdmat
4
4
5
5
"""
6
- Compute a positive-definite matrix in the form of a `PDMat` matrix see [PDMats.jl](https://github.com/JuliaStats/PDMats.jl)
7
- with the cholesky decomposition precomputed.
8
- The algorithm recursively tries to add recursively a diagonal nugget until positive
9
- definiteness is achieved or that the noise is too big.
6
+ kernelpdmat(k::Kernel, X::AbstractMatrix; obsdim::Int=2)
7
+ kernelpdmat(k::Kernel, X::AbstractVector)
8
+
9
+ Compute a positive-definite matrix in the form of a `PDMat` matrix see [PDMats.jl](https://github.com/JuliaStats/PDMats.jl)
10
+ with the cholesky decomposition precomputed.
11
+ The algorithm recursively tries to add recursively a diagonal nugget until positive
12
+ definiteness is achieved or until the noise is too big.
10
13
"""
11
14
function kernelpdmat (κ:: Kernel , X:: AbstractMatrix ; obsdim:: Int = defaultobs)
12
- K = kernelmatrix (κ, X; obsdim= obsdim)
15
+ return kernelpdmat (κ, vec_of_vecs (X; obsdim= obsdim))
16
+ end
17
+
18
+ function kernelpdmat (κ:: Kernel , X:: AbstractVector )
19
+ K = kernelmatrix (κ, X)
13
20
Kmax = maximum (K)
14
21
α = eps (eltype (K))
15
22
while ! isposdef (K + α * I) && α < 0.01 * Kmax
@@ -24,7 +31,3 @@ function kernelpdmat(κ::Kernel, X::AbstractMatrix; obsdim::Int=defaultobs)
24
31
end
25
32
return PDMat (K + α * I)
26
33
end
27
-
28
- function kernelpdmat (κ:: Kernel , X:: AbstractVector{<:Real} ; obsdim= defaultobs)
29
- return kernelpdmat (κ, reshape (X, 1 , :); obsdim= 2 )
30
- end
0 commit comments