#ifndef included_FunctionTable #define included_FunctionTable #include "common/ArraySize.h" #include /*! * Class FunctionTable is a serial function table class that defines * a series of operations that can be performed on the Array class. * Users can impliment additional versions of the function table that match * the interface to change the behavior of the array class. */ class FunctionTable final { public: /*! * Initialize the array with random values * @param[in] x The array to operate on */ template static void rand( Array &x ); /*! * Perform a reduce operator y = f(x) * @param[in] op The function operation * Note: the operator is a template parameter * (compared to a std::function to improve performance) * @param[in] A The array to operate on * @return The reduction */ template static inline TYPE reduce( LAMBDA &op, const Array &A ); /*! * Perform a element-wise operation y = f(x) * @param[in] fun The function operation * Note: the operator is a template parameter * (compared to a std::function to improve performance) * @param[in] x The input array to operate on * @param[out] y The output array */ template static inline void transform( LAMBDA &fun, const Array &x, Array &y ); /*! * Perform a element-wise operation z = f(x,y) * @param[in] fun The function operation * Note: the operator is a template parameter * (compared to a std::function to improve performance) * @param[in] x The first array * @param[in] y The second array * @param[out] z The result */ template static inline void transform( LAMBDA &fun, const Array &x, const Array &y, Array &z ); /*! * Multiply two arrays * @param[in] a The first array * @param[in] b The second array * @param[out] c The output array */ template static inline void multiply( const Array &a, const Array &b, Array &c ); /*! * Perform dgemv/dgemm equavalent operation ( C = alpha*A*B + beta*C ) * @param[in] alpha The scalar value alpha * @param[in] A The first array * @param[in] B The second array * @param[in] beta The scalar value alpha * @param[in,out] c The output array C */ template static void gemm( const TYPE alpha, const Array &A, const Array &B, const TYPE beta, Array &C ); /*! * Perform axpy equavalent operation ( y = alpha*x + y ) * @param[in] alpha The scalar value alpha * @param[in] x The input array x * @param[in,out] y The output array y */ template static void axpy( const TYPE alpha, const Array &x, Array &y ); /*! * Check if two arrays are approximately equal * @param[in] A The first array * @param[in] B The second array * @param[in] tol The tolerance */ template static bool equals( const Array &A, const Array &B, TYPE tol ); private: FunctionTable(); }; #endif