This commit is contained in:
conrad
2024-11-23 16:40:29 +10:00
parent b7cf2fd503
commit cdedada64a
2 changed files with 109 additions and 0 deletions
+9
View File
@@ -533,12 +533,21 @@ class Mat : public Base< eT, Mat<eT> >
arma_cold inline void reset();
arma_cold inline void soft_reset();
template<typename T1> inline void set_real(const Base<pod_type,T1>& X);
template<typename T1> inline void set_imag(const Base<pod_type,T1>& 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;
+100
View File
@@ -7759,6 +7759,106 @@ Mat<eT>::max() const
template<typename eT>
inline
eT
Mat<eT>::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<eT>::nan;
}
return op_min::direct_min(memptr(), n_elem, index_of_min_val);
}
template<typename eT>
inline
eT
Mat<eT>::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<eT>::nan;
}
return op_max::direct_max(memptr(), n_elem, index_of_max_val);
}
template<typename eT>
inline
eT
Mat<eT>::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<eT>::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<typename eT>
inline
eT
Mat<eT>::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<eT>::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<typename eT>
inline