[mlpack-git] master: Properly handle old Armadillo versions. Pre-4.500 doesn't have arguments to chol(). (9b55e5e)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Mon Jan 26 15:27:02 EST 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/71a9f87ab29175554507f1592e564063f0452743...9b55e5e4a300972d01cf1cf2802df8bf392a1fd1

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

commit 9b55e5e4a300972d01cf1cf2802df8bf392a1fd1
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Jan 26 15:25:10 2015 -0500

    Properly handle old Armadillo versions.
    Pre-4.500 doesn't have arguments to chol().


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

9b55e5e4a300972d01cf1cf2802df8bf392a1fd1
 src/mlpack/core/dists/gaussian_distribution.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/mlpack/core/dists/gaussian_distribution.cpp b/src/mlpack/core/dists/gaussian_distribution.cpp
index cc84b8b..2949f94 100644
--- a/src/mlpack/core/dists/gaussian_distribution.cpp
+++ b/src/mlpack/core/dists/gaussian_distribution.cpp
@@ -32,7 +32,13 @@ void GaussianDistribution::Covariance(arma::mat&& covariance)
 
 void GaussianDistribution::FactorCovariance()
 {
-  covLower = arma::chol(covariance, "lower");
+  // On Armadillo < 4.500, the "lower" option isn't available.
+  #if (ARMA_VERSION_MAJOR < 4) || \
+      ((ARMA_VERSION_MAJOR == 4) && (ARMA_VERSION_MINOR < 500))
+    covLower = arma::chol(covariance).t(); // This is less efficient.
+  #else
+    covLower = arma::chol(covariance, "lower");
+  #endif
 
   // Comment from rcurtin:
   //



More information about the mlpack-git mailing list