From f381fe8ae783d6fa7796cc807330abe83bcbbd25 Mon Sep 17 00:00:00 2001 From: HurricaneTong Date: Mon, 30 Mar 2015 15:38:20 +0800 Subject: [PATCH] use unsafe_col to speed up --- src/mlpack/methods/mean_shift/mean_shift.hpp | 33 +++----------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/src/mlpack/methods/mean_shift/mean_shift.hpp b/src/mlpack/methods/mean_shift/mean_shift.hpp index 9463cc3b0d..271632e1d9 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 std::enable_if::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 std::enable_if::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,24 +110,18 @@ 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" -#endif // __MLPACK_METHODS_MEAN_SHIFT_MEAN_SHIFT_HPP \ No newline at end of file +#endif // __MLPACK_METHODS_MEAN_SHIFT_MEAN_SHIFT_HPP