[mlpack-git] master: Some serialization changes. (676b003)

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


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

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

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

commit 676b0030cb3206f7df4db0a0167e03ff018f72df
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Apr 20 12:58:47 2015 +0000

    Some serialization changes.


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

676b0030cb3206f7df4db0a0167e03ff018f72df
 src/mlpack/core/tree/ballbound.hpp       |  1 -
 src/mlpack/core/tree/hrectbound.hpp      |  6 ++++++
 src/mlpack/core/tree/hrectbound_impl.hpp | 15 +++++++++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/mlpack/core/tree/ballbound.hpp b/src/mlpack/core/tree/ballbound.hpp
index 9ed2d33..28c74cf 100644
--- a/src/mlpack/core/tree/ballbound.hpp
+++ b/src/mlpack/core/tree/ballbound.hpp
@@ -4,7 +4,6 @@
  * Bounds that are useful for binary space partitioning trees.
  * Interface to a ball bound that works in arbitrary metric spaces.
  */
-
 #ifndef __MLPACK_CORE_TREE_BALLBOUND_HPP
 #define __MLPACK_CORE_TREE_BALLBOUND_HPP
 
diff --git a/src/mlpack/core/tree/hrectbound.hpp b/src/mlpack/core/tree/hrectbound.hpp
index 4d81338..7c0a3a0 100644
--- a/src/mlpack/core/tree/hrectbound.hpp
+++ b/src/mlpack/core/tree/hrectbound.hpp
@@ -163,6 +163,12 @@ class HRectBound
   double Diameter() const;
 
   /**
+   * Serialize the bound object.
+   */
+  template<typename Archive>
+  void Serialize(Archive& ar, const unsigned int version);
+
+  /**
    * Returns a string representation of this object.
    */
   std::string ToString() const;
diff --git a/src/mlpack/core/tree/hrectbound_impl.hpp b/src/mlpack/core/tree/hrectbound_impl.hpp
index 4158c86..ee199e2 100644
--- a/src/mlpack/core/tree/hrectbound_impl.hpp
+++ b/src/mlpack/core/tree/hrectbound_impl.hpp
@@ -420,6 +420,21 @@ inline double HRectBound<Power, TakeRoot>::Diameter() const
     return d;
 }
 
+//! Serialize the bound object.
+template<int Power, bool TakeRoot>
+template<typename Archive>
+void HRectBound<Power, TakeRoot>::Serialize(Archive& ar,
+                                            const unsigned int /* version */)
+{
+  ar & data::CreateNVP(dim, "dim");
+
+  // Allocate memory for the bounds, if necessary.
+  if (Archive::is_loading::value)
+    bounds = new math::Range[dim];
+
+  ar & data::CreateArrayNVP(bounds, "bounds");
+}
+
 /**
  * Returns a string representation of this object.
  */



More information about the mlpack-git mailing list