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

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Dec 16 17:24:24 EST 2011


Author: vlad321
Date: 2011-12-16 17:24:24 -0500 (Fri, 16 Dec 2011)
New Revision: 10870

Modified:
   mlpack/trunk/src/mlpack/core/math/clamp.hpp
   mlpack/trunk/src/mlpack/core/math/lin_alg.hpp
   mlpack/trunk/src/mlpack/core/math/random.hpp
Log:
Formatted /math



Modified: mlpack/trunk/src/mlpack/core/math/clamp.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/math/clamp.hpp	2011-12-16 22:16:01 UTC (rev 10869)
+++ mlpack/trunk/src/mlpack/core/math/clamp.hpp	2011-12-16 22:24:24 UTC (rev 10870)
@@ -41,16 +41,16 @@
  * Clamp a number between a particular range.
  *
  * @param value The number to clamp.
- * @param range_min The first of the range.
- * @param range_max The last of the range.
- * @return max(range_min, min(range_max, d)).
+ * @param rangeMin The first of the range.
+ * @param rangeMax The last of the range.
+ * @return max(rangeMin, min(rangeMax, d)).
  */
-inline double ClampRange(double value, double range_min, double range_max)
+inline double ClampRange(double value, double rangeMin, double rangeMax)
 {
-  value -= range_max;
-  value = ClampNonPositive (value) + range_max;
-  value -= range_min;
-  value = ClampNonNegative (value) + range_min;
+  value -= rangeMax;
+  value = ClampNonPositive (value) + rangeMax;
+  value -= rangeMin;
+  value = ClampNonNegative (value) + rangeMin;
   return value;
 }
 

Modified: mlpack/trunk/src/mlpack/core/math/lin_alg.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/math/lin_alg.hpp	2011-12-16 22:16:01 UTC (rev 10869)
+++ mlpack/trunk/src/mlpack/core/math/lin_alg.hpp	2011-12-16 22:24:24 UTC (rev 10870)
@@ -47,18 +47,18 @@
  * Creates a centered matrix, where centering is done by subtracting
  * the sum over the columns (a column vector) from each column of the matrix.
  *
- * @param X Input matrix
- * @param X_centered Matrix to write centered output into
+ * @param x Input matrix
+ * @param xCentered Matrix to write centered output into
  */
-void Center(const arma::mat& X, arma::mat& X_centered)
+void Center(const arma::mat& x, arma::mat& xCentered)
 {
   // Sum matrix along dimension 0 (that is, sum elements in each row).
-  arma::vec row_vector_sum = arma::sum(X, 1);
-  row_vector_sum /= X.n_cols; // scale
+  arma::vec rowVectorSum = arma::sum(x, 1);
+  rowVectorSum /= x.n_cols; // scale
 
-  X_centered.set_size(X.n_rows, X.n_cols);
-  for (size_t i = 0; i < X.n_rows; i++)
-    X_centered.row(i) = X.row(i) - row_vector_sum(i);
+  xCentered.set_size(x.n_rows, x.n_cols);
+  for (size_t i = 0; i < x.n_rows; i++)
+    xCentered.row(i) = x.row(i) - rowVectorSum(i);
 }
 
 /**
@@ -66,24 +66,24 @@
  * matrix. Whitening means the covariance matrix of the result is
  * the identity matrix
  */
-void WhitenUsingSVD(const arma::mat& X,
-                    arma::mat& X_whitened,
-                    arma::mat& whitening_matrix)
+void WhitenUsingSVD(const arma::mat& x,
+                    arma::mat& xWhitened,
+                    arma::mat& whiteningMatrix)
 {
-  arma::mat cov_X, U, V, inv_S_matrix, temp1;
-  arma::vec S_vector;
+  arma::mat covX, u, v, invSMatrix, temp1;
+  arma::vec sVector;
 
-  cov_X = ccov(X);
+  covX = ccov(x);
 
-  svd(U, S_vector, V, cov_X);
+  svd(u, sVector, v, covX);
 
-  size_t d = S_vector.n_elem;
-  inv_S_matrix.zeros(d, d);
-  inv_S_matrix.diag() = 1 / sqrt(S_vector);
+  size_t d = sVector.n_elem;
+  invSMatrix.zeros(d, d);
+  invSMatrix.diag() = 1 / sqrt(sVector);
 
-  whitening_matrix = V * inv_S_matrix * trans(U);
+  whiteningMatrix = v * invSMatrix * trans(u);
 
-  X_whitened = whitening_matrix * X;
+  xWhitened = whiteningMatrix * x;
 }
 
 /**
@@ -91,15 +91,15 @@
  * matrix. Whitening means the covariance matrix of the result is
  * the identity matrix
  */
