Skip to content

Commit 29b5ad7

Browse files
authored
Merge pull request JuliaGaussianProcesses#117 from devmotion/roundoff
2 parents df3819a + 3098084 commit 29b5ad7

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

Diff for: Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"
1515

1616
[compat]
1717
Compat = "2.2, 3"
18-
Distances = "0.8.2"
18+
Distances = "0.9"
1919
Requires = "1.0.1"
2020
SpecialFunctions = "0.8, 0.9, 0.10"
2121
StatsBase = "0.32, 0.33"

Diff for: src/basekernels/fbm.jl

+5-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ end
2020
function::FBMKernel)(x::AbstractVector{<:Real}, y::AbstractVector{<:Real})
2121
modX = sum(abs2, x)
2222
modY = sum(abs2, y)
23-
modXY = evaluate(SqEuclidean(sqroundoff), x, y)
23+
modXY = sqeuclidean(x, y)
2424
h = first.h)
2525
return (modX^h + modY^h - modXY^h)/2
2626
end
@@ -29,8 +29,6 @@ end
2929

3030
Base.show(io::IO, κ::FBMKernel) = print(io, "Fractional Brownian Motion Kernel (h = ", first.h), ")")
3131

32-
const sqroundoff = 1e-15
33-
3432
_fbm(modX, modY, modXY, h) = (modX^h + modY^h - modXY^h)/2
3533

3634
_mod(x::AbstractVector{<:Real}) = abs2.(x)
@@ -39,19 +37,19 @@ _mod(x::RowVecs) = vec(sum(abs2, x.X; dims=2))
3937

4038
function kernelmatrix::FBMKernel, x::AbstractVector)
4139
modx = _mod(x)
42-
modxx = pairwise(SqEuclidean(sqroundoff), x)
40+
modxx = pairwise(SqEuclidean(), x)
4341
return _fbm.(modx, modx', modxx, κ.h)
4442
end
4543

4644
function kernelmatrix!(K::AbstractMatrix, κ::FBMKernel, x::AbstractVector)
4745
modx = _mod(x)
48-
pairwise!(K, SqEuclidean(sqroundoff), x)
46+
pairwise!(K, SqEuclidean(), x)
4947
K .= _fbm.(modx, modx', K, κ.h)
5048
return K
5149
end
5250

5351
function kernelmatrix::FBMKernel, x::AbstractVector, y::AbstractVector)
54-
modxy = pairwise(SqEuclidean(sqroundoff), x, y)
52+
modxy = pairwise(SqEuclidean(), x, y)
5553
return _fbm.(_mod(x), _mod(y)', modxy, κ.h)
5654
end
5755

@@ -61,7 +59,7 @@ function kernelmatrix!(
6159
x::AbstractVector,
6260
y::AbstractVector,
6361
)
64-
pairwise!(K, SqEuclidean(sqroundoff), x, y)
62+
pairwise!(K, SqEuclidean(), x, y)
6563
K .= _fbm.(_mod(x), _mod(y)', K, κ.h)
6664
return K
6765
end

0 commit comments

Comments
 (0)