From 5f8ba6e99b8d718c8c04b20fb084dbd14cecc826 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Sun, 24 Nov 2024 09:05:01 -0600 Subject: [PATCH] Armadillo 14.2.1 bug fix release --- ChangeLog | 4 +++ inst/include/armadillo_bits/Base_bones.hpp | 4 +-- inst/include/armadillo_bits/Cube_bones.hpp | 4 +-- inst/include/armadillo_bits/Mat_bones.hpp | 4 +-- inst/include/armadillo_bits/SpBase_bones.hpp | 4 +-- inst/include/armadillo_bits/arma_version.hpp | 2 +- inst/include/armadillo_bits/op_max_meat.hpp | 35 +++++++++----------- inst/include/armadillo_bits/op_min_meat.hpp | 35 +++++++++----------- 8 files changed, 43 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index 843bf124..449f3993 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2024-11-24 Dirk Eddelbuettel + + * inst/include/armadillo_bits/: Armadillo 14.2.1 bug fixes + 2024-11-16 Dirk Eddelbuettel * DESCRIPTION (Version, Date): RcppArmadillo 14.2.0-1 diff --git a/inst/include/armadillo_bits/Base_bones.hpp b/inst/include/armadillo_bits/Base_bones.hpp index 9c7e9ca5..8f1625ba 100644 --- a/inst/include/armadillo_bits/Base_bones.hpp +++ b/inst/include/armadillo_bits/Base_bones.hpp @@ -130,8 +130,8 @@ struct Base arma_frown("use .index_min() instead") inline elem_type min(uword& index_of_min_val) const; arma_frown("use .index_max() instead") inline elem_type max(uword& index_of_max_val) const; - arma_deprecated inline elem_type min(uword& row_of_min_val, uword& col_of_min_val) const; - arma_deprecated inline elem_type max(uword& row_of_max_val, uword& col_of_max_val) const; + arma_frown("use .index_min() with ind2sub() instead") inline elem_type min(uword& row_of_min_val, uword& col_of_min_val) const; + arma_frown("use .index_max() with ind2sub() instead") inline elem_type max(uword& row_of_max_val, uword& col_of_max_val) const; arma_warn_unused inline uword index_min() const; arma_warn_unused inline uword index_max() const; diff --git a/inst/include/armadillo_bits/Cube_bones.hpp b/inst/include/armadillo_bits/Cube_bones.hpp index 6227ce9c..ec452d33 100644 --- a/inst/include/armadillo_bits/Cube_bones.hpp +++ b/inst/include/armadillo_bits/Cube_bones.hpp @@ -390,8 +390,8 @@ class Cube : public BaseCube< eT, Cube > arma_frown("use .index_min() instead") inline eT min(uword& index_of_min_val) const; arma_frown("use .index_max() instead") inline eT max(uword& index_of_max_val) const; - arma_deprecated inline eT min(uword& row_of_min_val, uword& col_of_min_val, uword& slice_of_min_val) const; - arma_deprecated inline eT max(uword& row_of_max_val, uword& col_of_max_val, uword& slice_of_max_val) const; + arma_frown("use .index_min() with ind2sub() instead") inline eT min(uword& row_of_min_val, uword& col_of_min_val, uword& slice_of_min_val) const; + arma_frown("use .index_max() with ind2sub() instead") inline eT max(uword& row_of_max_val, uword& col_of_max_val, uword& slice_of_max_val) const; arma_cold inline bool save(const std::string name, const file_type type = arma_binary) const; arma_cold inline bool save(const hdf5_name& spec, const file_type type = hdf5_binary) const; diff --git a/inst/include/armadillo_bits/Mat_bones.hpp b/inst/include/armadillo_bits/Mat_bones.hpp index 69d92cf8..7ee55447 100644 --- a/inst/include/armadillo_bits/Mat_bones.hpp +++ b/inst/include/armadillo_bits/Mat_bones.hpp @@ -544,8 +544,8 @@ class Mat : public Base< eT, Mat > arma_frown("use .index_min() instead") inline eT min(uword& index_of_min_val) const; arma_frown("use .index_max() instead") inline eT max(uword& index_of_max_val) const; - arma_deprecated inline eT min(uword& row_of_min_val, uword& col_of_min_val) const; - arma_deprecated inline eT max(uword& row_of_max_val, uword& col_of_max_val) const; + arma_frown("use .index_min() with ind2sub() instead") inline eT min(uword& row_of_min_val, uword& col_of_min_val) const; + arma_frown("use .index_max() with ind2sub() instead") inline eT max(uword& row_of_max_val, uword& col_of_max_val) const; arma_cold inline bool save(const std::string name, const file_type type = arma_binary) const; diff --git a/inst/include/armadillo_bits/SpBase_bones.hpp b/inst/include/armadillo_bits/SpBase_bones.hpp index 74ff3b46..c3e59465 100644 --- a/inst/include/armadillo_bits/SpBase_bones.hpp +++ b/inst/include/armadillo_bits/SpBase_bones.hpp @@ -79,8 +79,8 @@ struct SpBase arma_frown("use .index_min() instead") inline elem_type min(uword& index_of_min_val) const; arma_frown("use .index_max() instead") inline elem_type max(uword& index_of_max_val) const; - arma_deprecated inline elem_type min(uword& row_of_min_val, uword& col_of_min_val) const; - arma_deprecated inline elem_type max(uword& row_of_max_val, uword& col_of_max_val) const; + arma_frown("use .index_min() with ind2sub() instead") inline elem_type min(uword& row_of_min_val, uword& col_of_min_val) const; + arma_frown("use .index_max() with ind2sub() instead") inline elem_type max(uword& row_of_max_val, uword& col_of_max_val) const; arma_warn_unused inline uword index_min() const; arma_warn_unused inline uword index_max() const; diff --git a/inst/include/armadillo_bits/arma_version.hpp b/inst/include/armadillo_bits/arma_version.hpp index d47f0c8c..875a7944 100644 --- a/inst/include/armadillo_bits/arma_version.hpp +++ b/inst/include/armadillo_bits/arma_version.hpp @@ -23,7 +23,7 @@ #define ARMA_VERSION_MAJOR 14 #define ARMA_VERSION_MINOR 2 -#define ARMA_VERSION_PATCH 0 +#define ARMA_VERSION_PATCH 1 #define ARMA_VERSION_NAME "Smooth Caffeine" diff --git a/inst/include/armadillo_bits/op_max_meat.hpp b/inst/include/armadillo_bits/op_max_meat.hpp index 5e2b39a4..185ce7f7 100644 --- a/inst/include/armadillo_bits/op_max_meat.hpp +++ b/inst/include/armadillo_bits/op_max_meat.hpp @@ -393,32 +393,19 @@ op_max::direct_max(const eT* const X, const uword n_elem, uword& index_of_max_va { arma_debug_sigprint(); - eT max_val_i = priv::most_neg(); - eT max_val_j = priv::most_neg(); - - uword best_index_i = 0; - uword best_index_j = 0; - - uword i,j; - for(i=0, j=1; j max_val_i) { max_val_i = X_i; best_index_i = i; } - if(X_j > max_val_j) { max_val_j = X_j; best_index_j = j; } - } + eT best_val = priv::most_neg(); + uword best_index = 0; - if(i < n_elem) + for(uword i=0; i < n_elem; ++i) { - const eT X_i = X[i]; + const eT val = X[i]; - if(X_i > max_val_i) { max_val_i = X_i; best_index_i = i; } + if(val > best_val) { best_val = val; best_index = i; } } - index_of_max_val = (max_val_i > max_val_j) ? best_index_i : best_index_j; + index_of_max_val = best_index; - return (max_val_i > max_val_j) ? max_val_i : max_val_j; + return best_val; } @@ -705,6 +692,8 @@ op_max::max_with_index(const Proxy& P, uword& index_of_max_val) { arma_conform_check(true, "max(): object has no elements"); + index_of_max_val = 0; + return Datum::nan; } @@ -786,6 +775,8 @@ op_max::max_with_index(const ProxyCube& P, uword& index_of_max_val) { arma_conform_check(true, "max(): object has no elements"); + index_of_max_val = 0; + return Datum::nan; } @@ -1160,6 +1151,8 @@ op_max::max_with_index(const Proxy& P, uword& index_of_max_val) { arma_conform_check(true, "max(): object has no elements"); + index_of_max_val = 0; + return Datum::nan; } @@ -1263,6 +1256,8 @@ op_max::max_with_index(const ProxyCube& P, uword& index_of_max_val) { arma_conform_check(true, "max(): object has no elements"); + index_of_max_val = 0; + return Datum::nan; } diff --git a/inst/include/armadillo_bits/op_min_meat.hpp b/inst/include/armadillo_bits/op_min_meat.hpp index 8fa6e74f..07a4337f 100644 --- a/inst/include/armadillo_bits/op_min_meat.hpp +++ b/inst/include/armadillo_bits/op_min_meat.hpp @@ -393,32 +393,19 @@ op_min::direct_min(const eT* const X, const uword n_elem, uword& index_of_min_va { arma_debug_sigprint(); - eT min_val_i = priv::most_pos(); - eT min_val_j = priv::most_pos(); - - uword best_index_i = 0; - uword best_index_j = 0; - - uword i,j; - for(i=0, j=1; j(); + uword best_index = 0; - if(i < n_elem) + for(uword i=0; i < n_elem; ++i) { - const eT X_i = X[i]; + const eT val = X[i]; - if(X_i < min_val_i) { min_val_i = X_i; best_index_i = i; } + if(val < best_val) { best_val = val; best_index = i; } } - index_of_min_val = (min_val_i < min_val_j) ? best_index_i : best_index_j; + index_of_min_val = best_index; - return (min_val_i < min_val_j) ? min_val_i : min_val_j; + return best_val; } @@ -705,6 +692,8 @@ op_min::min_with_index(const Proxy& P, uword& index_of_min_val) { arma_conform_check(true, "min(): object has no elements"); + index_of_min_val = 0; + return Datum::nan; } @@ -786,6 +775,8 @@ op_min::min_with_index(const ProxyCube& P, uword& index_of_min_val) { arma_conform_check(true, "min(): object has no elements"); + index_of_min_val = 0; + return Datum::nan; } @@ -1160,6 +1151,8 @@ op_min::min_with_index(const Proxy& P, uword& index_of_min_val) { arma_conform_check(true, "min(): object has no elements"); + index_of_min_val = 0; + return Datum::nan; } @@ -1263,6 +1256,8 @@ op_min::min_with_index(const ProxyCube& P, uword& index_of_min_val) { arma_conform_check(true, "min(): object has no elements"); + index_of_min_val = 0; + return Datum::nan; }