For array expression E and function object F
A = ltl::apply( F, E ); // elementwise apply F.operator() to E.
The functor F has to define
typedef typename F::value_type
enum { isVectorizable = 0/1 }
operator()( VEC_TYPE(parameter_type) )
Here's an example:
struct functor { typedef float value_type; enum { isVectorizable = 0 }; value_type operator()( float a ) { return a*a; } };
Here's the same in a vectorzable version:
struct functor { typedef float value_type; enum { isVectorizable = 1 }; float operator()( float a ) { return a*a; } // SSE implementation of float multiply: VEC_TYPE(float) operator()( VEC_TYPE(float) a ) { return _mm_mul_ps(a,a); } };