/* * Copyright 2008-2012 NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include #include #include #include namespace thrust { namespace detail { namespace functional { template __host__ __device__ actor< composite< unary_operator, actor > > __host__ __device__ operator-(const actor &_1) { return compose(unary_operator(), _1); } // end operator-() // there's no standard unary_plus functional, so roll an ad hoc one here template struct unary_plus : public thrust::unary_function { __host__ __device__ T operator()(const T &x) const {return +x;} }; // end unary_plus template __host__ __device__ actor< composite< unary_operator, actor > > operator+(const actor &_1) { return compose(unary_operator(), _1); } // end operator+() template __host__ __device__ actor< composite< binary_operator, actor, typename as_actor::type > > operator+(const actor &_1, const T2 &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator+() template __host__ __device__ actor< composite< binary_operator, typename as_actor::type, actor > > operator+(const T1 &_1, const actor &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator+() template __host__ __device__ actor< composite< binary_operator, actor, actor > > operator+(const actor &_1, const actor &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator+() template __host__ __device__ actor< composite< binary_operator, typename as_actor::type, actor > > operator-(const T1 &_1, const actor &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator-() template __host__ __device__ actor< composite< binary_operator, actor, typename as_actor::type > > operator-(const actor &_1, const T2 &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator-() template __host__ __device__ actor< composite< binary_operator, actor, actor > > operator-(const actor &_1, const actor &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator-() template __host__ __device__ actor< composite< binary_operator, typename as_actor::type, actor > > operator*(const T1 &_1, const actor &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator*() template __host__ __device__ actor< composite< binary_operator, actor, typename as_actor::type > > operator*(const actor &_1, const T2 &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator*() template __host__ __device__ actor< composite< binary_operator, actor, actor > > operator*(const actor &_1, const actor &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator*() template __host__ __device__ actor< composite< binary_operator, actor, typename as_actor::type > > operator/(const actor &_1, const T2 &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator/() template __host__ __device__ actor< composite< binary_operator, typename as_actor::type, actor > > operator/(const T1 &_1, const actor &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator/() template __host__ __device__ actor< composite< binary_operator, actor, actor > > operator/(const actor &_1, const actor &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator/() template __host__ __device__ actor< composite< binary_operator, actor, typename as_actor::type > > operator%(const actor &_1, const T2 &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator%() template __host__ __device__ actor< composite< binary_operator, typename as_actor::type, actor > > operator%(const T1 &_1, const actor &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator%() template __host__ __device__ actor< composite< binary_operator, actor, actor > > operator%(const actor &_1, const actor &_2) { return compose(binary_operator(), make_actor(_1), make_actor(_2)); } // end operator%() // there's no standard prefix_increment functional, so roll an ad hoc one here template struct prefix_increment : public thrust::unary_function { __host__ __device__ T& operator()(T &x) const { return ++x; } }; // end prefix_increment template __host__ __device__ actor< composite< unary_operator, actor > > operator++(const actor &_1) { return compose(unary_operator(), _1); } // end operator++() // there's no standard suffix_increment functional, so roll an ad hoc one here template struct suffix_increment : public thrust::unary_function { __host__ __device__ T operator()(T &x) const { return x++; } }; // end suffix_increment template __host__ __device__ actor< composite< unary_operator, actor > > operator++(const actor &_1, int) { return compose(unary_operator(), _1); } // end operator++() // there's no standard prefix_decrement functional, so roll an ad hoc one here template struct prefix_decrement : public thrust::unary_function { __host__ __device__ T& operator()(T &x) const { return --x; } }; // end prefix_decrement template __host__ __device__ actor< composite< unary_operator, actor > > operator--(const actor &_1) { return compose(unary_operator(), _1); } // end operator--() // there's no standard suffix_decrement functional, so roll an ad hoc one here template struct suffix_decrement : public thrust::unary_function { __host__ __device__ T operator()(T &x) const { return x--; } }; // end suffix_decrement template __host__ __device__ actor< composite< unary_operator, actor > > operator--(const actor &_1, int) { return compose(unary_operator(), _1); } // end operator--() } // end functional } // end detail } // end thrust