MLPACK
1.0.4
|
00001 /*** 00002 * @file mahalanobis_dstance.h 00003 * @author Ryan Curtin 00004 * 00005 * The Mahalanobis distance. 00006 * 00007 * This file is part of MLPACK 1.0.4. 00008 * 00009 * MLPACK is free software: you can redistribute it and/or modify it under the 00010 * terms of the GNU Lesser General Public License as published by the Free 00011 * Software Foundation, either version 3 of the License, or (at your option) any 00012 * later version. 00013 * 00014 * MLPACK is distributed in the hope that it will be useful, but WITHOUT ANY 00015 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00016 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00017 * details (LICENSE.txt). 00018 * 00019 * You should have received a copy of the GNU General Public License along with 00020 * MLPACK. If not, see <http://www.gnu.org/licenses/>. 00021 */ 00022 #ifndef __MLPACK_CORE_METRICS_MAHALANOBIS_DISTANCE_HPP 00023 #define __MLPACK_CORE_METRICS_MAHALANOBIS_DISTANCE_HPP 00024 00025 #include <mlpack/core.hpp> 00026 00027 namespace mlpack { 00028 namespace metric { 00029 00060 template<bool t_take_root = false> 00061 class MahalanobisDistance 00062 { 00063 public: 00068 MahalanobisDistance() { } 00069 00076 MahalanobisDistance(const size_t dimensionality) : 00077 covariance(arma::eye<arma::mat>(dimensionality, dimensionality)) { } 00078 00085 MahalanobisDistance(const arma::mat& covariance) : covariance(covariance) { } 00086 00096 template<typename VecType1, typename VecType2> 00097 double Evaluate(const VecType1& a, const VecType2& b); 00098 00104 const arma::mat& Covariance() const { return covariance; } 00105 00111 arma::mat& Covariance() { return covariance; } 00112 00113 private: 00115 arma::mat covariance; 00116 }; 00117 00118 }; // namespace distance 00119 }; // namespace mlpack 00120 00121 #include "mahalanobis_distance_impl.hpp" 00122 00123 #endif