simple_proxies.hpp
Go to the documentation of this file.
1 /*!
2  * \brief Low level proxy generating functions
3  *
4  *
5  * \author O. Krause
6  * \date 2016
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_DEFAULT_PROXIES_HPP
29 #define REMORA_KERNELS_DEFAULT_PROXIES_HPP
30 
31 #include "../../detail/matrix_proxy_classes.hpp"
32 #include "../../detail/vector_proxy_classes.hpp"
33 
34 // about the purpose of this file:
35 // expression templates are using an expression optimization mechansism
36 // which binds proxies with all kinds of block expressions
37 // therefore those proxy generators can not be used for defining
38 // kernels, as this would generate cyclic include dependencies.
39 // instead we generate "simple" versions of the proxies here
40 
41 namespace remora{namespace bindings {
42 
43 //vector subrange
44 template<class V>
45 vector_range<typename const_expression<V>::type>
46 simple_subrange(vector_expression<V, cpu_tag> const& expression, std::size_t start, std::size_t stop){
47  return vector_range<typename const_expression<V>::type>(expression(), start, stop);
48 }
49 
50 template<class V>
51 vector_range<V>
52 simple_subrange(vector_expression<V, cpu_tag>& expression, std::size_t start, std::size_t stop){
53  return vector_range<V>(expression(), start, stop);
54 }
55 
56 //matrix subrange
57 template<class M>
58 matrix_range<typename const_expression<M>::type>
59 simple_subrange(matrix_expression<M, cpu_tag> const& expression,
60  std::size_t start1, std::size_t stop1, std::size_t start2, std::size_t stop2 ){
61  return matrix_range<typename const_expression<M>::type>(expression(), start1, stop1, start2, stop2);
62 }
63 
64 template<class M>
65 matrix_range<M>
66 simple_subrange(matrix_expression<M, cpu_tag>& expression,
67  std::size_t start1, std::size_t stop1, std::size_t start2, std::size_t stop2 ){
68  return matrix_range<M>(expression(), start1, stop1, start2, stop2);
69 }
70 
71 //matrix row
72 template<class M>
73 matrix_row<typename const_expression<M>::type>
74 simple_row(matrix_expression<M, cpu_tag> const& expression, typename M::size_type i){
75  return matrix_row<typename const_expression<M>::type>(expression(), i);
76 }
77 template<class M>
78 matrix_row<M>
79 simple_row(matrix_expression<M, cpu_tag>& expression, typename M::size_type i){
80  return matrix_row<M>(expression(), i);
81 }
82 
83 //matrix column
84 template<class M>
85 matrix_row< matrix_transpose< typename const_expression<M>::type > >
86 simple_column(matrix_expression<M, cpu_tag> const& expression, typename M::size_type i){
87  typedef matrix_transpose< typename const_expression<M>::type > TransE;
88  TransE transE(expression());
89  return matrix_row< TransE >(transE, i);
90 }
91 template<class M>
92 matrix_row< matrix_transpose<M> >
93 simple_column(matrix_expression<M, cpu_tag>& expression, typename M::size_type i){
94  typedef matrix_transpose<M> TransE;
95  TransE transE(expression());
96  return matrix_row< TransE >(transE, i);
97 }
98 
99 //simple trans
100 template<class M>
101 matrix_transpose< typename const_expression<M>::type >
102 simple_trans(matrix_expression<M, cpu_tag>const& m){
103  return matrix_transpose< typename const_expression<M>::type >(m());
104 }
105 template<class M>
106 matrix_transpose<M>
107 simple_trans(matrix_expression<M, cpu_tag>& m){
108  return matrix_transpose<M>(m());
109 }
110 
111 }}
112 #endif