[mlpack-svn] r14029 - mlpack/trunk/src/mlpack/core/math

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Dec 20 17:38:57 EST 2012


Author: trironk3
Date: 2012-12-20 17:38:57 -0500 (Thu, 20 Dec 2012)
New Revision: 14029

Modified:
   mlpack/trunk/src/mlpack/core/math/range.hpp
   mlpack/trunk/src/mlpack/core/math/range_impl.hpp
Log:
Implemented ToString methods for the math folder.

Modified: mlpack/trunk/src/mlpack/core/math/range.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/math/range.hpp	2012-12-20 22:38:12 UTC (rev 14028)
+++ mlpack/trunk/src/mlpack/core/math/range.hpp	2012-12-20 22:38:57 UTC (rev 14029)
@@ -156,6 +156,11 @@
    */
   inline bool Contains(const Range& r) const;
 
+  /**
+   * Returns a string representation of an object.
+   */
+  inline std::string ToString() const;
+
 };
 
 }; // namespace math

Modified: mlpack/trunk/src/mlpack/core/math/range_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/math/range_impl.hpp	2012-12-20 22:38:12 UTC (rev 14028)
+++ mlpack/trunk/src/mlpack/core/math/range_impl.hpp	2012-12-20 22:38:57 UTC (rev 14029)
@@ -8,6 +8,7 @@
 
 #include "range.hpp"
 #include <float.h>
+#include <sstream>
 
 namespace mlpack {
 namespace math {
@@ -172,6 +173,19 @@
 {
   return lo <= r.hi;
 }
+/**
+ * Returns a string representation of an object.
+ */
+std::string Range::ToString() const
+{
+  std::ostringstream convert;
+  convert << "Range [" << this << "]" << std::endl;
+  convert << "Low:  " << lo << std::endl;
+  convert << "High: " << hi;
+  
+  std::string result = convert.str();
+  return result;   
+}
 
 }; // namesapce math
 }; // namespace mlpack




More information about the mlpack-svn mailing list