From cdedada64adae2615ca8cb5d30c4ae6ce52c76ea Mon Sep 17 00:00:00 2001 From: conrad Date: Sat, 23 Nov 2024 16:40:29 +1000 Subject: [PATCH] revert --- include/armadillo_bits/Mat_bones.hpp | 9 +++ include/armadillo_bits/Mat_meat.hpp | 100 +++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) diff --git a/include/armadillo_bits/Mat_bones.hpp b/include/armadillo_bits/Mat_bones.hpp index fe5356f5..7ee55447 100644 --- a/include/armadillo_bits/Mat_bones.hpp +++ b/include/armadillo_bits/Mat_bones.hpp @@ -533,12 +533,21 @@ class Mat : public Base< eT, Mat > arma_cold inline void reset(); arma_cold inline void soft_reset(); + template inline void set_real(const Base& X); template inline void set_imag(const Base& X); + arma_warn_unused inline eT min() const; arma_warn_unused inline eT max() const; + 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_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; arma_cold inline bool save(const hdf5_name& spec, const file_type type = hdf5_binary) const; arma_cold inline bool save(const csv_name& spec, const file_type type = csv_ascii) const; diff --git a/include/armadillo_bits/Mat_meat.hpp b/include/armadillo_bits/Mat_meat.hpp index 365677ca..51524abd 100644 --- a/include/armadillo_bits/Mat_meat.hpp +++ b/include/armadillo_bits/Mat_meat.hpp @@ -7759,6 +7759,106 @@ Mat::max() const +template +inline +eT +Mat::min(uword& index_of_min_val) const + { + arma_debug_sigprint(); + + if(n_elem == 0) + { + arma_conform_check(true, "Mat::min(): object has no elements"); + + index_of_min_val = uword(0); + + return Datum::nan; + } + + return op_min::direct_min(memptr(), n_elem, index_of_min_val); + } + + + +template +inline +eT +Mat::max(uword& index_of_max_val) const + { + arma_debug_sigprint(); + + if(n_elem == 0) + { + arma_conform_check(true, "Mat::max(): object has no elements"); + + index_of_max_val = uword(0); + + return Datum::nan; + } + + return op_max::direct_max(memptr(), n_elem, index_of_max_val); + } + + + +template +inline +eT +Mat::min(uword& row_of_min_val, uword& col_of_min_val) const + { + arma_debug_sigprint(); + + if(n_elem == 0) + { + arma_conform_check(true, "Mat::min(): object has no elements"); + + row_of_min_val = uword(0); + col_of_min_val = uword(0); + + return Datum::nan; + } + + uword iq; + + eT val = op_min::direct_min(memptr(), n_elem, iq); + + row_of_min_val = iq % n_rows; + col_of_min_val = iq / n_rows; + + return val; + } + + + +template +inline +eT +Mat::max(uword& row_of_max_val, uword& col_of_max_val) const + { + arma_debug_sigprint(); + + if(n_elem == 0) + { + arma_conform_check(true, "Mat::max(): object has no elements"); + + row_of_max_val = uword(0); + col_of_max_val = uword(0); + + return Datum::nan; + } + + uword iq; + + eT val = op_max::direct_max(memptr(), n_elem, iq); + + row_of_max_val = iq % n_rows; + col_of_max_val = iq / n_rows; + + return val; + } + + + //! save the matrix to a file template inline