Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Commit

Permalink
Add default values for parametric constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
trthatcher committed Jan 4, 2019
1 parent 893bd5a commit ac987eb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/kernelfunctions/mercer/rationalquadratic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ struct GammaRationalQuadraticKernel{T<:AbstractFloat} <: AbstractRationalQuadrat
β::T
γ::T
function GammaRationalQuadraticKernel{T}(
α::Real,
β::Real,
γ::Real
α::Real=T(1),
β::Real=T(1),
γ::Real=T(1)
) where {T<:AbstractFloat}
@check_args(GammaRationalQuadraticKernel, α, α > zero(T), "α > 0")
@check_args(GammaRationalQuadraticKernel, β, β > zero(T), "β > 0")
Expand Down
2 changes: 1 addition & 1 deletion src/kernelfunctions/negativedefinite/log.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ LogKernel{Float64}(0.5,0.5)
struct LogKernel{T<:AbstractFloat} <: NegativeDefiniteKernel{T}
α::T
γ::T
function LogKernel{T}::Real, γ::Real) where {T<:AbstractFloat}
function LogKernel{T}::Real=T(1), γ::Real=T(1)) where {T<:AbstractFloat}
@check_args(LogKernel, α, α > zero(T), "α > 0")
@check_args(LogKernel, γ, one(T) >= γ > zero(T), "γ ∈ (0,1]")
return new{T}(α, γ)
Expand Down
4 changes: 2 additions & 2 deletions src/kernelfunctions/negativedefinite/power.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ PowerKernel{Float32}(0.5)
"""
struct PowerKernel{T<:AbstractFloat} <: NegativeDefiniteKernel{T}
γ::T
function PowerKernel{T}::Real) where {T<:AbstractFloat}
function PowerKernel{T}::Real=T(1)) where {T<:AbstractFloat}
@check_args(PowerKernel, γ, one(T) >= γ > zero(T), "γ ∈ (0,1]")
new{T}(γ)
end
end
PowerKernel::T = 1.0) where {T<:Real} = PowerKernel{promote_float(T)}(γ)
PowerKernel::T=1.0) where {T<:Real} = PowerKernel{promote_float(T)}(γ)

@inline basefunction(::PowerKernel) = SquaredEuclidean()

Expand Down
4 changes: 2 additions & 2 deletions src/kernelfunctions/sigmoid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ SigmoidKernel{Float64}(0.5,0.5)
struct SigmoidKernel{T<:AbstractFloat} <: Kernel{T}
a::T
c::T
function SigmoidKernel{T}(a::Real, c::Real) where {T<:AbstractFloat}
function SigmoidKernel{T}(a::Real=T(1), c::Real=T(1)) where {T<:AbstractFloat}
@check_args(SigmoidKernel, a, a > zero(T), "a > 0")
@check_args(SigmoidKernel, c, c >= zero(T), "c ≧ 0")
return new{T}(a, c)
end
end
function SigmoidKernel(a::T₁ = 1.0, c::T₂ = T₁(1)) where {T₁<:Real,T₂<:Real}
function SigmoidKernel(a::T₁=1.0, c::T₂=T₁(1)) where {T₁<:Real,T₂<:Real}
SigmoidKernel{promote_float(T₁,T₂)}(a,c)
end

Expand Down

0 comments on commit ac987eb

Please sign in to comment.