// This is core/vnl/vnl_block.h #ifndef vnl_block_h_ #define vnl_block_h_ #ifdef VCL_NEEDS_PRAGMA_INTERFACE #pragma interface #endif //: // \file // \author fsm // // \verbatim // Modifications // 2009-03-30 Peter Vanroose - Added arg_min() & arg_max() and reimplemented min_value() & max_value() // \endverbatim // #include #include "vnl/vnl_export.h" VNL_EXPORT void vnl_block_raise_exception(char const *FILE, int LINE, char const *why); //: return sum of elements template inline T vnl_block_sum(T const x[], unsigned n) { if (n == 0) return T(0); else { T ans = x[0]; for (unsigned i=1; i inline T vnl_block_product(T const x[], unsigned n) { if (n == 0) return T(1); else { T ans = x[0]; for (unsigned i=1; i inline T vnl_block_min_value(T const *x, unsigned n) { if (n == 0) vnl_block_raise_exception(__FILE__, __LINE__, "n is 0"); T ans = *x; while (--n > 0) if (ans > *++x) ans = *x; return ans; } //: return largest value. template inline T vnl_block_max_value(T const *x, unsigned n) { if (n == 0) vnl_block_raise_exception(__FILE__, __LINE__, "n is 0"); T ans = *x; while (--n > 0) if (ans < *++x) ans = *x; return ans; } //: return index of smallest value. template inline unsigned vnl_block_arg_min(T const x[], unsigned n) { if (n == 0) vnl_block_raise_exception(__FILE__, __LINE__, "n is 0"); T tmp = *x; unsigned idx = 0; for (unsigned i=1; i *++x) tmp = *x, idx = i; return idx; } //: return index of largest value. template inline unsigned vnl_block_arg_max(T const x[], unsigned n) { if (n == 0) vnl_block_raise_exception(__FILE__, __LINE__, "n is 0"); T tmp = *x; unsigned idx = 0; for (unsigned i=1; i inline void vnl_block_copy(T const x[], T y[], unsigned n) { for (unsigned i=0; i inline void vnl_block_reverse(T x[], unsigned n) { T tmp; for (unsigned i=0; 2*i inline void vnl_block_scale(T a, T x[], unsigned n) { for (unsigned i=0; i inline void vnl_block_scale(T a, T const x[], T y[], unsigned n) { for (unsigned i=0; i inline void vnl_block_add(T const x[], T y[], unsigned n) { for (unsigned i=0; i inline void vnl_block_add(T const x[], T const y[], T z[], unsigned n) { for (unsigned i=0; i inline void vnl_block_sub(T const x[], T const y[], T z[], unsigned n) { for (unsigned i=0; i inline void vnl_block_mul(T const x[], T y[], unsigned n) { for (unsigned i=0; i inline void vnl_block_mul(T const x[], T const y[], T z[], unsigned n) { for (unsigned i=0; i inline void vnl_block_div(T const x[], T const y[], T z[], unsigned n) { for (unsigned i=0; i inline void vnl_block_negate(T const x[], T y[], unsigned n) { for (unsigned i=0; i inline void vnl_block_invert(T const x[], T y[], unsigned n) { for (unsigned i=0; i inline void vnl_block_axpy(T a, T const x[], T y[], unsigned n) { for (unsigned i=0; i inline void vnl_block_fill(T x[], unsigned n, T value) { for (unsigned i=0; i