@@ -40,14 +40,16 @@ function kernelmatrix!(
40
40
41
41
featuredim = feature_dim (obsdim)
42
42
if ! check_dims (K, X, X, featuredim, obsdim)
43
- throw (DimensionMismatch (" Dimensions of the target array K $(size (K)) are not consistent with X $(size (X)) " ))
43
+ throw (DimensionMismatch (" Dimensions of the target array K $(size (K)) are not " *
44
+ " consistent with X $(size (X)) " ))
44
45
end
45
46
46
47
size (X, featuredim) == length (kernel) ||
47
48
error (" number of kernels and groups of features are not consistent" )
48
49
49
- kernelmatrix! (K, kernel. kernels[1 ], selectdim (X, featuredim, 1 ))
50
- for (k, Xi) in Iterators. drop (zip (kernel. kernels, eachslice (X; dims = featuredim)), 1 )
50
+ kernels_and_input = zip (kernel. kernels, eachslice (X; dims = featuredim))
51
+ kernelmatrix! (K, first (kernels_and_input)... )
52
+ for (k, Xi) in Iterators. drop (kernels_and_input, 1 )
51
53
K .*= kernelmatrix (k, Xi)
52
54
end
53
55
@@ -65,14 +67,15 @@ function kernelmatrix!(
65
67
66
68
featuredim = feature_dim (obsdim)
67
69
if ! check_dims (K, X, Y, featuredim, obsdim)
68
- throw (DimensionMismatch (" Dimensions $(size (K)) of the target array K are not consistent with X ($(size (X)) ) and Y ($(size (Y)) )" ))
70
+ throw (DimensionMismatch (" Dimensions $(size (K)) of the target array K are not " *
71
+ " consistent with X ($(size (X)) ) and Y ($(size (Y)) )" ))
69
72
end
70
73
71
74
size (X, featuredim) == length (kernel) ||
72
75
error (" number of kernels and groups of features are not consistent" )
73
76
74
77
kernels_and_input = zip (
75
- zip ( kernel. kernels,
78
+ kernel. kernels,
76
79
eachslice (X; dims = featuredim),
77
80
eachslice (Y; dims = featuredim),
78
81
)
@@ -95,7 +98,8 @@ function kernelmatrix(
95
98
96
99
featuredim = feature_dim (obsdim)
97
100
if ! check_dims (X, X, featuredim, obsdim)
98
- throw (DimensionMismatch (" Dimensions of the target array K $(size (K)) are not consistent with X $(size (X)) " ))
101
+ throw (DimensionMismatch (" Dimensions of the target array K $(size (K)) are not " *
102
+ " consistent with X $(size (X)) " ))
99
103
end
100
104
101
105
size (X, featuredim) == length (kernel) ||
@@ -113,11 +117,12 @@ function kernelmatrix(
113
117
Y:: AbstractMatrix ;
114
118
obsdim:: Int = defaultobs
115
119
)
116
- @assert obsdim ∈ (1 , 2 ) || error (" obsdim should be 1 or 2 (see docs of kernelmatrix))" )
120
+ obsdim ∈ (1 , 2 ) || error (" obsdim should be 1 or 2 (see docs of kernelmatrix))" )
117
121
118
122
featuredim = feature_dim (obsdim)
119
123
if ! check_dims (X, Y, featuredim, obsdim)
120
- throw (DimensionMismatch (" Dimensions $(size (K)) of the target array K are not consistent with X ($(size (X)) ) and Y ($(size (Y)) )" ))
124
+ throw (DimensionMismatch (" Dimensions $(size (K)) of the target array K are not " *
125
+ " consistent with X ($(size (X)) ) and Y ($(size (Y)) )" ))
121
126
end
122
127
123
128
size (X, featuredim) == length (kernel) ||
@@ -141,15 +146,17 @@ function kerneldiagmatrix!(
141
146
)
142
147
obsdim ∈ (1 , 2 ) || error (" obsdim should be 1 or 2 (see docs of kernelmatrix))" )
143
148
if length (K) != size (X, obsdim)
144
- throw (DimensionMismatch (" Dimensions of the target array K $(size (K)) are not consistent with X $(size (X)) " ))
149
+ throw (DimensionMismatch (" Dimensions of the target array K $(size (K)) are not " *
150
+ " consistent with X $(size (X)) " ))
145
151
end
146
152
147
153
featuredim = feature_dim (obsdim)
148
154
size (X, featuredim) == length (kernel) ||
149
155
error (" number of kernels and groups of features are not consistent" )
150
156
151
- kerneldiagmatrix! (K, kernel. kernels[1 ], selectdim (X, featuredim, 1 ))
152
- for (k, Xi) in Iterators. drop (zip (kernel. kernels, eachslice (X; dims = featuredim)), 1 )
157
+ kernels_and_input = zip (kernel. kernels, eachslice (X; dims = featuredim))
158
+ kerneldiagmatrix! (K, first (kernels_and_input)... )
159
+ for (k, Xi) in Iterators. drop (kernels_and_input, 1 )
153
160
K .*= kerneldiagmatrix (k, Xi)
154
161
end
155
162
0 commit comments