Mercurial > hg > octave-max
diff liboctave/Array.h @ 8998:a48fba01e4ac
optimize isnan/isinf/isfinite mappers
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 19 Mar 2009 17:46:38 +0100 |
parents | d865363208d6 |
children | 484756d558d6 |
line wrap: on
line diff
--- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -601,6 +601,26 @@ return result; } + + // This is non-breakable map, suitable for fast functions. Efficiency + // relies on compiler's ability to inline a function pointer. This seems + // to be OK with recent GCC. + template <class U> + Array<U> + fastmap (U (*fcn) (typename ref_param<T>::type)) const + { + octave_idx_type len = length (); + + const T *m = data (); + + Array<U> result (dims ()); + U *p = result.fortran_vec (); + + std::transform (m, m + len, p, fcn); + + return result; + } + }; #endif