[mlpack-svn] r15982 - mlpack/trunk/src/mlpack/methods/pca
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Oct 23 07:09:29 EDT 2013
Author: marcus
Date: Wed Oct 23 07:09:28 2013
New Revision: 15982
Log:
Check the matrix dimension before dropping unnecessary rows.
Modified:
mlpack/trunk/src/mlpack/methods/pca/pca.cpp
Modified: mlpack/trunk/src/mlpack/methods/pca/pca.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/pca/pca.cpp (original)
+++ mlpack/trunk/src/mlpack/methods/pca/pca.cpp Wed Oct 23 07:09:28 2013
@@ -120,8 +120,9 @@
Apply(data, data, eigVal, coeffs);
- // Drop unnecessary rows.
- data.shed_rows(newDimension, data.n_rows - 1);
+ if (newDimension < coeffs.n_rows)
+ // Drop unnecessary rows.
+ data.shed_rows(newDimension, data.n_rows - 1);
// Calculate the total amount of variance retained.
return (sum(eigVal.subvec(0, newDimension - 1)) / sum(eigVal));
More information about the mlpack-svn
mailing list