00001 00022 #ifndef __MLPACK_CORE_KERNELS_LAPLACIAN_KERNEL_HPP 00023 #define __MLPACK_CORE_KERNELS_LAPLACIAN_KERNEL_HPP 00024 00025 #include <mlpack/core.hpp> 00026 00027 namespace mlpack { 00028 namespace kernel { 00029 00040 class LaplacianKernel 00041 { 00042 public: 00046 LaplacianKernel() : bandwidth(1.0) 00047 { } 00048 00054 LaplacianKernel(double bandwidth) : 00055 bandwidth(bandwidth) 00056 { } 00057 00069 template<typename VecType> 00070 double Evaluate(const VecType& a, const VecType& b) const 00071 { 00072 // The precalculation of gamma saves us a little computation time. 00073 return exp(-metric::EuclideanDistance::Evaluate(a, b) / bandwidth); 00074 } 00075 00084 double Evaluate(const double t) const 00085 { 00086 // The precalculation of gamma saves us a little computation time. 00087 return exp(-t / bandwidth); 00088 } 00089 00091 double Bandwidth() const { return bandwidth; } 00093 double& Bandwidth() { return bandwidth; } 00094 00095 private: 00097 double bandwidth; 00098 }; 00099 00101 template<> 00102 class KernelTraits<LaplacianKernel> 00103 { 00104 public: 00106 static const bool IsNormalized = true; 00107 }; 00108 00109 }; // namespace kernel 00110 }; // namespace mlpack 00111 00112 #endif