MLPACK
1.0.10
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
mlpack
core
kernels
triangular_kernel.hpp
Go to the documentation of this file.
1
22
#ifndef __MLPACK_CORE_KERNELS_TRIANGULAR_KERNEL_HPP
23
#define __MLPACK_CORE_KERNELS_TRIANGULAR_KERNEL_HPP
24
25
#include <
mlpack/core.hpp
>
26
#include <
mlpack/core/metrics/lmetric.hpp
>
27
28
namespace
mlpack {
29
namespace
kernel {
30
40
class
TriangularKernel
41
{
42
public
:
48
TriangularKernel
(
const
double
bandwidth
= 1.0) :
bandwidth
(
bandwidth
) { }
49
56
template
<
typename
Vec1Type,
typename
Vec2Type>
57
double
Evaluate
(
const
Vec1Type& a,
const
Vec2Type& b)
const
58
{
59
return
std::max(0.0, (1 -
metric::EuclideanDistance::Evaluate
(a, b) /
60
bandwidth
));
61
}
62
69
double
Evaluate
(
const
double
distance)
const
70
{
71
return
std::max(0.0, (1 - distance) /
bandwidth
);
72
}
73
75
double
Bandwidth
()
const
{
return
bandwidth
; }
77
double
&
Bandwidth
() {
return
bandwidth
; }
78
80
std::string
ToString
()
const
81
{
82
std::ostringstream convert;
83
convert <<
"TriangularKernel ["
<<
this
<<
"]"
<< std::endl;
84
convert <<
" Bandwidth: "
<<
bandwidth
<< std::endl;
85
return
convert.str();
86
}
87
88
private
:
90
double
bandwidth
;
91
};
92
94
template
<>
95
class
KernelTraits
<
TriangularKernel
>
96
{
97
public
:
99
static
const
bool
IsNormalized
=
true
;
100
};
101
102
};
// namespace kernel
103
};
// namespace mlpack
104
105
#endif
Generated by
1.8.3.1