Skip to content

Commit 1a3fa33

Browse files
ConstantKernel Performance (#432)
* Add methods * Bump patch version * Use Fill * Update src/basekernels/constant.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Revert to fill Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent cbbf1d4 commit 1a3fa33

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "KernelFunctions"
22
uuid = "ec8451be-7e33-11e9-00cf-bbf324bd1392"
3-
version = "0.10.29"
3+
version = "0.10.30"
44

55
[deps]
66
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/basekernels/constant.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,12 @@ kappa(κ::ConstantKernel, x::Real) = only(κ.c) * one(x)
7777

7878
metric(::ConstantKernel) = Delta()
7979

80+
function kernelmatrix(k::ConstantKernel, x::AbstractVector)
81+
return fill(only(k.c), length(x), length(x))
82+
end
83+
84+
function kernelmatrix(k::ConstantKernel, x::AbstractVector, y::AbstractVector)
85+
return fill(only(k.c), length(x), length(y))
86+
end
87+
8088
Base.show(io::IO, κ::ConstantKernel) = print(io, "Constant Kernel (c = ", only.c), ")")

0 commit comments

Comments
 (0)