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(CEREAL_NVP(bandwidth));
112 static const bool IsNormalized =
true;
114 static const bool UsesSquaredDistance =
false;
double Gradient(const double distance) const
Evaluate the gradient of triangular kernel given that the distance between the two points is known...
Definition: triangular_kernel.hpp:73
This is a template class that can provide information about various kernels.
Definition: kernel_traits.hpp:27
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The trivially simple triangular kernel, defined by.
Definition: triangular_kernel.hpp:30
The core includes that mlpack expects; standard C++ includes and Armadillo.
double Evaluate(const VecTypeA &a, const VecTypeB &b) const
Evaluate the triangular kernel for the two given vectors.
Definition: triangular_kernel.hpp:49
static VecTypeA::elem_type Evaluate(const VecTypeA &a, const VecTypeB &b)
Computes the distance between two points.
Definition: lmetric_impl.hpp:24
double & Bandwidth()
Modify the bandwidth of the kernel.
Definition: triangular_kernel.hpp:92
TriangularKernel(const double bandwidth=1.0)
Initialize the triangular kernel with the given bandwidth (default 1.0).
Definition: triangular_kernel.hpp:38
double Evaluate(const double distance) const
Evaluate the triangular kernel given that the distance between the two points is known.
Definition: triangular_kernel.hpp:61
double Bandwidth() const
Get the bandwidth of the kernel.
Definition: triangular_kernel.hpp:90
void serialize(Archive &ar, const uint32_t)
Serialize the kernel.
Definition: triangular_kernel.hpp:96