diff --git a/ChangeLog b/ChangeLog index b6d08117..7137a57d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2024-11-05 Dirk Eddelbuettel +2024-11-07 Dirk Eddelbuettel * DESCRIPTION (Version, Date): RcppArmadillo 12.1.99-1 * inst/NEWS.Rd: Idem @@ -10,6 +10,10 @@ * inst/include/armadillo_bits/: Re-sync Armadillo 12.2.0-rc0 +2024-11-05 Dirk Eddelbuettel + + * inst/include/armadillo_bits/: Re-sync Armadillo 12.2.0-rc0 + 2024-11-03 Dirk Eddelbuettel * inst/include/armadillo_bits/: Armadillo 12.2.0-rc0 diff --git a/DESCRIPTION b/DESCRIPTION index ff051464..dfe1e281 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: RcppArmadillo Type: Package Title: 'Rcpp' Integration for the 'Armadillo' Templated Linear Algebra Library Version: 14.1.99-1 -Date: 2024-11-05 +Date: 2024-11-07 Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "edd@debian.org", comment = c(ORCID = "0000-0001-6419-907X")), person("Romain", "Francois", role = "aut", diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 8049cfc6..d4b6e5f3 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -3,7 +3,7 @@ \newcommand{\ghpr}{\href{https://github.com/RcppCore/RcppArmadillo/pull/#1}{##1}} \newcommand{\ghit}{\href{https://github.com/RcppCore/RcppArmadillo/issues/#1}{##1}} -\section{Changes in RcppArmadillo version 14.1.99-1 (2024-11-05)}{ +\section{Changes in RcppArmadillo version 14.1.99-1 (2024-11-07)}{ \itemize{ \item Upgraded to Armadillo release 14.2.0-rc0 (Stochastic Parrot) \itemize{ diff --git a/inst/include/armadillo_bits/auxlib_meat.hpp b/inst/include/armadillo_bits/auxlib_meat.hpp index 72bd2e75..a6a1f122 100644 --- a/inst/include/armadillo_bits/auxlib_meat.hpp +++ b/inst/include/armadillo_bits/auxlib_meat.hpp @@ -28,7 +28,7 @@ auxlib::inv(Mat& A) { arma_debug_sigprint(); - // NOTE: given a matrix with NaN values, getrf() and getri() do not necessarily fail, + // NOTE: given a matrix with NaN values, lapack::getrf() and lapack::getri() do not necessarily fail, // NOTE: and can produce matrices with NaN values. // NOTE: we're not checking for non-finite values to avoid breaking existing user code. diff --git a/inst/include/armadillo_bits/config.hpp b/inst/include/armadillo_bits/config.hpp index a8f6cf9d..46d755bc 100644 --- a/inst/include/armadillo_bits/config.hpp +++ b/inst/include/armadillo_bits/config.hpp @@ -95,9 +95,6 @@ #error "use ARMA_USE_FFTW3 instead of ARMA_USE_FFTW" #endif -// #define ARMA_BLAS_64BIT_INT -//// Uncomment the above line if your BLAS and LAPACK libraries use 64 bit integers - // #define ARMA_BLAS_CAPITALS //// Uncomment the above line if your BLAS and LAPACK libraries have capitalised function names @@ -105,6 +102,9 @@ //// Uncomment the above line if your BLAS and LAPACK libraries have function names with a trailing underscore. //// Conversely, comment it out if the function names don't have a trailing underscore. +// #define ARMA_BLAS_LONG_LONG +//// Uncomment the above line if your BLAS and LAPACK libraries use 64 bit integers, ie. "long long" instead of "int" + // #define ARMA_BLAS_NOEXCEPT //// Uncomment the above line if you require BLAS functions to have the 'noexcept' specification @@ -128,7 +128,7 @@ //// Uncomment the above line to use Intel MKL types for complex numbers. //// You will need to include appropriate MKL headers before the Armadillo header. //// You may also need to enable or disable the following options: -//// ARMA_BLAS_LONG, ARMA_BLAS_LONG_LONG, ARMA_USE_FORTRAN_HIDDEN_ARGS +//// ARMA_BLAS_LONG_LONG, ARMA_USE_FORTRAN_HIDDEN_ARGS #if !defined(ARMA_USE_OPENMP) // #define ARMA_USE_OPENMP diff --git a/inst/include/armadillo_bits/op_cond_meat.hpp b/inst/include/armadillo_bits/op_cond_meat.hpp index ad1bc765..be1ef078 100644 --- a/inst/include/armadillo_bits/op_cond_meat.hpp +++ b/inst/include/armadillo_bits/op_cond_meat.hpp @@ -37,7 +37,7 @@ op_cond::apply(const Base& X) if(is_op_diagmat::value || A.is_diagmat()) { - arma_debug_print("op_cond::apply(): detected diagonal matrix"); + arma_debug_print("op_cond::apply(): diag optimisation"); return op_cond::apply_diag(A); } diff --git a/inst/include/armadillo_bits/op_expmat_meat.hpp b/inst/include/armadillo_bits/op_expmat_meat.hpp index aff2deab..7278cabc 100644 --- a/inst/include/armadillo_bits/op_expmat_meat.hpp +++ b/inst/include/armadillo_bits/op_expmat_meat.hpp @@ -75,7 +75,7 @@ op_expmat::apply_direct(Mat& out, const Base& out, const Base::value || X.is_diagmat()) { - arma_debug_print("op_expmat_sym: detected diagonal matrix"); + arma_debug_print("op_expmat_sym: diag optimisation"); out = X; diff --git a/inst/include/armadillo_bits/op_inv_spd_meat.hpp b/inst/include/armadillo_bits/op_inv_spd_meat.hpp index a252e5dc..73ed5c79 100644 --- a/inst/include/armadillo_bits/op_inv_spd_meat.hpp +++ b/inst/include/armadillo_bits/op_inv_spd_meat.hpp @@ -191,7 +191,7 @@ op_inv_spd_full::apply_direct(Mat& out, const Base::value || out.is_diagmat()) { - arma_debug_print("op_inv_spd_full: detected diagonal matrix"); + arma_debug_print("op_inv_spd_full: diag optimisation"); eT* colmem = out.memptr(); @@ -300,7 +300,7 @@ op_inv_spd_rcond::apply_direct(Mat& out, op_inv_spd_stat if(is_op_diagmat::value || out.is_diagmat()) { - arma_debug_print("op_inv_spd_rcond: detected diagonal matrix"); + arma_debug_print("op_inv_spd_rcond: diag optimisation"); out_state.is_diag = true; diff --git a/inst/include/armadillo_bits/op_log_det_meat.hpp b/inst/include/armadillo_bits/op_log_det_meat.hpp index 5601597d..39ef514d 100644 --- a/inst/include/armadillo_bits/op_log_det_meat.hpp +++ b/inst/include/armadillo_bits/op_log_det_meat.hpp @@ -202,7 +202,7 @@ op_log_det_sympd::apply_direct(typename T1::pod_type& out_val, const Base::value || A.is_diagmat()) { - arma_debug_print("op_log_det_sympd: detected diagonal matrix"); + arma_debug_print("op_log_det_sympd: diag optimisation"); eT* colmem = A.memptr(); diff --git a/inst/include/armadillo_bits/op_logmat_meat.hpp b/inst/include/armadillo_bits/op_logmat_meat.hpp index 67136602..43cd9ac5 100644 --- a/inst/include/armadillo_bits/op_logmat_meat.hpp +++ b/inst/include/armadillo_bits/op_logmat_meat.hpp @@ -111,7 +111,7 @@ op_logmat::apply_direct(Mat< std::complex >& out, const if(A.is_diagmat()) { - arma_debug_print("op_logmat: detected diagonal matrix"); + arma_debug_print("op_logmat: diag optimisation"); const uword N = A.n_rows; @@ -292,7 +292,7 @@ op_logmat_cx::apply_direct(Mat& out, const Base& out, const Base::value || X.is_diagmat()) { - arma_debug_print("op_logmat_sympd: detected diagonal matrix"); + arma_debug_print("op_logmat_sympd: diag optimisation"); out = X; diff --git a/inst/include/armadillo_bits/op_pinv_meat.hpp b/inst/include/armadillo_bits/op_pinv_meat.hpp index 48f02edc..f88ca05b 100644 --- a/inst/include/armadillo_bits/op_pinv_meat.hpp +++ b/inst/include/armadillo_bits/op_pinv_meat.hpp @@ -106,7 +106,7 @@ op_pinv::apply_direct(Mat& out, const Base::value || A.is_diagmat()) { - arma_debug_print("op_pinv: detected diagonal matrix"); + arma_debug_print("op_pinv: diag optimisation"); return op_pinv::apply_diag(out, A, tol); } diff --git a/inst/include/armadillo_bits/op_powmat_meat.hpp b/inst/include/armadillo_bits/op_powmat_meat.hpp index bbd104cf..c95b6860 100644 --- a/inst/include/armadillo_bits/op_powmat_meat.hpp +++ b/inst/include/armadillo_bits/op_powmat_meat.hpp @@ -96,7 +96,7 @@ op_powmat::apply_direct_positive(Mat& out, const Mat& X, const uword y) if(X.is_diagmat()) { - arma_debug_print("op_powmat: detected diagonal matrix"); + arma_debug_print("op_powmat: diag optimisation"); podarray tmp(N); // use temporary array in case we have aliasing @@ -194,11 +194,11 @@ op_powmat_cx::apply_direct(Mat< std::complex >& out, cons if(A.is_diagmat()) { - arma_debug_print("op_powmat_cx: detected diagonal matrix"); + arma_debug_print("op_powmat_cx: diag optimisation"); podarray tmp(N); // use temporary array in case we have aliasing - for(uword i=0; i(A.at(i,i)), y) ; } + for(uword i=0; i(A.at(i,i)), y ); } out.zeros(N,N); @@ -207,11 +207,11 @@ op_powmat_cx::apply_direct(Mat< std::complex >& out, cons return true; } - const bool try_sympd = arma_config::optimise_sym && sym_helper::guess_sympd(A); + const bool try_sym = arma_config::optimise_sym && sym_helper::is_approx_sym(A); - if(try_sympd) + if(try_sym) { - arma_debug_print("op_powmat_cx: attempting sympd optimisation"); + arma_debug_print("op_powmat_cx: symmetric/hermitian optimisation"); Col eigval; Mat eigvec; @@ -220,16 +220,39 @@ op_powmat_cx::apply_direct(Mat< std::complex >& out, cons if(eig_status) { - eigval = pow(eigval, y); + bool all_pos = true; - const Mat tmp = diagmat(eigval) * eigvec.t(); + for(uword i=0; i >::from(eigvec * tmp); + if(all_pos) + { + arma_debug_print("op_powmat_cx: all_pos = true"); + + eigval = pow(eigval, y); + + const Mat tmp = eigvec * diagmat(eigval); + + out = conv_to< Mat >::from(tmp * eigvec.t()); + } + else + { + arma_debug_print("op_powmat_cx: all_pos = false"); + + Col cx_eigval_pow(N, arma_nozeros_indicator()); + + for(uword i=0; i(eigval[i]), y ); } + + const Mat cx_eigvec = conv_to< Mat >::from(eigvec); + + const Mat tmp = cx_eigvec * diagmat(cx_eigval_pow); + + out = tmp * cx_eigvec.t(); + } return true; } - arma_debug_print("op_powmat_cx: sympd optimisation failed"); + arma_debug_print("op_powmat_cx: symmetric/hermitian optimisation failed"); // fallthrough if optimisation failed } diff --git a/inst/include/armadillo_bits/op_rank_meat.hpp b/inst/include/armadillo_bits/op_rank_meat.hpp index 15511fc1..c7840e57 100644 --- a/inst/include/armadillo_bits/op_rank_meat.hpp +++ b/inst/include/armadillo_bits/op_rank_meat.hpp @@ -37,7 +37,7 @@ op_rank::apply(uword& out, const Base& expr, const ty if(is_op_diagmat::value || A.is_diagmat()) { - arma_debug_print("op_rank::apply(): detected diagonal matrix"); + arma_debug_print("op_rank::apply(): diag optimisation"); return op_rank::apply_diag(out, A, tol); } diff --git a/inst/include/armadillo_bits/op_sqrtmat_meat.hpp b/inst/include/armadillo_bits/op_sqrtmat_meat.hpp index 44017455..3c2f07d4 100644 --- a/inst/include/armadillo_bits/op_sqrtmat_meat.hpp +++ b/inst/include/armadillo_bits/op_sqrtmat_meat.hpp @@ -116,7 +116,7 @@ op_sqrtmat::apply_direct(Mat< std::complex >& out, const if(A.is_diagmat()) { - arma_debug_print("op_sqrtmat: detected diagonal matrix"); + arma_debug_print("op_sqrtmat: diag optimisation"); const uword N = A.n_rows; @@ -325,7 +325,7 @@ op_sqrtmat_cx::apply_direct(Mat& out, const Base& out, const Base::value || X.is_diagmat()) { - arma_debug_print("op_sqrtmat_sympd: detected diagonal matrix"); + arma_debug_print("op_sqrtmat_sympd: diag optimisation"); out = X;