12#ifndef MLPACK_CORE_KERNELS_TRIANGULAR_KERNEL_HPP
13#define MLPACK_CORE_KERNELS_TRIANGULAR_KERNEL_HPP
48 template<
typename VecTypeA,
typename VecTypeB>
49 double Evaluate(
const VecTypeA& a,
const VecTypeB& b)
const
63 return std::max(0.0, (1 - distance) / bandwidth);
77 return -1.0 / bandwidth;
79 else if (distance > 1)
85 return arma::datum::nan;
95 template<
typename Archive>
98 ar & BOOST_SERIALIZATION_NVP(bandwidth);
This is a template class that can provide information about various kernels.
static const bool UsesSquaredDistance
If true, then the kernel include a squared distance, ||x - y||^2 .
static const bool IsNormalized
If true, then the kernel is normalized: K(x, x) = K(y, y) = 1 for all x.
The trivially simple triangular kernel, defined by.
double Evaluate(const double distance) const
Evaluate the triangular kernel given that the distance between the two points is known.
double Evaluate(const VecTypeA &a, const VecTypeB &b) const
Evaluate the triangular kernel for the two given vectors.
TriangularKernel(const double bandwidth=1.0)
Initialize the triangular kernel with the given bandwidth (default 1.0).
double & Bandwidth()
Modify the bandwidth of the kernel.
double Gradient(const double distance) const
Evaluate the gradient of triangular kernel given that the distance between the two points is known.
double Bandwidth() const
Get the bandwidth of the kernel.
void serialize(Archive &ar, const unsigned int)
Serialize the kernel.
static VecTypeA::elem_type Evaluate(const VecTypeA &a, const VecTypeB &b)
Computes the distance between two points.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.