[mlpack-git] master: Change trace(a * b) to accu(a % b). Apply this to test functions, too; speedup seems negligible but it's surely not a bad idea. (565a7b4)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Jan 15 11:40:45 EST 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/184c36dda87a9259c74d82265c2027896e097d42...1cf0e9bb2bd4d758e7b43220bf13e25de47a324c

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

commit 565a7b41b7234c522c2e784dad0921fa70ec5615
Author: ryan <ryan at ratml.org>
Date:   Thu Jan 15 11:35:53 2015 -0500

    Change trace(a * b) to accu(a % b).
    Apply this to test functions, too; speedup seems negligible but it's surely not a bad idea.


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

565a7b41b7234c522c2e784dad0921fa70ec5615
 .../core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp
index 6503ae1..8e71e49 100644
--- a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp
+++ b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp
@@ -219,7 +219,7 @@ void LovaszThetaSDP::Gradient(const arma::mat& coordinates,
     {
       // A_0 = I_n.  Hooray!  That's easy!  b_0 = 1.
       double inner = -1 * double(n) - 0.5 *
-          (trace(trans(coordinates) * coordinates) - 1);
+          (accu(trans(coordinates) % coordinates) - 1);
 
       arma::mat zz = (inner * arma::eye<arma::mat>(n, n));
 
@@ -241,7 +241,7 @@ void LovaszThetaSDP::Gradient(const arma::mat& coordinates,
       a(edge[1], edge[0]) = 1;
 
       double inner = (-1) - 0.5 *
-          (trace(a * (trans(coordinates) * coordinates)));
+          (accu(a % (trans(coordinates) * coordinates)));
 
       arma::mat zz = (inner * a);
 



More information about the mlpack-git mailing list