[mlpack-svn] r16846 - mlpack/trunk/src/mlpack/methods/nystroem_method

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon Jul 21 10:58:53 EDT 2014


Author: rcurtin
Date: Mon Jul 21 10:58:53 2014
New Revision: 16846

Log:
Refactor to be stricter with types (arma::Col<size_t> instead of arma::vec).


Modified:
   mlpack/trunk/src/mlpack/methods/nystroem_method/kmeans_selection.hpp
   mlpack/trunk/src/mlpack/methods/nystroem_method/nystroem_method.hpp
   mlpack/trunk/src/mlpack/methods/nystroem_method/nystroem_method_impl.hpp
   mlpack/trunk/src/mlpack/methods/nystroem_method/ordered_selection.hpp
   mlpack/trunk/src/mlpack/methods/nystroem_method/random_selection.hpp

Modified: mlpack/trunk/src/mlpack/methods/nystroem_method/kmeans_selection.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/nystroem_method/kmeans_selection.hpp	(original)
+++ mlpack/trunk/src/mlpack/methods/nystroem_method/kmeans_selection.hpp	Mon Jul 21 10:58:53 2014
@@ -20,7 +20,7 @@
  public:
   /**
    * Use the K-Means clustering method to select the specified number of points
-   * in the dataset.
+   * in the dataset.  You are responsible for deleting the returned matrix!
    *
    * @param data Dataset to sample from.
    * @param m Number of points to select.

Modified: mlpack/trunk/src/mlpack/methods/nystroem_method/nystroem_method.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/nystroem_method/nystroem_method.hpp	(original)
+++ mlpack/trunk/src/mlpack/methods/nystroem_method/nystroem_method.hpp	Mon Jul 21 10:58:53 2014
@@ -59,7 +59,7 @@
    * @param miniKernel to store the constructed mini-kernel matrix in.
    * @param miniKernel to store the constructed semi-kernel matrix in.
    */
-  void GetKernelMatrix(const arma::vec& points, 
+  void GetKernelMatrix(const arma::Col<size_t>& selectedPoints, 
                        arma::mat& miniKernel, 
                        arma::mat& semiKernel);
 

Modified: mlpack/trunk/src/mlpack/methods/nystroem_method/nystroem_method_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/nystroem_method/nystroem_method_impl.hpp	(original)
+++ mlpack/trunk/src/mlpack/methods/nystroem_method/nystroem_method_impl.hpp	Mon Jul 21 10:58:53 2014
@@ -26,31 +26,31 @@
 
 template<typename KernelType, typename PointSelectionPolicy>
 void NystroemMethod<KernelType, PointSelectionPolicy>::GetKernelMatrix(
-                                       const arma::mat* seletedData, 
-                                       arma::mat& miniKernel, 
-                                       arma::mat& semiKernel)
+    const arma::mat* selectedData, 
+    arma::mat& miniKernel, 
+    arma::mat& semiKernel)
 {
   // Assemble mini-kernel matrix.
   for (size_t i = 0; i < rank; ++i)
     for (size_t j = 0; j < rank; ++j)
-      miniKernel(i, j) = kernel.Evaluate(seletedData->col(i),
-                                         seletedData->col(j));
+      miniKernel(i, j) = kernel.Evaluate(selectedData->col(i),
+                                         selectedData->col(j));
 
   // Construct semi-kernel matrix with interactions between selected data and
   // all points.
   for (size_t i = 0; i < data.n_cols; ++i)
     for (size_t j = 0; j < rank; ++j)
       semiKernel(i, j) = kernel.Evaluate(data.col(i), 
-                                         seletedData->col(j));
+                                         selectedData->col(j));
   // Clean the memory.
-  delete seletedData;
+  delete selectedData;
 }
 
 template<typename KernelType, typename PointSelectionPolicy>
 void NystroemMethod<KernelType, PointSelectionPolicy>::GetKernelMatrix(
-                                       const arma::vec& selectedPoints, 
-                                       arma::mat& miniKernel, 
-                                       arma::mat& semiKernel)
+    const arma::Col<size_t>& selectedPoints,
+    arma::mat& miniKernel,
+    arma::mat& semiKernel)
 {
   // Assemble mini-kernel matrix.
   for (size_t i = 0; i < rank; ++i)

Modified: mlpack/trunk/src/mlpack/methods/nystroem_method/ordered_selection.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/nystroem_method/ordered_selection.hpp	(original)
+++ mlpack/trunk/src/mlpack/methods/nystroem_method/ordered_selection.hpp	Mon Jul 21 10:58:53 2014
@@ -24,11 +24,11 @@
    * @param m Number of points to select.
    * @return Indices of selected points from the dataset.
    */
-  const static arma::vec Select(const arma::mat& /* unused */, const size_t m)
+  const static arma::Col<size_t> Select(const arma::mat& /* unused */,
+                                        const size_t m)
   {
     // This generates [0 1 2 3 ... (m - 1)].
-    arma::vec selectedPoints = arma::linspace<arma::vec>(0, m - 1, m);
-    return selectedPoints;
+    return arma::linspace<arma::Col<size_t> >(0, m - 1, m);
   }
 };
 

Modified: mlpack/trunk/src/mlpack/methods/nystroem_method/random_selection.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/nystroem_method/random_selection.hpp	(original)
+++ mlpack/trunk/src/mlpack/methods/nystroem_method/random_selection.hpp	Mon Jul 21 10:58:53 2014
@@ -24,9 +24,9 @@
    * @param m Number of points to select.
    * @return Indices of selected points from the dataset.
    */
-  const static arma::vec Select(const arma::mat& data, const size_t m)
+  const static arma::Col<size_t> Select(const arma::mat& data, const size_t m)
   {
-    arma::vec selectedPoints(m);
+    arma::Col<size_t> selectedPoints(m);
     for (size_t i = 0; i < m; ++i)
       selectedPoints(i) = math::RandInt(0, data.n_cols);
 



More information about the mlpack-svn mailing list