[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. (f85b12d)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:12:31 EST 2015


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

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

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

commit f85b12d31d646305d17395806887a6c0888b22cd
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.


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

f85b12d31d646305d17395806887a6c0888b22cd
 .../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