From dcb926d2f6ea13ddb1cac826f51fdedc70ed3698 Mon Sep 17 00:00:00 2001 From: Conrad Sanderson Date: Mon, 6 Apr 2020 10:53:12 +0200 Subject: [PATCH 1/2] corrections to handle vector types in Armadillo 9.870 This patch corrects handling of Armadillo vector types by `IsVector`. Without this patch, mlpack will not compile with Armadillo 9.870 (and development version 9.869). Armadillo 9.870 has extended handling of sparse submatrix views. In addition to `arma::SpSubview`, it now has `arma::SpSubview_col` and `arma::SpSubview_row`. The latter two types are vector types, so `IsVector` needs to be adjusted accordingly. --- src/mlpack/core/util/arma_traits.hpp | 35 +++++++++++++++++++++------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/mlpack/core/util/arma_traits.hpp b/src/mlpack/core/util/arma_traits.hpp index 45e5dac125..efa59c4fd2 100644 --- a/src/mlpack/core/util/arma_traits.hpp +++ b/src/mlpack/core/util/arma_traits.hpp @@ -81,14 +81,33 @@ struct IsVector > const static bool value = true; }; -// I'm not so sure about this one. An SpSubview object can be a row or column, -// but it can also be a matrix subview. -// template<> -template -struct IsVector > -{ - const static bool value = true; -}; +#if ( (ARMA_VERSION_MAJOR >= 10) || ((ARMA_VERSION_MAJOR == 9) && (ARMA_VERSION_MINOR >= 869)) ) + + // Armadillo 9.869+ has SpSubview_col and SpSubview_row + + template + struct IsVector > + { + const static bool value = true; + }; + + template + struct IsVector > + { + const static bool value = true; + }; + +#else + + // fallback for older Armadillo versions + + template + struct IsVector > + { + const static bool value = true; + }; + +#endif #endif From 77a0513d1df916c9e0f9bbcd91a998a039fcdaa5 Mon Sep 17 00:00:00 2001 From: Conrad Sanderson Date: Tue, 7 Apr 2020 02:56:12 +0200 Subject: [PATCH 2/2] layout changes Co-Authored-By: Ryan Curtin --- src/mlpack/core/util/arma_traits.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mlpack/core/util/arma_traits.hpp b/src/mlpack/core/util/arma_traits.hpp index efa59c4fd2..155a6a0d82 100644 --- a/src/mlpack/core/util/arma_traits.hpp +++ b/src/mlpack/core/util/arma_traits.hpp @@ -82,7 +82,8 @@ struct IsVector > }; -#if ( (ARMA_VERSION_MAJOR >= 10) || ((ARMA_VERSION_MAJOR == 9) && (ARMA_VERSION_MINOR >= 869)) ) +#if ((ARMA_VERSION_MAJOR >= 10) || \ + ((ARMA_VERSION_MAJOR == 9) && (ARMA_VERSION_MINOR >= 869))) // Armadillo 9.869+ has SpSubview_col and SpSubview_row