mlpack  1.0.12
laplacian_kernel.hpp
Go to the documentation of this file.
1 
14 #ifndef __MLPACK_CORE_KERNELS_LAPLACIAN_KERNEL_HPP
15 #define __MLPACK_CORE_KERNELS_LAPLACIAN_KERNEL_HPP
16 
17 #include <mlpack/core.hpp>
18 
19 namespace mlpack {
20 namespace kernel {
21 
33 {
34  public:
39  { }
40 
47  bandwidth(bandwidth)
48  { }
49 
61  template<typename VecType>
62  double Evaluate(const VecType& a, const VecType& b) const
63  {
64  // The precalculation of gamma saves us a little computation time.
66  }
67 
76  double Evaluate(const double t) const
77  {
78  // The precalculation of gamma saves us a little computation time.
79  return exp(-t / bandwidth);
80  }
81 
83  double Bandwidth() const { return bandwidth; }
85  double& Bandwidth() { return bandwidth; }
86 
88  std::string ToString() const
89  {
90  std::ostringstream convert;
91  convert << "LaplacianKernel [" << this << "]" << std::endl;
92  convert << " Bandwidth: " << bandwidth << std::endl;
93  return convert.str();
94  }
95 
96  private:
98  double bandwidth;
99 };
100 
102 template<>
104 {
105  public:
107  static const bool IsNormalized = true;
108 };
109 
110 }; // namespace kernel
111 }; // namespace mlpack
112 
113 #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:23
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.
static const bool IsNormalized
If true, then the kernel is normalized: K(x, x) = K(y, y) = 1 for all x.