MLPACK  1.0.11
laplacian_kernel.hpp
Go to the documentation of this file.
1 
22 #ifndef __MLPACK_CORE_KERNELS_LAPLACIAN_KERNEL_HPP
23 #define __MLPACK_CORE_KERNELS_LAPLACIAN_KERNEL_HPP
24 
25 #include <mlpack/core.hpp>
26 
27 namespace mlpack {
28 namespace kernel {
29 
41 {
42  public:
47  { }
48 
55  bandwidth(bandwidth)
56  { }
57 
69  template<typename VecType>
70  double Evaluate(const VecType& a, const VecType& b) const
71  {
72  // The precalculation of gamma saves us a little computation time.
74  }
75 
84  double Evaluate(const double t) const
85  {
86  // The precalculation of gamma saves us a little computation time.
87  return exp(-t / bandwidth);
88  }
89 
91  double Bandwidth() const { return bandwidth; }
93  double& Bandwidth() { return bandwidth; }
94 
96  std::string ToString() const
97  {
98  std::ostringstream convert;
99  convert << "LaplacianKernel [" << this << "]" << std::endl;
100  convert << " Bandwidth: " << bandwidth << std::endl;
101  return convert.str();
102  }
103 
104  private:
106  double bandwidth;
107 };
108 
110 template<>
112 {
113  public:
115  static const bool IsNormalized = true;
116 };
117 
118 }; // namespace kernel
119 }; // namespace mlpack
120 
121 #endif
This is a template class that can provide information about various kernels.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:31
std::string ToString() const
Return a string representation of the kernel.
double Evaluate(const VecType &a, const VecType &b) const
Evaluation of the Laplacian kernel.
LaplacianKernel()
Default constructor; sets bandwidth to 1.0.
double & Bandwidth()
Modify the bandwidth.
double Evaluate(const double t) const
Evaluation of the Laplacian kernel given the distance between two points.
static double Evaluate(const VecType1 &a, const VecType2 &b)
Computes the distance between two points.
The standard Laplacian kernel.
double bandwidth
Kernel bandwidth.
double Bandwidth() const
Get the bandwidth.
LaplacianKernel(double bandwidth)
Construct the Laplacian kernel with a custom bandwidth.