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);
76 }
else if (distance > 1) {
79 return arma::datum::nan;
89 template<
typename Archive>
106 static const bool IsNormalized =
true;
108 static const bool UsesSquaredDistance =
false;
This is a template class that can provide information about various kernels.
Linear algebra utility functions, generally performed on matrices or vectors.
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.
The core includes that mlpack expects; standard C++ includes and Armadillo.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename std::enable_if_t< HasSerialize< T >::value > *=0)
Call this function to produce a name-value pair; this is similar to BOOST_SERIALIZATION_NVP(), but should be used for types that have a Serialize() function (or contain a type that has a Serialize() function) instead of a serialize() function.
double Gradient(const double distance) const
Evaluate the gradient of triangular kernel given that the distance between the two points is known...
double bandwidth
The bandwidth of the kernel.
static VecTypeA::elem_type Evaluate(const VecTypeA &a, const VecTypeB &b)
Computes the distance between two points.
double & Bandwidth()
Modify the bandwidth of the kernel.
TriangularKernel(const double bandwidth=1.0)
Initialize the triangular kernel with the given bandwidth (default 1.0).
double Evaluate(const VecTypeA &a, const VecTypeB &b) const
Evaluate the triangular kernel for the two given vectors.
void Serialize(Archive &ar, const unsigned int)
Serialize the kernel.
double Bandwidth() const
Get the bandwidth of the kernel.