MLPACK
1.0.7
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
79
private
:
81
double
bandwidth
;
82
};
83
85
template
<>
86
class
KernelTraits
<
TriangularKernel
>
87
{
88
public
:
90
static
const
bool
IsNormalized
=
true
;
91
};
92
93
};
// namespace kernel
94
};
// namespace mlpack
95
96
#endif
Generated by
1.8.3.1