All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
op_applier.hpp
Go to the documentation of this file.
#ifndef VIENNACL_LINALG_DETAIL_OP_APPLIER_HPP
#define VIENNACL_LINALG_DETAIL_OP_APPLIER_HPP
/* =========================================================================
Copyright (c) 2010-2016, Institute for Microelectronics,
Institute for Analysis and Scientific Computing,
TU Wien.
Portions of this software are copyright by UChicago Argonne, LLC.
-----------------
ViennaCL - The Vienna Computing Library
-----------------
Project Head: Karl Rupp rupp@iue.tuwien.ac.at
(A list of authors and contributors can be found in the manual)
License: MIT (X11), see file LICENSE in the base directory
============================================================================= */
#include "viennacl/forwards.h"
#include <cmath>
namespace viennacl
{
namespace linalg
{
namespace detail
{
template<typename OpT>
struct op_applier
{
typedef typename OpT::ERROR_UNKNOWN_OP_TAG_PROVIDED error_type;
};
template<>
struct op_applier<op_element_binary<op_prod> >
{
template<typename T>
static void apply(T & result, T const & x, T const & y) { result = x * y; }
};
template<>
struct op_applier<op_element_binary<op_div> >
{
template<typename T>
static void apply(T & result, T const & x, T const & y) { result = x / y; }
};
template<>
struct op_applier<op_element_binary<op_pow> >
{
template<typename T>
static void apply(T & result, T const & x, T const & y) { result = std::pow(x, y); }
};
#define VIENNACL_MAKE_UNARY_OP_APPLIER(funcname) \
template<> \
struct op_applier<op_element_unary<op_##funcname> > \
{ \
template<typename T> \
static void apply(T & result, T const & x) { using namespace std; result = funcname(x); } \
}
VIENNACL_MAKE_UNARY_OP_APPLIER(abs);
VIENNACL_MAKE_UNARY_OP_APPLIER(acos);
VIENNACL_MAKE_UNARY_OP_APPLIER(asin);
VIENNACL_MAKE_UNARY_OP_APPLIER(atan);
VIENNACL_MAKE_UNARY_OP_APPLIER(ceil);
VIENNACL_MAKE_UNARY_OP_APPLIER(cos);
VIENNACL_MAKE_UNARY_OP_APPLIER(cosh);
VIENNACL_MAKE_UNARY_OP_APPLIER(exp);
VIENNACL_MAKE_UNARY_OP_APPLIER(fabs);
VIENNACL_MAKE_UNARY_OP_APPLIER(floor);
VIENNACL_MAKE_UNARY_OP_APPLIER(log);
VIENNACL_MAKE_UNARY_OP_APPLIER(log10);
VIENNACL_MAKE_UNARY_OP_APPLIER(sin);
VIENNACL_MAKE_UNARY_OP_APPLIER(sinh);
VIENNACL_MAKE_UNARY_OP_APPLIER(sqrt);
VIENNACL_MAKE_UNARY_OP_APPLIER(tan);
VIENNACL_MAKE_UNARY_OP_APPLIER(tanh);
#undef VIENNACL_MAKE_UNARY_OP_APPLIER
}
}
}
#endif // VIENNACL_LINALG_DETAIL_OP_EXECUTOR_HPP
viennacl::linalg::detail::op_applier::error_type
OpT::ERROR_UNKNOWN_OP_TAG_PROVIDED error_type
Definition: op_applier.hpp:45
viennacl::linalg::detail::op_applier
Worker class for decomposing expression templates.
Definition: op_applier.hpp:43
forwards.h
This file provides the forward declarations for the main types used within ViennaCL.
viennacl::op_div
A tag class representing division.
Definition: forwards.h:98
viennacl::op_prod
A tag class representing matrix-vector products and element-wise multiplications. ...
Definition: forwards.h:94
viennacl::op_element_binary
A tag class representing element-wise binary operations (like multiplication) on vectors or matrices...
Definition: forwards.h:130