[mlpack-git] master: Add BallBound<>::Serialize(). (a255049)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Fri Jul 10 18:59:39 EDT 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/4a97187bbba7ce8a6191b714949dd818ef0f37d2...e5905e62c15d1bcff21e6359b11efcd7ab6d7ca0

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

commit a25504914e0ac4089ff99abe3cd2d18712fb7a99
Author: Ryan Curtin <ryan at ratml.org>
Date:   Sat Apr 18 01:44:09 2015 +0000

    Add BallBound<>::Serialize().


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

a25504914e0ac4089ff99abe3cd2d18712fb7a99
 src/mlpack/core/tree/ballbound.hpp      |  4 ++++
 src/mlpack/core/tree/ballbound_impl.hpp | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/src/mlpack/core/tree/ballbound.hpp b/src/mlpack/core/tree/ballbound.hpp
index d1eae34..9ed2d33 100644
--- a/src/mlpack/core/tree/ballbound.hpp
+++ b/src/mlpack/core/tree/ballbound.hpp
@@ -177,6 +177,10 @@ class BallBound
   //! Modify the distance metric used in this bound.
   TMetricType& Metric() { return *metric; }
 
+  //! Serialize the bound.
+  template<typename Archive>
+  void Serialize(Archive& ar, const unsigned int version);
+
   /**
    * Returns a string representation of this object.
    */
diff --git a/src/mlpack/core/tree/ballbound_impl.hpp b/src/mlpack/core/tree/ballbound_impl.hpp
index 3f64908..8ada4a4 100644
--- a/src/mlpack/core/tree/ballbound_impl.hpp
+++ b/src/mlpack/core/tree/ballbound_impl.hpp
@@ -251,6 +251,24 @@ BallBound<VecType, TMetricType>::operator|=(const MatType& data)
   return *this;
 }
 
+//! Serialize the BallBound.
+template<typename VecType, typename TMetricType>
+void BallBound<VecType, TMetricType>::Serialize(
+    Archive& ar,
+    const unsigned int /* version */)
+{
+  ar & data::CreateNVP(radius, "radius");
+  ar & data::CreateNVP(center, "center");
+
+  if (Archive::is_loading::value)
+  {
+    metric = new TMetricType();
+    ownsMetric = true;
+  }
+
+  ar & data::CreateNVP(metric, "metric");
+}
+
 /**
  * Returns a string representation of this object.
  */



More information about the mlpack-git mailing list