### Added some vector norm functions for L1 norm, and absolute mean,max,min(Thanks to Michal Nociar)

`git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@339 fdac6126-5c0c-442c-9429-916003d36597`
parent ea141230
 ... ... @@ -416,7 +416,6 @@ public: #undef expr #endif } //@} /** normalize vector, return normalized vector */ ... ... @@ -439,9 +438,36 @@ public: return *this; } //@} //------------------------------------------------------------ euclidean norm /// \name Non-Euclidean norm calculations //@{ /// compute L1 (Manhattan) norm inline Scalar l1_norm() const { #if DIM==N Scalar s(0); #define expr(i) s += abs(Base::values_[i]); unroll(expr); #undef expr return s; #else #define expr(i) abs(Base::values_[i]) return (unroll_comb(expr, +)); #undef expr #endif } //@} //------------------------------------------------------------ max, min, mean /// \name Minimum maximum and mean //@{ /// return the maximal component inline Scalar max() const { ... ... @@ -450,6 +476,17 @@ public: return m; } /// return the maximal absolute component inline Scalar max_abs() const { Scalar m(abs(Base::values_)); for(int i=1; im) m=abs(Base::values_[i]); return m; } /// return the minimal component inline Scalar min() const { ... ... @@ -458,6 +495,16 @@ public: return m; } /// return the minimal absolute component inline Scalar min_abs() const { Scalar m(abs(Base::values_)); for(int i=1; i Base::values_[i]) Base::values_[i] = _rhs[i]; ... ... @@ -481,6 +545,15 @@ public: return *this; } /// maximize values and signalize coordinate maximization inline bool maximized(const vector_type& _rhs) { bool result(false); #define expr(i) if (_rhs[i] > Base::values_[i]) { Base::values_[i] =_rhs[i]; result = true; } unroll(expr); #undef expr return result; } /// component-wise min inline vector_type min(const vector_type& _rhs) { return vector_type(*this).minimize(_rhs); ... ... @@ -491,8 +564,7 @@ public: return vector_type(*this).maximize(_rhs); } //@} //------------------------------------------------------------ misc functions ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!