[mlpack-git] master: Properly consider ElemType parameter for bounds. (b55534d)

gitdub at mlpack.org gitdub at mlpack.org
Wed Aug 17 13:52:27 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/0f4b25acd6aaa14294c044874ba6cc0751712baa...0a19d07bd39e6223991976474bc79671ba8aa0f0

>---------------------------------------------------------------

commit b55534d084fb56f1f4390e36bece99a82ac3529f
Author: MarcosPividori <marcos.pividori at gmail.com>
Date:   Wed Aug 17 14:52:27 2016 -0300

    Properly consider ElemType parameter for bounds.


>---------------------------------------------------------------

b55534d084fb56f1f4390e36bece99a82ac3529f
 .../core/tree/space_split/projection_vector.hpp    | 23 +++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/mlpack/core/tree/space_split/projection_vector.hpp b/src/mlpack/core/tree/space_split/projection_vector.hpp
index 5ade0f9..39f2453 100644
--- a/src/mlpack/core/tree/space_split/projection_vector.hpp
+++ b/src/mlpack/core/tree/space_split/projection_vector.hpp
@@ -49,9 +49,9 @@ class AxisParallelProjVector
    * @param bound Bound to be projected.
    * @return Range of projected values.
    */
-  template<typename MetricType>
-  math::RangeType<double> Project(
-      const bound::HRectBound<MetricType>& bound) const
+  template<typename MetricType, typename ElemType>
+  math::RangeType<ElemType> Project(
+      const bound::HRectBound<MetricType, ElemType>& bound) const
   {
     return bound[dim];
   };
@@ -62,9 +62,9 @@ class AxisParallelProjVector
    * @param bound Bound to be projected.
    * @return Range of projected values.
    */
-  template<typename MetricType>
-  math::RangeType<double> Project(
-      const bound::BallBound<MetricType>& bound) const
+  template<typename MetricType, typename VecType>
+  math::RangeType<typename VecType::elem_type> Project(
+      const bound::BallBound<MetricType, VecType>& bound) const
   {
     return bound[dim];
   };
@@ -123,13 +123,14 @@ class ProjVector
    * @param bound Bound to be projected.
    * @return Range of projected values.
    */
-  template<typename MetricType>
-  math::RangeType<double> Project(
-      const bound::BallBound<MetricType>& bound) const
+  template<typename MetricType, typename VecType>
+  math::RangeType<typename VecType::elem_type> Project(
+      const bound::BallBound<MetricType, VecType>& bound) const
   {
+    typedef typename VecType::elem_type ElemType;
     const double center = Project(bound.Center());
-    const double radius = bound.Radius();
-    return math::Range(center - radius, center + radius);
+    const ElemType radius = bound.Radius();
+    return math::RangeType<ElemType>(center - radius, center + radius);
   };
 
   /**




More information about the mlpack-git mailing list