MLPACK  1.0.8
triangular_kernel.hpp
Go to the documentation of this file.
1 
22 #ifndef __MLPACK_CORE_KERNELS_TRIANGULAR_KERNEL_HPP
23 #define __MLPACK_CORE_KERNELS_TRIANGULAR_KERNEL_HPP
24 
25 #include <mlpack/core.hpp>
27 
28 namespace mlpack {
29 namespace kernel {
30 
41 {
42  public:
48  TriangularKernel(const double bandwidth = 1.0) : bandwidth(bandwidth) { }
49 
56  template<typename Vec1Type, typename Vec2Type>
57  double Evaluate(const Vec1Type& a, const Vec2Type& b) const
58  {
59  return std::max(0.0, (1 - metric::EuclideanDistance::Evaluate(a, b) /
60  bandwidth));
61  }
62 
69  double Evaluate(const double distance) const
70  {
71  return std::max(0.0, (1 - distance) / bandwidth);
72  }
73 
75  double Bandwidth() const { return bandwidth; }
77  double& Bandwidth() { return bandwidth; }
78 
79  private:
81  double bandwidth;
82 };
83 
85 template<>
87 {
88  public:
90  static const bool IsNormalized = true;
91 };
92 
93 }; // namespace kernel
94 }; // namespace mlpack
95 
96 #endif