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

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


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

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

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

commit eeae6f5b287a813cc2b3d068a8cf15244ab0d471
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().


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

eeae6f5b287a813cc2b3d068a8cf15244ab0d471
 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