[mlpack-git] master: Simplify a matrix calculation. (887dc99)

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


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

commit 887dc99db55e9ecc8d8a70c10364d6f40899bc1c
Author: Ryan Curtin <ryan at ratml.org>
Date:   Thu Aug 7 15:42:44 2014 +0000

    Simplify a matrix calculation.


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

887dc99db55e9ecc8d8a70c10364d6f40899bc1c
 src/mlpack/methods/adaboost/adaboost_impl.hpp | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/src/mlpack/methods/adaboost/adaboost_impl.hpp b/src/mlpack/methods/adaboost/adaboost_impl.hpp
index 0f0461f..d420880 100644
--- a/src/mlpack/methods/adaboost/adaboost_impl.hpp
+++ b/src/mlpack/methods/adaboost/adaboost_impl.hpp
@@ -108,15 +108,7 @@ Adaboost<MatType, WeakLearner>::Adaboost(
 
     // Now, start calculation of alpha(t) using ht
 
-    // begin calculation of rt
-
-    for (j = 0; j < ht.n_rows; j++)
-    {
-      for (k = 0; k < ht.n_cols; k++)
-        rt += (D(j, k) * yt(j, k) * ht(j, k));
-    }
-    // end calculation of rt
-    // std::cout<<"Value of rt is: "<<rt<<"\n";
+    rt += arma::accu(D % yt % ht);
 
     if (i > 0)
     {
@@ -180,9 +172,9 @@ void Adaboost<MatType, WeakLearner>::BuildClassificationMatrix(
 {
   int i, j;
 
-  for (i = 0;i < t.n_rows; i++)
+  for (i = 0; i < t.n_rows; i++)
   {
-    for (j = 0;j < t.n_cols; j++)
+    for (j = 0; j < t.n_cols; j++)
     {
       if (j == l(i))
         t(i, j) = 1.0;



More information about the mlpack-git mailing list