-void WhitenUsingEig(const arma::mat& X,
-                    arma::mat& X_whitened,
-                    arma::mat& whitening_matrix)
+void WhitenUsingEig(const arma::mat& x,
+                    arma::mat& xWhitened,
+                    arma::mat& whiteningMatrix)
 {
   arma::mat diag, eigenvectors;
   arma::vec eigenvalues;
 
   // Get eigenvectors of covariance of input matrix.
-  eig_sym(eigenvalues, eigenvectors, ccov(X));
+  eig_sym(eigenvalues, eigenvectors, ccov(x));
 
   // Generate diagonal matrix using 1 / sqrt(eigenvalues) for each value.
   VectorPower(eigenvalues, -0.5);
@@ -107,10 +107,10 @@
   diag.diag() = eigenvalues;
 
   // Our whitening matrix is diag(1 / sqrt(eigenvectors)) * eigenvalues.
-  whitening_matrix = diag * trans(eigenvectors);
+  whiteningMatrix = diag * trans(eigenvectors);
 
   // Now apply the whitening matrix.
-  X_whitened = whitening_matrix * X;
+  xWhitened = whiteningMatrix * x;
 }
 
 /**
@@ -139,16 +139,16 @@
 }
 
 /**
- * Orthogonalize X and return the result in W, using eigendecomposition.
- * We will be using the formula \f$ W = X (X^T X)^{-0.5} \f$.
+ * Orthogonalize x and return the result in W, using eigendecomposition.
+ * We will be using the formula \f$ W = x (x^T x)^{-0.5} \f$.
  */
-void Orthogonalize(const arma::mat& X, arma::mat& W)
+void Orthogonalize(const arma::mat& x, arma::mat& W)
 {
   // For a matrix A, A^N = V * D^N * V', where VDV' is the
   // eigendecomposition of the matrix A.
   arma::mat eigenvalues, eigenvectors;
   arma::vec egval;
-  eig_sym(egval, eigenvectors, ccov(X));
+  eig_sym(egval, eigenvectors, ccov(x));
   VectorPower(egval, -0.5);
 
   eigenvalues.zeros(egval.n_elem, egval.n_elem);
@@ -156,16 +156,16 @@
 
   arma::mat at = (eigenvectors * eigenvalues * trans(eigenvectors));
 
-  W = at * X;
+  W = at * x;
 }
 
 /**
- * Orthogonalize X in-place.  This could be sped up by a custom
+ * Orthogonalize x in-place.  This could be sped up by a custom
  * implementation.
  */
-void Orthogonalize(arma::mat& X)
+void Orthogonalize(arma::mat& x)
 {
-  Orthogonalize(X, X);
+  Orthogonalize(x, x);
 }
 
 }; // namespace math

Modified: mlpack/trunk/src/mlpack/core/math/random.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/math/random.hpp	2011-12-16 22:16:01 UTC (rev 10869)
+++ mlpack/trunk/src/mlpack/core/math/random.hpp	2011-12-16 22:24:24 UTC (rev 10870)
@@ -55,12 +55,12 @@
 /**
  * Generates a uniform random integer.
  */
-inline int RandInt(int hi_exclusive)
+inline int RandInt(int hiExclusive)
 {
   #if BOOST_VERSION >= 104700
-    boost::random::uniform_int_distribution dist(0, hi_exclusive - 1);
+    boost::random::uniform_int_distribution dist(0, hiExclusive - 1);
   #else
-    boost::uniform_int<> dist(0, hi_exclusive - 1);
+    boost::uniform_int<> dist(0, hiExclusive - 1);
   #endif
 
   return dist(randGen);
@@ -69,12 +69,12 @@
 /**
  * Generates a uniform random integer.
  */
-inline int RandInt(int lo, int hi_exclusive)
+inline int RandInt(int lo, int hiExclusive)
 {
   #if BOOST_VERSION >= 104700
-    boost::random::uniform_int_distribution dist(lo, hi_exclusive - 1);
+    boost::random::uniform_int_distribution dist(lo, hiExclusive - 1);
   #else
-    boost::uniform_int<> dist(0, hi_exclusive - 1);
+    boost::uniform_int<> dist(0, hiExclusive - 1);
   #endif
 
   return dist(randGen);




More information about the mlpack-svn mailing list