MLPACK  1.0.4
triangular_kernel.hpp
Go to the documentation of this file.
00001 
00022 #ifndef __MLPACK_CORE_KERNELS_TRIANGULAR_KERNEL_HPP
00023 #define __MLPACK_CORE_KERNELS_TRIANGULAR_KERNEL_HPP
00024 
00025 #include <mlpack/core.hpp>
00026 #include <mlpack/core/metrics/lmetric.hpp>
00027 
00028 namespace mlpack {
00029 namespace kernel {
00030 
00040 class TriangularKernel
00041 {
00042  public:
00048   TriangularKernel(const double bandwidth = 1.0) : bandwidth(bandwidth) { }
00049 
00056   template<typename Vec1Type, typename Vec2Type>
00057   double Evaluate(const Vec1Type& a, const Vec2Type& b)
00058   {
00059     return std::max(0.0, (1 - metric::EuclideanDistance::Evaluate(a, b) /
00060         bandwidth));
00061   }
00062 
00064   double Bandwidth() const { return bandwidth; }
00066   double& Bandwidth() { return bandwidth; }
00067 
00068  private:
00070   double bandwidth;
00071 };
00072 
00073 }; // namespace kernel
00074 }; // namespace mlpack
00075 
00076 #endif