5
5
In-place version of [`kernelmatrix`](@ref) where pre-allocated matrix `K` will be
6
6
overwritten with the kernel matrix.
7
7
8
- kernelmatrix!(K::AbstractMatrix, κ::Kernel, X::AbstractMatrix; obsdim::Integer=2 )
8
+ kernelmatrix!(K::AbstractMatrix, κ::Kernel, X::AbstractMatrix; obsdim)
9
9
kernelmatrix!(
10
10
K::AbstractMatrix,
11
11
κ::Kernel,
12
12
X::AbstractMatrix,
13
13
Y::AbstractMatrix;
14
- obsdim::Integer=2 ,
14
+ obsdim,
15
15
)
16
16
17
- Equivalent to `kernelmatrix!(K, κ, ColVecs(X))` and
18
- `kernelmatrix(K, κ, ColVecs(X), ColVecs(Y))` respectively.
19
- Set `obsdim=1` to get `RowVecs`.
17
+ If `obsdim=1`, equivalent to `kernelmatrix!(K, κ, RowVecs(X))` and
18
+ `kernelmatrix(K, κ, RowVecs(X), RowVecs(Y))`, respectively.
19
+ If `obsdim=2`, equivalent to `kernelmatrix!(K, κ, ColVecs(X))` and
20
+ `kernelmatrix(K, κ, ColVecs(X), ColVecs(Y))`, respectively.
20
21
21
22
See also: [`ColVecs`](@ref), [`RowVecs`](@ref)
22
23
"""
@@ -35,12 +36,13 @@ Compute the kernel `κ` for each pair of inputs in `x` and `y`.
35
36
Returns a matrix of size `(length(x), length(y))` satisfying
36
37
`kernelmatrix(κ, x, y)[p, q] == κ(x[p], y[q])`.
37
38
38
- kernelmatrix(κ::Kernel, X::AbstractMatrix; obsdim::Int=2 )
39
- kernelmatrix(κ::Kernel, X::AbstractMatrix, Y::AbstractMatrix; obsdim::Int=2 )
39
+ kernelmatrix(κ::Kernel, X::AbstractMatrix; obsdim)
40
+ kernelmatrix(κ::Kernel, X::AbstractMatrix, Y::AbstractMatrix; obsdim)
40
41
41
- Equivalent to `kernelmatrix(κ, ColVecs(X))` and `kernelmatrix(κ, ColVecs(X), ColVecs(Y))`
42
- respectively.
43
- Set `obsdim=1` to get `RowVecs`.
42
+ If `obsdim=1`, equivalent to `kernelmatrix(κ, RowVecs(X))` and
43
+ `kernelmatrix(κ, RowVecs(X), RowVecs(Y))`, respectively.
44
+ If `obsdim=2`, equivalent to `kernelmatrix(κ, ColVecs(X))` and
45
+ `kernelmatrix(κ, ColVecs(X), ColVecs(Y))`, respectively.
44
46
45
47
See also: [`ColVecs`](@ref), [`RowVecs`](@ref)
46
48
"""
@@ -52,18 +54,19 @@ kernelmatrix
52
54
53
55
In place version of [`kernelmatrix_diag`](@ref).
54
56
55
- kernelmatrix_diag!(K::AbstractVector, κ::Kernel, X::AbstractMatrix; obsdim::Int=2 )
57
+ kernelmatrix_diag!(K::AbstractVector, κ::Kernel, X::AbstractMatrix; obsdim)
56
58
kernelmatrix_diag!(
57
59
K::AbstractVector,
58
60
κ::Kernel,
59
61
X::AbstractMatrix,
60
62
Y::AbstractMatrix;
61
- obsdim::Int=2,
63
+ obsdim
62
64
)
63
65
64
- Equivalent to `kernelmatrix_diag!(K, κ, ColVecs(X))` and
65
- `kernelmatrix_diag!(K, κ, ColVecs(X), ColVecs(Y))` respectively.
66
- Set `obsdim=1` to get `RowVecs`.
66
+ If `obsdim=1`, equivalent to `kernelmatrix_diag!(K, κ, RowVecs(X))` and
67
+ `kernelmatrix_diag!(K, κ, RowVecs(X), RowVecs(Y))`, respectively.
68
+ If `obsdim=2`, equivalent to `kernelmatrix_diag!(K, κ, ColVecs(X))` and
69
+ `kernelmatrix_diag!(K, κ, ColVecs(X), ColVecs(Y))`, respectively.
67
70
68
71
See also: [`ColVecs`](@ref), [`RowVecs`](@ref)
69
72
"""
@@ -79,11 +82,13 @@ Compute the diagonal of `kernelmatrix(κ, x)` efficiently.
79
82
Compute the diagonal of `kernelmatrix(κ, x, y)` efficiently.
80
83
Requires that `x` and `y` are the same length.
81
84
82
- kernelmatrix_diag(κ::Kernel, X::AbstractMatrix; obsdim::Int=2 )
83
- kernelmatrix_diag(κ::Kernel, X::AbstractMatrix, Y::AbstractMatrix; obsdim::Int=2 )
85
+ kernelmatrix_diag(κ::Kernel, X::AbstractMatrix; obsdim)
86
+ kernelmatrix_diag(κ::Kernel, X::AbstractMatrix, Y::AbstractMatrix; obsdim)
84
87
85
- Equivalent to `kernelmatrix_diag(κ, ColVecs(X))` and
86
- `kernelmatrix_diag(κ, ColVecs(X), ColVecs(Y))` respectively.
88
+ If `obsdim=1`, equivalent to `kernelmatrix_diag(κ, RowVecs(X))` and
89
+ `kernelmatrix_diag(κ, RowVecs(X), RowVecs(Y))`, respectively.
90
+ If `obsdim=2`, equivalent to `kernelmatrix_diag(κ, ColVecs(X))` and
91
+ `kernelmatrix_diag(κ, ColVecs(X), ColVecs(Y))`, respectively.
87
92
88
93
See also: [`ColVecs`](@ref), [`RowVecs`](@ref)
89
94
"""
@@ -162,10 +167,10 @@ end
162
167
# Wrapper methods for AbstractMatrix inputs to maintain obsdim interface.
163
168
#
164
169
165
- const defaultobs = 2
170
+ const defaultobs = nothing
166
171
167
172
function kernelmatrix! (
168
- K:: AbstractMatrix , κ:: Kernel , X:: AbstractMatrix ; obsdim:: Int = defaultobs
173
+ K:: AbstractMatrix , κ:: Kernel , X:: AbstractMatrix ; obsdim:: Union{ Int,Nothing} = defaultobs
169
174
)
170
175
return kernelmatrix! (K, κ, vec_of_vecs (X; obsdim= obsdim))
171
176
end
@@ -175,12 +180,12 @@ function kernelmatrix!(
175
180
κ:: Kernel ,
176
181
X:: AbstractMatrix ,
177
182
Y:: AbstractMatrix ;
178
- obsdim:: Int = defaultobs,
183
+ obsdim:: Union{ Int,Nothing} = defaultobs,
179
184
)
180
185
return kernelmatrix! (K, κ, vec_of_vecs (X; obsdim= obsdim), vec_of_vecs (Y; obsdim= obsdim))
181
186
end
182
187
183
- function kernelmatrix (κ:: Kernel , X:: AbstractMatrix ; obsdim:: Int = defaultobs)
188
+ function kernelmatrix (κ:: Kernel , X:: AbstractMatrix ; obsdim:: Union{ Int,Nothing} = defaultobs)
184
189
return kernelmatrix (κ, vec_of_vecs (X; obsdim= obsdim))
185
190
end
186
191
@@ -189,7 +194,7 @@ function kernelmatrix(κ::Kernel, X::AbstractMatrix, Y::AbstractMatrix; obsdim=d
189
194
end
190
195
191
196
function kernelmatrix_diag! (
192
- K:: AbstractVector , κ:: Kernel , X:: AbstractMatrix ; obsdim:: Int = defaultobs
197
+ K:: AbstractVector , κ:: Kernel , X:: AbstractMatrix ; obsdim:: Union{ Int,Nothing} = defaultobs
193
198
)
194
199
return kernelmatrix_diag! (K, κ, vec_of_vecs (X; obsdim= obsdim))
195
200
end
@@ -199,19 +204,21 @@ function kernelmatrix_diag!(
199
204
κ:: Kernel ,
200
205
X:: AbstractMatrix ,
201
206
Y:: AbstractMatrix ;
202
- obsdim:: Int = defaultobs,
207
+ obsdim:: Union{ Int,Nothing} = defaultobs,
203
208
)
204
209
return kernelmatrix_diag! (
205
210
K, κ, vec_of_vecs (X; obsdim= obsdim), vec_of_vecs (Y; obsdim= obsdim)
206
211
)
207
212
end
208
213
209
- function kernelmatrix_diag (κ:: Kernel , X:: AbstractMatrix ; obsdim:: Int = defaultobs)
214
+ function kernelmatrix_diag (
215
+ κ:: Kernel , X:: AbstractMatrix ; obsdim:: Union{Int,Nothing} = defaultobs
216
+ )
210
217
return kernelmatrix_diag (κ, vec_of_vecs (X; obsdim= obsdim))
211
218
end
212
219
213
220
function kernelmatrix_diag (
214
- κ:: Kernel , X:: AbstractMatrix , Y:: AbstractMatrix ; obsdim:: Int = defaultobs
221
+ κ:: Kernel , X:: AbstractMatrix , Y:: AbstractMatrix ; obsdim:: Union{ Int,Nothing} = defaultobs
215
222
)
216
223
return kernelmatrix_diag (
217
224
κ, vec_of_vecs (X; obsdim= obsdim), vec_of_vecs (Y; obsdim= obsdim)
0 commit comments