Apply Expressions
[The Class MArray]

Apply a function object (any object that defines operator()) to all elements of an MArray or Expression.

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
and if it to be used in LTL_USE_SIMD mode, it has to provide
 enum { isVectorizable = 0/1 }
to indicate if it is vectorizable or not. If it is vectorizable, it has to provide
 operator()( VEC_TYPE(parameter_type) )
which will be used during evaluation.

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);
   }
};

Generated on Wed Mar 11 17:44:35 2009 for LTL by  doxygen 1.5.3