From e3cd540e36043f1fd7eefef31e2ca4cfa8b35879 Mon Sep 17 00:00:00 2001 From: conrad Date: Fri, 13 Nov 2020 16:55:04 +1000 Subject: [PATCH] expand Base with sum() --- include/armadillo_bits/Base_bones.hpp | 2 ++ include/armadillo_bits/Base_meat.hpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/armadillo_bits/Base_bones.hpp b/include/armadillo_bits/Base_bones.hpp index 8ef250fa..eb64cfa6 100644 --- a/include/armadillo_bits/Base_bones.hpp +++ b/include/armadillo_bits/Base_bones.hpp @@ -119,6 +119,8 @@ struct Base arma_cold inline void raw_print( const std::string extra_text = "") const; arma_cold inline void raw_print(std::ostream& user_stream, const std::string extra_text = "") const; + inline arma_warn_unused elem_type sum() const; + inline arma_warn_unused elem_type min() const; inline arma_warn_unused elem_type max() const; diff --git a/include/armadillo_bits/Base_meat.hpp b/include/armadillo_bits/Base_meat.hpp index 0e319159..885ede9b 100644 --- a/include/armadillo_bits/Base_meat.hpp +++ b/include/armadillo_bits/Base_meat.hpp @@ -81,6 +81,17 @@ Base::raw_print(std::ostream& user_stream, const std::string +template +inline +arma_warn_unused +elem_type +Base::sum() const + { + return accu( (*this).get_ref() ); + } + + + template inline arma_warn_unused