mlpack: src/mlpack/core/kernels/laplacian_kernel.hpp Source File
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 
62  template<typename VecTypeA, typename VecTypeB>
63  double Evaluate(const VecTypeA& a, const VecTypeB& b) const
64  {
65  // The precalculation of gamma saves us a little computation time.
67  }
68 
77  double Evaluate(const double t) const
78  {
79  // The precalculation of gamma saves us a little computation time.
80  return exp(-t / bandwidth);
81  }
82 
92  double Gradient(const double t) const {
93  return exp(-t / bandwidth) / -bandwidth;
94  }
95 
97  double Bandwidth() const { return bandwidth; }
99  double& Bandwidth() { return bandwidth; }
100 
102  template<typename Archive>
103  void Serialize(Archive& ar, const unsigned int /* version */)
104  {
105  ar & data::CreateNVP(bandwidth, "bandwidth");
106  }
107 
108  private:
110  double bandwidth;
111 };
112 
114 template<>
116 {
117  public:
119  static const bool IsNormalized = true;
121  static const bool UsesSquaredDistance = false;
122 };
123 
124 } // namespace kernel
125 } // namespace mlpack
126 
127 #endif
This is a template class that can provide information about various kernels.
double Gradient(const double t) const
Evaluation of the gradient of the Laplacian kernel given the distance between two points...
Linear algebra utility functions, generally performed on matrices or vectors.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename boost::enable_if< HasSerialize< T >>::type *=0)
Call this function to produce a name-value pair; this is similar to BOOST_SERIALIZATION_NVP(), but should be used for types that have a Serialize() function (or contain a type that has a Serialize() function) instead of a serialize() function.
double Evaluate(const VecTypeA &a, const VecTypeB &b) const
Evaluation of the Laplacian kernel.
void Serialize(Archive &ar, const unsigned int)
Serialize the kernel.
static VecTypeA::elem_type Evaluate(const VecTypeA &a, const VecTypeB &b)
Computes the distance between two points.
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.
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
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.