[mlpack-git] master: use unsafe_col to speed up (f381fe8)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Wed Apr 29 14:43:53 EDT 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/ee384655c4462e422e343e9725437fd772ca4449...182d4a629c1b23f683dff7b284844e4e3e9f5cc4
>---------------------------------------------------------------
commit f381fe8ae783d6fa7796cc807330abe83bcbbd25
Author: HurricaneTong <HurricaneTong at HurricaneTong.local>
Date: Mon Mar 30 15:38:20 2015 +0800
use unsafe_col to speed up
>---------------------------------------------------------------
f381fe8ae783d6fa7796cc807330abe83bcbbd25
src/mlpack/methods/mean_shift/mean_shift.hpp | 31 ++++------------------------
1 file changed, 4 insertions(+), 27 deletions(-)
diff --git a/src/mlpack/methods/mean_shift/mean_shift.hpp b/src/mlpack/methods/mean_shift/mean_shift.hpp
index 9463cc3..271632e 100644
--- a/src/mlpack/methods/mean_shift/mean_shift.hpp
+++ b/src/mlpack/methods/mean_shift/mean_shift.hpp
@@ -93,8 +93,7 @@ class MeanShift
private:
/**
- * If the kernel doesn't include a squared distance,
- * general way will be applied to calculate the weight of a data point.
+ * A general approach to calculate the weight for a point.
*
* @param centroid The centroid to calculate the weight
* @param point Calculate its weight
@@ -102,23 +101,7 @@ class MeanShift
* @return If true, the @point is near enough to the @centroid and @weight is valid,
* If false, the @point is far from the @centroid and @weight is invalid.
*/
- template <typename Kernel = KernelType>
- typename std::enable_if<!kernel::KernelTraits<Kernel>::UsesSquaredDistance, bool>::type
- CalcWeight(const arma::colvec& centroid, const arma::colvec& point, double& weight);
-
- /**
- * If the kernel includes a squared distance,
- * the weight of a data point can be calculated faster.
- *
- * @param centroid The centroid to calculate the weight
- * @param point Calculate its weight
- * @param weight Store the weight
- * @return If true, the @point is near enough to the @centroid and @weight is valid,
- * If false, the @point is far from the @centroid and @weight is invalid.
- */
- template <typename Kernel = KernelType>
- typename std::enable_if<kernel::KernelTraits<Kernel>::UsesSquaredDistance, bool>::type
- CalcWeight(const arma::colvec& centroid, const arma::colvec& point, double& weight);
+ bool CalcWeight(const arma::colvec& centroid, const arma::colvec& point, double& weight);
/**
* If distance of two centroids is less than radius, one will be removed.
@@ -127,22 +110,16 @@ class MeanShift
*/
double radius;
- // By storing radius * radius, we can speed up a little.
- double squaredRadius;
-
//! Maximum number of iterations before giving up.
size_t maxIterations;
//! Instantiated kernel.
KernelType kernel;
- metric::EuclideanDistance metric;
-
-
};
-}; // namespace meanshift
-}; // namespace mlpack
+} // namespace meanshift
+} // namespace mlpack
// Include implementation.
#include "mean_shift_impl.hpp"
More information about the mlpack-git
mailing list