[mlpack-git] master, mlpack-1.0.x: Refactor to be stricter with types (arma::Col<size_t> instead of arma::vec). (c49d4ee)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:53:58 EST 2015


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

On branches: master,mlpack-1.0.x
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

commit c49d4ee04582d11d09d935c127a072d68acc7e9d
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Jul 21 14:58:53 2014 +0000

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


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

c49d4ee04582d11d09d935c127a072d68acc7e9d
 .../methods/nystroem_method/kmeans_selection.hpp     |  2 +-
 .../methods/nystroem_method/nystroem_method.hpp      |  2 +-
 .../methods/nystroem_method/nystroem_method_impl.hpp | 20 ++++++++++----------
 .../methods/nystroem_method/ordered_selection.hpp    |  6 +++---
 .../methods/nystroem_method/random_selection.hpp     |  4 ++--
 5 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/mlpack/methods/nystroem_method/kmeans_selection.hpp b/src/mlpack/methods/nystroem_method/kmeans_selection.hpp
index f931d74..ea6cbbc 100644
--- a/src/mlpack/methods/nystroem_method/kmeans_selection.hpp
+++ b/src/mlpack/methods/nystroem_method/kmeans_selection.hpp
@@ -20,7 +20,7 @@ class KMeansSelection
  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.
diff --git a/src/mlpack/methods/nystroem_method/nystroem_method.hpp b/src/mlpack/methods/nystroem_method/nystroem_method.hpp
index fc91d6e..0d01b36 100644
--- a/src/mlpack/methods/nystroem_method/nystroem_method.hpp
+++ b/src/mlpack/methods/nystroem_method/nystroem_method.hpp
@@ -59,7 +59,7 @@ class NystroemMethod
    * @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);
 
diff --git a/src/mlpack/methods/nystroem_method/nystroem_method_impl.hpp b/src/mlpack/methods/nystroem_method/nystroem_method_impl.hpp
index 231ecbf..e8d68f7 100644
--- a/src/mlpack/methods/nystroem_method/nystroem_method_impl.hpp
+++ b/src/mlpack/methods/nystroem_method/nystroem_method_impl.hpp
@@ -26,31 +26,31 @@ NystroemMethod<KernelType, PointSelectionPolicy>::NystroemMethod(
 
 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)
diff --git a/src/mlpack/methods/nystroem_method/ordered_selection.hpp b/src/mlpack/methods/nystroem_method/ordered_selection.hpp
index 154c04e..9e9e32e 100644
--- a/src/mlpack/methods/nystroem_method/ordered_selection.hpp
+++ b/src/mlpack/methods/nystroem_method/ordered_selection.hpp
@@ -24,11 +24,11 @@ class OrderedSelection
    * @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);
   }
 };
 
diff --git a/src/mlpack/methods/nystroem_method/random_selection.hpp b/src/mlpack/methods/nystroem_method/random_selection.hpp
index 83b09cc..39dfa12 100644
--- a/src/mlpack/methods/nystroem_method/random_selection.hpp
+++ b/src/mlpack/methods/nystroem_method/random_selection.hpp
@@ -24,9 +24,9 @@ class RandomSelection
    * @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-git mailing list