add .clamp()

This commit is contained in:
conrad
2021-05-04 00:25:12 +10:00
parent 32b8702db6
commit eb8375c41e
2 changed files with 18 additions and 0 deletions
+2
View File
@@ -323,6 +323,8 @@ class Cube : public BaseCube< eT, Cube<eT> >
inline const Cube& clean(const pod_type threshold);
inline const Cube& clamp(const eT min_val, const eT max_val);
inline const Cube& fill(const eT val);
inline const Cube& zeros();
+16
View File
@@ -3942,6 +3942,22 @@ Cube<eT>::clean(const typename get_pod_type<eT>::result threshold)
template<typename eT>
inline
const Cube<eT>&
Cube<eT>::clamp(const eT min_val, const eT max_val)
{
arma_extra_debug_sigprint();
arma_debug_check( (min_val > max_val), "Cube::clamp(): min_val must be less than max_val" );
arrayops::clamp(memptr(), n_elem, min_val, max_val);
return *this;
}
//! fill the cube with the specified value
template<typename eT>
inline