[mlpack] 74/149: Be explicit with calls to arma:: functions. Although gcc accepts this as-is, we don't have a guarantee that all compilers will.

Barak A. Pearlmutter barak+git at pearlmutter.net
Sat May 2 09:11:11 UTC 2015


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch svn-trunk
in repository mlpack.

commit 01b105734f929fb0be47a4df4939ca1c14fbaaa1
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Wed Nov 5 19:52:12 2014 +0000

    Be explicit with calls to arma:: functions.  Although gcc accepts this as-is, we
    don't have a guarantee that all compilers will.
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@17302 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 .../methods/sparse_coding/sparse_coding_impl.hpp   | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/mlpack/methods/sparse_coding/sparse_coding_impl.hpp b/src/mlpack/methods/sparse_coding/sparse_coding_impl.hpp
index 3f212b4..7919c20 100644
--- a/src/mlpack/methods/sparse_coding/sparse_coding_impl.hpp
+++ b/src/mlpack/methods/sparse_coding/sparse_coding_impl.hpp
@@ -149,7 +149,7 @@ double SparseCoding<DictionaryInitializer>::OptimizeDictionary(
 
   for (size_t j = 0; j < atoms; ++j)
   {
-    if (accu(codes.row(j) != 0) == 0)
+    if (arma::accu(codes.row(j) != 0) == 0)
       inactiveAtoms.push_back(j);
   }
 
@@ -231,11 +231,11 @@ double SparseCoding<DictionaryInitializer>::OptimizeDictionary(
     while (true)
     {
       // Calculate objective.
-      double sumDualVars = sum(dualVars);
+      double sumDualVars = arma::sum(dualVars);
       double fOld = -(-trace(trans(codesXT) * matAInvZXT) - sumDualVars);
       double fNew = -(-trace(trans(codesXT) * solve(codesZT +
           diagmat(dualVars + alpha * searchDirection), codesXT)) -
-          (sumDualVars + alpha * sum(searchDirection)));
+          (sumDualVars + alpha * arma::sum(searchDirection)));
 
       if (fNew <= fOld + alpha * sufficientDecrease)
       {
@@ -249,7 +249,7 @@ double SparseCoding<DictionaryInitializer>::OptimizeDictionary(
 
     // Take step and print useful information.
     dualVars += searchDirection;
-    normGradient = norm(gradient, 2);
+    normGradient = arma::norm(gradient, 2);
     Log::Debug << "Newton Method iteration " << t << ":" << std::endl;
     Log::Debug << "  Gradient norm: " << std::scientific << normGradient
         << "." << std::endl;
@@ -280,7 +280,7 @@ double SparseCoding<DictionaryInitializer>::OptimizeDictionary(
                              data.col(math::RandInt(data.n_cols)) +
                              data.col(math::RandInt(data.n_cols)));
 
-        dictionary.col(i) /= norm(dictionary.col(i), 2);
+        dictionary.col(i) /= arma::norm(dictionary.col(i), 2);
 
         // Increment inactive index counter.
         ++currentInactiveIndex;
@@ -302,7 +302,7 @@ void SparseCoding<DictionaryInitializer>::ProjectDictionary()
 {
   for (size_t j = 0; j < atoms; j++)
   {
-    double atomNorm = norm(dictionary.col(j), 2);
+    double atomNorm = arma::norm(dictionary.col(j), 2);
     if (atomNorm > 1)
     {
       Log::Info << "Norm of atom " << j << " exceeds 1 (" << std::scientific
@@ -316,12 +316,12 @@ void SparseCoding<DictionaryInitializer>::ProjectDictionary()
 template<typename DictionaryInitializer>
 double SparseCoding<DictionaryInitializer>::Objective() const
 {
-  double l11NormZ = sum(sum(abs(codes)));
-  double froNormResidual = norm(data - (dictionary * codes), "fro");
+  double l11NormZ = arma::sum(arma::sum(arma::abs(codes)));
+  double froNormResidual = arma::norm(data - (dictionary * codes), "fro");
 
   if (lambda2 > 0)
   {
-    double froNormZ = norm(codes, "fro");
+    double froNormZ = arma::norm(codes, "fro");
     return 0.5 * (std::pow(froNormResidual, 2.0) + (lambda2 *
         std::pow(froNormZ, 2.0))) + (lambda1 * l11NormZ);
   }
@@ -338,9 +338,9 @@ std::string SparseCoding<DictionaryInitializer>::ToString() const
   convert << "Sparse Coding  [" << this << "]" << std::endl;
   convert << "  Data: " << data.n_rows << "x" ;
   convert <<  data.n_cols << std::endl;
-  convert << "  Atoms: " << atoms << std::endl; 
-  convert << "  Lambda 1: " << lambda1 << std::endl; 
-  convert << "  Lambda 2: " << lambda2 << std::endl; 
+  convert << "  Atoms: " << atoms << std::endl;
+  convert << "  Lambda 1: " << lambda1 << std::endl;
+  convert << "  Lambda 2: " << lambda2 << std::endl;
   return convert.str();
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git



More information about the debian-science-commits mailing list