Mercurial > hg > octave-terminal
changeset 9814:2b29f3472e20
add a couple of useful loops
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 13 Nov 2009 12:00:53 +0100 |
parents | 8fa32b527d9a |
children | 29f4f8c9b3f1 |
files | liboctave/ChangeLog liboctave/mx-inlines.cc |
diffstat | 2 files changed, 25 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2009-11-13 Jaroslav Hajek <highegg@gmail.com> + + * mx-inlines.cc (mx_inline_any_nan): Rewrite. + (mx_inline_all_real): New reduction loop. + 2009-11-12 Jaroslav Hajek <highegg@gmail.com> * lo-mappers.cc ( rc_acos, rc_acos, rc_acosh, rc_acosh, rc_asin,
--- a/liboctave/mx-inlines.cc +++ b/liboctave/mx-inlines.cc @@ -181,21 +181,29 @@ template <class T> inline bool -mx_inline_any_nan (size_t, const T*) { return false; } +mx_inline_any_nan (size_t n, const T* x) +{ + for (size_t i = 0; i < n; i++) + { + if (xisnan (x[i])) + return true; + } -#define DEFMXANYNAN(T) \ -inline bool \ -mx_inline_any_nan (size_t n, const T* t) \ -{ \ - for (size_t i = 0; i < n; i++) \ - if (xisnan (t[i])) return true; \ - return false; \ + return false; } -DEFMXANYNAN(double) -DEFMXANYNAN(float) -DEFMXANYNAN(Complex) -DEFMXANYNAN(FloatComplex) +template<class T> +inline bool +mx_inline_all_real (size_t n, const std::complex<T>* x) +{ + for (size_t i = 0; i < n; i++) + { + if (x[i].imag () != 0) + return false; + } + + return true; +} #define DEFMXMAPPER(F, FUN) \ template <class T> \