mlpack
3.1.1
src
mlpack
core
metrics
mahalanobis_distance.hpp
Go to the documentation of this file.
1
/***
2
* @file mahalanobis_distance.hpp
3
* @author Ryan Curtin
4
*
5
* The Mahalanobis distance.
6
*
7
* mlpack is free software; you may redistribute it and/or modify it under the
8
* terms of the 3-clause BSD license. You should have received a copy of the
9
* 3-clause BSD license along with mlpack. If not, see
10
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
11
*/
12
#ifndef MLPACK_CORE_METRICS_MAHALANOBIS_DISTANCE_HPP
13
#define MLPACK_CORE_METRICS_MAHALANOBIS_DISTANCE_HPP
14
15
#include <
mlpack/prereqs.hpp
>
16
17
namespace
mlpack
{
18
namespace
metric {
19
59
template
<
bool
TakeRoot = true>
60
class
MahalanobisDistance
61
{
62
public
:
67
MahalanobisDistance
() { }
68
75
MahalanobisDistance
(
const
size_t
dimensionality) :
76
covariance(arma::eye<arma::mat>(dimensionality, dimensionality)) { }
77
84
MahalanobisDistance
(arma::mat covariance) :
85
covariance(
std
::move(covariance)) { }
86
96
template
<
typename
VecTypeA,
typename
VecTypeB>
97
double
Evaluate
(
const
VecTypeA& a,
const
VecTypeB& b);
98
104
const
arma::mat&
Covariance
()
const
{
return
covariance; }
105
111
arma::mat&
Covariance
() {
return
covariance; }
112
114
template
<
typename
Archive>
115
void
serialize
(Archive& ar,
const
unsigned
int
version);
116
117
private
:
119
arma::mat covariance;
120
};
121
122
}
// namespace metric
123
}
// namespace mlpack
124
125
#include "mahalanobis_distance_impl.hpp"
126
127
#endif
prereqs.hpp
mlpack
@serialization.hpp
Definition:
add_to_po.hpp:21
mlpack::metric::MahalanobisDistance::serialize
void serialize(Archive &ar, const unsigned int version)
Serialize the Mahalanobis distance.
std
Definition:
prereqs.hpp:55
mlpack::metric::MahalanobisDistance::MahalanobisDistance
MahalanobisDistance()
Initialize the Mahalanobis distance with the empty matrix as covariance.
Definition:
mahalanobis_distance.hpp:97
mlpack::metric::MahalanobisDistance::Evaluate
double Evaluate(const VecTypeA &a, const VecTypeB &b)
Evaluate the distance between the two given points using this Mahalanobis distance.
mlpack::metric::MahalanobisDistance::Covariance
const arma::mat & Covariance() const
Access the covariance matrix.
Definition:
mahalanobis_distance.hpp:134
Generated by
1.8.17