ViennaCL - The Vienna Computing Library
1.5.2
|
00001 #ifndef VIENNACL_LINALG_DETAIL_OP_APPLIER_HPP 00002 #define VIENNACL_LINALG_DETAIL_OP_APPLIER_HPP 00003 00004 /* ========================================================================= 00005 Copyright (c) 2010-2014, Institute for Microelectronics, 00006 Institute for Analysis and Scientific Computing, 00007 TU Wien. 00008 Portions of this software are copyright by UChicago Argonne, LLC. 00009 00010 ----------------- 00011 ViennaCL - The Vienna Computing Library 00012 ----------------- 00013 00014 Project Head: Karl Rupp rupp@iue.tuwien.ac.at 00015 00016 (A list of authors and contributors can be found in the PDF manual) 00017 00018 License: MIT (X11), see file LICENSE in the base directory 00019 ============================================================================= */ 00020 00026 #include "viennacl/forwards.h" 00027 #include <cmath> 00028 00029 namespace viennacl 00030 { 00031 namespace linalg 00032 { 00033 namespace detail 00034 { 00035 00042 template <typename OP> 00043 struct op_applier 00044 { 00045 typedef typename OP::ERROR_UNKNOWN_OP_TAG_PROVIDED error_type; 00046 }; 00047 00049 template <> 00050 struct op_applier<op_element_binary<op_prod> > 00051 { 00052 template <typename T> 00053 static void apply(T & result, T const & x, T const & y) { result = x * y; } 00054 }; 00055 00056 template <> 00057 struct op_applier<op_element_binary<op_div> > 00058 { 00059 template <typename T> 00060 static void apply(T & result, T const & x, T const & y) { result = x / y; } 00061 }; 00062 00063 template <> 00064 struct op_applier<op_element_binary<op_pow> > 00065 { 00066 template <typename T> 00067 static void apply(T & result, T const & x, T const & y) { result = std::pow(x, y); } 00068 }; 00069 00070 #define VIENNACL_MAKE_UNARY_OP_APPLIER(funcname) \ 00071 template <> \ 00072 struct op_applier<op_element_unary<op_##funcname> > \ 00073 { \ 00074 template <typename T> \ 00075 static void apply(T & result, T const & x) { using namespace std; result = funcname(x); } \ 00076 } 00077 00078 VIENNACL_MAKE_UNARY_OP_APPLIER(abs); 00079 VIENNACL_MAKE_UNARY_OP_APPLIER(acos); 00080 VIENNACL_MAKE_UNARY_OP_APPLIER(asin); 00081 VIENNACL_MAKE_UNARY_OP_APPLIER(atan); 00082 VIENNACL_MAKE_UNARY_OP_APPLIER(ceil); 00083 VIENNACL_MAKE_UNARY_OP_APPLIER(cos); 00084 VIENNACL_MAKE_UNARY_OP_APPLIER(cosh); 00085 VIENNACL_MAKE_UNARY_OP_APPLIER(exp); 00086 VIENNACL_MAKE_UNARY_OP_APPLIER(fabs); 00087 VIENNACL_MAKE_UNARY_OP_APPLIER(floor); 00088 VIENNACL_MAKE_UNARY_OP_APPLIER(log); 00089 VIENNACL_MAKE_UNARY_OP_APPLIER(log10); 00090 VIENNACL_MAKE_UNARY_OP_APPLIER(sin); 00091 VIENNACL_MAKE_UNARY_OP_APPLIER(sinh); 00092 VIENNACL_MAKE_UNARY_OP_APPLIER(sqrt); 00093 VIENNACL_MAKE_UNARY_OP_APPLIER(tan); 00094 VIENNACL_MAKE_UNARY_OP_APPLIER(tanh); 00095 00096 #undef VIENNACL_MAKE_UNARY_OP_APPLIER 00097 00099 } 00100 } 00101 } 00102 00103 #endif // VIENNACL_LINALG_DETAIL_OP_EXECUTOR_HPP