vector_assign.hpp
Go to the documentation of this file.
1/*!
2 * \brief Assignment kernels for vector expressions
3 *
4 * \author O. Krause
5 * \date 2015
6 *
7 *
8 * \par Copyright 1995-2015 Shark Development Team
9 *
10 * <BR><HR>
11 * This file is part of Shark.
12 * <http://image.diku.dk/shark/>
13 *
14 * Shark is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License as published
16 * by the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * Shark is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public License
25 * along with Shark. If not, see <http://www.gnu.org/licenses/>.
26 *
27 */
28#ifndef REMORA_KERNELS_VECTOR_ASSIGN_HPP
29#define REMORA_KERNELS_VECTOR_ASSIGN_HPP
30
31#include "../detail/traits.hpp"
33#ifdef REMORA_USE_GPU
34#include "gpu/vector_assign.hpp"
35#endif
36
37namespace remora{namespace kernels {
38
39
40template<class V, class F, class Device>
41void apply(vector_expression<V, Device>& v,F const& f) {
42 bindings::apply(v,f);
43}
44template<class F, class V, class Device>
45void assign(vector_expression<V, Device>& v, typename V::value_type t) {
46 bindings::assign<F>(v,t);
47}
48
49/////////////////////////////////////////////////////////
50//direct assignment of two vectors
51////////////////////////////////////////////////////////
52
53//dispatcher
54template< class V, class E, class Device>
55void assign(vector_expression<V, Device>& v, vector_expression<E, Device> const& e) {
56 REMORA_SIZE_CHECK(v().size() == e().size());
57 typedef typename V::evaluation_category::tag TagV;
58 typedef typename E::evaluation_category::tag TagE;
59 bindings::vector_assign(v, e,TagV(),TagE());
60}
61
62////////////////////////////////////////////
63//assignment with functor
64////////////////////////////////////////////
65
66
67// Dispatcher
68template<class F, class V, class E, class Device>
69void assign(vector_expression<V, Device>& v, vector_expression<E, Device> const& e, F f) {
70 REMORA_SIZE_CHECK(v().size() == e().size());
71 typedef typename V::evaluation_category::tag TagV;
72 typedef typename E::evaluation_category::tag TagE;
73 bindings::vector_assign_functor(v(), e(), f, TagV(),TagE());
74}
75
76}}
77#endif